Whamcloud - gitweb
LU-6394 all: fix compilation errors with FORTIFY_SOURCE 26/14126/7
authorFrank Zago <fzago@cray.com>
Fri, 20 Mar 2015 20:37:13 +0000 (15:37 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 6 Apr 2015 01:06:29 +0000 (01:06 +0000)
When Lustre is configured with CFLAGS="-D_FORTIFY_SOURCE=2 -O2" on
Centos 6, the compilation will fails with errors such as this one:

 cacheio.c: In function ‘qword_printhex’:
 cacheio.c:174: error: ignoring return value of ‘fwrite’, declared
   with attribute warn_unused_result

Signed-off-by: frank zago <fzago@cray.com>
Change-Id: Ie06fd5a26b62daf62bfd0133a2d7ebc66ece5be6
Reviewed-on: http://review.whamcloud.com/14126
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: James Simmons <uja.ornl@gmail.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/tests/llapi_fid_test.c
lustre/utils/gss/cacheio.c
lustre/utils/gss/cacheio.h
lustre/utils/gss/context_lucid.c
lustre/utils/gss/svcgssd.c

index 6d08f61..e7d18f9 100644 (file)
@@ -92,7 +92,10 @@ static void cleanup(void)
        rc = snprintf(cmd, sizeof(cmd), "rm -rf -- '%s'", mainpath);
        ASSERTF(rc > 0 && rc < sizeof(cmd),
                "invalid delete command for path '%s'", mainpath);
-       system(cmd);
+       rc = system(cmd);
+       ASSERTF(rc != -1, "Cannot execute rm command");
+       ASSERTF(WEXITSTATUS(rc) == 0,
+               "rm command returned %d", WEXITSTATUS(rc));
 }
 
 /* Helper - call path2fid, fd2fid and fid2path against an existing
index 0a268d4..93eada7 100644 (file)
@@ -154,28 +154,36 @@ void qword_addeol(char **bpp, int *lp)
 
 static char qword_buf[8192];
 static char tmp_buf[8192];
-void qword_print(FILE *f, char *str)
+int qword_print(FILE *f, char *str)
 {
        char *bp = qword_buf;
        int len = sizeof(qword_buf);
+       size_t sret;
+
        qword_add(&bp, &len, str);
-       fwrite(qword_buf, bp-qword_buf, 1, f);
+       sret = fwrite(qword_buf, bp-qword_buf, 1, f);
        /* XXX: */
        memcpy(tmp_buf, qword_buf, bp-qword_buf);
        tmp_buf[bp-qword_buf] = '\0';
        printerr(2, "%s", tmp_buf);
+
+       return sret != 1;
 }
 
-void qword_printhex(FILE *f, char *str, int slen)
+int qword_printhex(FILE *f, char *str, int slen)
 {
        char *bp = qword_buf;
        int len = sizeof(qword_buf);
+       size_t sret;
+
        qword_addhex(&bp, &len, str, slen);
-       fwrite(qword_buf, bp-qword_buf, 1, f);
+       sret = fwrite(qword_buf, bp-qword_buf, 1, f);
        /* XXX: */
        memcpy(tmp_buf, qword_buf, bp-qword_buf);
        tmp_buf[bp-qword_buf] = '\0';
        printerr(2, "%s", tmp_buf);
+
+       return sret != 1;
 }
 
 void qword_printint(FILE *f, int num)
index 6585fc7..4e2da47 100644 (file)
@@ -38,8 +38,8 @@ void qword_addhex(char **bpp, int *lp, char *buf, int blen);
 void qword_addint(char **bpp, int *lp, int n);
 void qword_adduint(char **bpp, int *lp, unsigned int n);
 void qword_addeol(char **bpp, int *lp);
-void qword_print(FILE *f, char *str);
-void qword_printhex(FILE *f, char *str, int slen);
+int qword_print(FILE *f, char *str);
+int qword_printhex(FILE *f, char *str, int slen);
 void qword_printint(FILE *f, int num);
 int qword_eol(FILE *f);
 int readline(int fd, char **buf, int *lenp);
index c5241cc..1f69818 100644 (file)
@@ -263,7 +263,7 @@ derive_key_lucid(const gss_krb5_lucid_key_t *in, gss_krb5_lucid_key_t *out,
        krb5_error_code code;
        unsigned char constant_data[K5CLENGTH];
        krb5_data datain;
-       int keylength;
+       int keylength __attribute__ ((unused));
 #ifdef HAVE_KRB5
        void *enc;
 #endif
index cebd852..457d991 100644 (file)
@@ -149,9 +149,10 @@ static void
 release_parent()
 {
        int status;
+       ssize_t sret __attribute__ ((unused));
 
        if (pipefds[1] > 0) {
-               write(pipefds[1], &status, 1);
+               sret = write(pipefds[1], &status, 1);
                close(pipefds[1]);
                pipefds[1] = -1;
        }