From: Ruben Kerkhof Date: Tue, 29 Nov 2016 16:26:37 +0000 (+0100) Subject: contrib/docker: cleanup wrapper a bit X-Git-Tag: collectd-5.8.0~285^2~2 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=3d0f82ce316e9712e08493d21e7e792d62dff98e contrib/docker: cleanup wrapper a bit - No need to declare errno - Remove one level of indentation --- diff --git a/contrib/docker/rootfs_prefix/rootfs_prefix.c b/contrib/docker/rootfs_prefix/rootfs_prefix.c index c27a67af..65be0720 100644 --- a/contrib/docker/rootfs_prefix/rootfs_prefix.c +++ b/contrib/docker/rootfs_prefix/rootfs_prefix.c @@ -11,28 +11,22 @@ #define BUFSIZE 256 const char *add_prefix(const char *orig, char *prefixed) { - int status; - int errno; - - if ((strncmp(orig, "/proc", 5) == 0) || (strncmp(orig, "/sys", 4) == 0)) { - - status = snprintf(prefixed, BUFSIZE, "%s%s", PREFIX, orig); - if ((unsigned int)status >= BUFSIZE) { - error(status, ENAMETOOLONG, - "'%s' got truncated when adding '%s' prefix: '%s'", orig, PREFIX, - prefixed); - return orig; - } else if (status < 1) { - error(status, errno, - "adding '%s' prefix to file path failed: '%s' -> '%s'", PREFIX, - orig, prefixed); - return orig; - } else { - return (const char *)prefixed; - } + if ((strncmp(orig, "/proc", 5) != 0) && (strncmp(orig, "/sys", 4) != 0)) + return orig; - } else { + int status = snprintf(prefixed, BUFSIZE, "%s%s", PREFIX, orig); + if ((unsigned int)status >= BUFSIZE) { + error(status, ENAMETOOLONG, + "'%s' got truncated when adding '%s' prefix: '%s'", orig, PREFIX, + prefixed); + return orig; + } else if (status < 1) { + error(status, errno, + "adding '%s' prefix to file path failed: '%s' -> '%s'", PREFIX, + orig, prefixed); return orig; + } else { + return (const char *)prefixed; } }