]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal-remote: shorten code a bit by using strcspn()
authorLennart Poettering <lennart@poettering.net>
Fri, 23 Nov 2018 15:52:26 +0000 (16:52 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 26 Nov 2018 13:08:46 +0000 (14:08 +0100)
src/journal-remote/journal-remote-main.c

index 02078dcb4a376919440d46eff786e0736862ae5f..c46e0acdd369354d4a20ec64484b1d4e6d2e2614 100644 (file)
@@ -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)