Recent-ish clang doesn't like self-assignment. Google/Android code always uses the [template-based moral equivalent of] __attribute__((__unused__)) to keep both compilers happy. --- lib/lib.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
From 30bba481f1d9e92a008579c3ae5331cb7c808969 Mon Sep 17 00:00:00 2001 From: Elliott Hughes <e...@google.com> Date: Sun, 19 Feb 2017 09:22:45 -0800 Subject: [PATCH] 4a4b3d65644ce403b0f22887fc0d38b0202ec8c7 upset clang.
Recent-ish clang doesn't like self-assignment. Google/Android code always uses the [template-based moral equivalent of] __attribute__((__unused__)) to keep both compilers happy. --- lib/lib.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/lib.c b/lib/lib.c index 6f7ed30..f677614 100644 --- a/lib/lib.c +++ b/lib/lib.c @@ -634,6 +634,7 @@ int copy_tempfile(int fdin, char *name, char **tempname) { struct stat statbuf; int fd; + int ignored __attribute__((__unused__)); *tempname = xmprintf("%s%s", name, "XXXXXX"); if(-1 == (fd = mkstemp(*tempname))) error_exit("no temp file"); @@ -648,9 +649,9 @@ int copy_tempfile(int fdin, char *name, char **tempname) // We chmod before chown, which strips the suid bit. Caller has to explicitly // switch it back on if they want to keep suid. - // I said IGNORING ERRORS. Both gcc and clang clutch their pearls about this - // but it's _supposed_ to fail when we're not root. - if (fchown(fd, statbuf.st_uid, statbuf.st_gid)) fd = fd; + // Suppress warn-unused-result. Both gcc and clang clutch their pearls about + // this but it's _supposed_ to fail when we're not root. + ignored = fchown(fd, statbuf.st_uid, statbuf.st_gid); return fd; } -- 2.11.0.483.g087da7b7c-goog
_______________________________________________ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net