]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD/MINOR: systemd: fix compiler warning about unused result
authorLukas Tribus <luky-37@hotmail.com>
Tue, 10 Dec 2013 07:32:56 +0000 (08:32 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 10 Dec 2013 07:50:55 +0000 (08:50 +0100)
There is a compiler warning after commit 1b6e75fa84 ("MEDIUM: haproxy-
systemd-wrapper: Use haproxy in same directory"):

src/haproxy-systemd-wrapper.c: In function â\80\98locate_haproxyâ\80\99:
src/haproxy-systemd-wrapper.c:28:10: warning: ignoring return value of â\80\98readlinkâ\80\99, declared with attribute warn_unused_result [-Wunused-result]

Fix the compiler warning by checking the return value of readlink().

src/haproxy-systemd-wrapper.c

index 4ca86dd3b8c0cb3be79d79ad2c2d7ebbbaa9f307..c63f41ff7df6f538721b3b0f1cb50fc8f39e642e 100644 (file)
@@ -24,9 +24,9 @@ static char **main_argv;
 
 static void locate_haproxy(char *buffer, size_t buffer_size)
 {
-       char* end;
-       readlink("/proc/self/exe", buffer, buffer_size);
-       end = strrchr(buffer, '/');
+       char* end = NULL;
+       if (readlink("/proc/self/exe", buffer, buffer_size) > 0)
+               end = strrchr(buffer, '/');
        if (end == NULL)
                strncpy(buffer, "/usr/sbin/haproxy", buffer_size);
        end[1] = '\0';