diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-11-23 16:52:26 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-11-26 14:08:46 +0100 |
commit | 15d121b0e2c391d7ab5bd05b92c16682191ad001 (patch) | |
tree | 031a2163abfbe80d9338f6209e4e9febd8e136fa /src/journal-remote | |
parent | da9fc98ded5b0931782c0422752f2daf7fe4557c (diff) | |
download | systemd-15d121b0e2c391d7ab5bd05b92c16682191ad001.tar.gz systemd-15d121b0e2c391d7ab5bd05b92c16682191ad001.tar.bz2 systemd-15d121b0e2c391d7ab5bd05b92c16682191ad001.zip |
journal-remote: shorten code a bit by using strcspn()
Diffstat (limited to 'src/journal-remote')
-rw-r--r-- | src/journal-remote/journal-remote-main.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/journal-remote/journal-remote-main.c b/src/journal-remote/journal-remote-main.c index 02078dcb4a..c46e0acdd3 100644 --- a/src/journal-remote/journal-remote-main.c +++ b/src/journal-remote/journal-remote-main.c @@ -614,15 +614,14 @@ static int create_remoteserver( if (arg_url) { const char *url; - char *hostname, *p; + char *hostname; if (!strstr(arg_url, "/entries")) { if (endswith(arg_url, "/")) url = strjoina(arg_url, "entries"); else url = strjoina(arg_url, "/entries"); - } - else + } else url = strdupa(arg_url); log_info("Spawning curl %s...", url); @@ -634,11 +633,7 @@ static int create_remoteserver( if (!hostname) hostname = arg_url; - hostname = strdupa(hostname); - if ((p = strchr(hostname, '/'))) - *p = '\0'; - if ((p = strchr(hostname, ':'))) - *p = '\0'; + hostname = strndupa(hostname, strcspn(hostname, "/:")); r = journal_remote_add_source(s, fd, hostname, false); if (r < 0) |