mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:27:45 +00:00
LibCore+Everywhere: Remove ArgsParser::add*(char const*&)
This is not guaranteed to always work correctly as ArgsParser deals in StringViews and might have a non-properly-null-terminated string as a value. As a bonus, using StringView (and DeprecatedString where necessary) leads to nicer looking code too :^)
This commit is contained in:
parent
60908adcbe
commit
500044906d
43 changed files with 122 additions and 145 deletions
|
@ -49,7 +49,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
bool verbose = false;
|
||||
bool should_close = false;
|
||||
bool udp_mode = false;
|
||||
char const* target = nullptr;
|
||||
DeprecatedString target;
|
||||
int port = 0;
|
||||
int maximum_tcp_receive_buffer_size_input = -1;
|
||||
|
||||
|
@ -96,8 +96,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
sa.sin_family = AF_INET;
|
||||
sa.sin_port = htons(port);
|
||||
sa.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
if (target) {
|
||||
if (inet_pton(AF_INET, target, &sa.sin_addr) <= 0) {
|
||||
if (!target.is_empty()) {
|
||||
if (inet_pton(AF_INET, target.characters(), &sa.sin_addr) <= 0) {
|
||||
perror("inet_pton");
|
||||
return 1;
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
TRY(Core::System::setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)));
|
||||
TRY(Core::System::setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout)));
|
||||
|
||||
auto* hostent = gethostbyname(target);
|
||||
auto* hostent = gethostbyname(target.characters());
|
||||
if (!hostent) {
|
||||
warnln("Socket::connect: Unable to resolve '{}'", target);
|
||||
return 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue