]> git.tuebingen.mpg.de Git - adu.git/commitdiff
fd.c: Avoid gcc warning regarding fchdir().
authorAndre Noll <maan@tuebingen.mpg.de>
Sat, 4 Jun 2016 14:43:43 +0000 (16:43 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Sat, 4 Jun 2016 14:43:43 +0000 (16:43 +0200)
gcc-4.8.4 on Ubuntu-14.04 complains about our use of fchdir():

fd.c:181:9: warning: ignoring return value of ‘fchdir’, declared with attribute warn_unused_result [-Wunused-result]
   fchdir(*cwd);

Silence the warning by introducing a dummy variable. The patch also
fixes the indentation of the comment which explains why we ignore
the return value here.

fd.c

diff --git a/fd.c b/fd.c
index 902e8f1898d29c7ace5a481c4f731ce7134f4433..39e98374b3acb9ccc727426bf0b6b06d047b57e7 100644 (file)
--- a/fd.c
+++ b/fd.c
@@ -176,9 +176,10 @@ int adu_opendir(const char *dirname, DIR **dir, int *cwd)
        if (*dir)
                return 1;
        ret = -ERRNO_TO_ERROR(errno);
-/* Ignore return value of fchdir() and close(). We're busted anyway. */
-       if (cwd)
-               fchdir(*cwd);
+       /* Ignore return value of fchdir() and close(). We're busted anyway. */
+       if (cwd) {
+               int __a_unused ret2 = fchdir(*cwd); /* STFU, gcc */
+       }
 close_cwd:
        if (cwd)
                close(*cwd);