Whamcloud - gitweb
b=19720
authorbrian <brian>
Fri, 9 Oct 2009 13:47:37 +0000 (13:47 +0000)
committerbrian <brian>
Fri, 9 Oct 2009 13:47:37 +0000 (13:47 +0000)
i=robert.read
i=dmitry.zogin

Clean up various warnings stemming from unused variables and unchecked
function return values.

28 files changed:
libcfs/include/libcfs/darwin/darwin-prim.h
libcfs/include/libcfs/posix/libcfs.h
libcfs/include/libcfs/winnt/winnt-prim.h
libcfs/libcfs/linux/linux-debug.c
lnet/lnet/api-ni.c
lnet/selftest/selftest.h
lnet/utils/debug.c
lnet/utils/lstclient.c
lnet/utils/routerstat.c
lustre/liblustre/llite_lib.c
lustre/liblustre/tests/recovery_small.c
lustre/liblustre/tests/sanity.c
lustre/lvfs/fsfilt.c
lustre/mds/handler.c
lustre/obdclass/capa.c
lustre/obdclass/genops.c
lustre/obdfilter/filter.c
lustre/ptlrpc/ptlrpcd.c
lustre/tests/fsx.c
lustre/tests/mmap_sanity.c
lustre/utils/lfs.c
lustre/utils/liblustreapi.c
lustre/utils/llverdev.c
lustre/utils/lreplicate.c
lustre/utils/mkfs_lustre.c
lustre/utils/mount_lustre.c
lustre/utils/mount_utils.c
lustre/utils/obd.c

index 2b877de..ec7036c 100644 (file)
@@ -472,7 +472,7 @@ struct __dummy_ ## name ## _struct {}
 #define inter_module_get(n)                    cfs_symbol_get(n)
 #define inter_module_put(n)                    cfs_symbol_put(n)
 
-static inline int request_module(char *name)
+static inline int request_module(const char *name, ...)
 {
        return (-EINVAL);
 }
index b204213..2173ab9 100644 (file)
@@ -241,7 +241,7 @@ static inline void MODULE_AUTHOR(char *name)
 #define __init
 #define __exit
 
-static inline int request_module(char *name)
+static inline int request_module(const char *name, ...)
 {
         return (-EINVAL);
 }
index accf7a9..3414023 100644 (file)
@@ -745,7 +745,7 @@ struct module {
 extern struct module libcfs_global_module;
 #define THIS_MODULE  &libcfs_global_module
 
-#define request_module(x) (0)
+#define request_module(x, y) (0)
 #define EXPORT_SYMBOL(s)
 #define MODULE_AUTHOR(s)
 #define MODULE_DESCRIPTION(s)
index f08be51..f8dab0f 100644 (file)
@@ -212,7 +212,7 @@ void lbug_with_loc(const char *file, const char *func, const int line)
 static void
 print_trace_warning_symbol(void *data, char *msg, unsigned long symbol)
 {
-       printk(data);
+        printk("%s", (char *)data);
        print_symbol(msg, symbol);
        printk("\n");
 }
index a7a4f2b..86541a7 100644 (file)
@@ -992,7 +992,7 @@ lnet_startup_lndnis (void)
 #ifdef __KERNEL__
                 if (lnd == NULL) {
                         LNET_MUTEX_UP(&the_lnet.ln_lnd_mutex);
-                        rc = request_module(libcfs_lnd2modname(lnd_type));
+                        rc = request_module("%s", libcfs_lnd2modname(lnd_type));
                         LNET_MUTEX_DOWN(&the_lnet.ln_lnd_mutex);
 
                         lnd = lnet_find_lnd_by_type(lnd_type);
index 7312eac..5dc9481 100644 (file)
@@ -430,6 +430,7 @@ void sfw_unpack_message(srpc_msg_t *msg);
 void sfw_free_pages(srpc_server_rpc_t *rpc);
 void sfw_add_bulk_page(srpc_bulk_t *bk, cfs_page_t *pg, int i);
 int sfw_alloc_pages(srpc_server_rpc_t *rpc, int npages, int sink);
+int sfw_make_session (srpc_mksn_reqst_t *request, srpc_mksn_reply_t *reply);
 
 srpc_client_rpc_t *
 srpc_create_client_rpc(lnet_process_id_t peer, int service,
index 3ce3013..8a28b4f 100644 (file)
@@ -363,15 +363,22 @@ static void print_rec(struct dbg_line ***linevp, int used, int fdout)
                 struct dbg_line *line = linev[i];
                 struct ptldebug_header *hdr = line->hdr;
                 char out[4097];
+                char *buf = out;
                 int bytes;
+                ssize_t bytes_written;
 
                 bytes = sprintf(out, "%08x:%08x:%u:%u.%06llu:%u:%u:%u:(%s:%u:%s()) %s",
                                 hdr->ph_subsys, hdr->ph_mask, hdr->ph_cpu_id,
                                 hdr->ph_sec, (unsigned long long)hdr->ph_usec,
                                 hdr->ph_stack, hdr->ph_pid, hdr->ph_extern_pid,
                                 line->file, hdr->ph_line_num, line->fn, line->text);
-
-                write(fdout, out, bytes);
+                while (bytes > 0) {
+                        bytes_written = write(fdout, buf, bytes);
+                        if (bytes_written <= 0)
+                                break;
+                        bytes -= bytes_written;
+                        buf += bytes_written;
+                }
                 free(line->hdr);
                 free(line);
         }
@@ -627,7 +634,8 @@ int jt_dbg_debug_kernel(int argc, char **argv)
                 return 1;
         }
         if (argc > 1) {
-                fdout = open(argv[1], O_WRONLY|O_CREAT|O_TRUNC);
+                fdout = open(argv[1], O_WRONLY | O_CREAT | O_TRUNC,
+                             S_IRUSR | S_IWUSR);
                 if (fdout < 0) {
                         fprintf(stderr, "fopen(%s) failed: %s\n", argv[1],
                                 strerror(errno));
index a439645..26a05c9 100644 (file)
@@ -186,13 +186,13 @@ main(int argc, char **argv)
                         server_mode_flag = 1;
                         break;
                 default:
-                        fprintf(stderr, usage_string);
+                        fprintf(stderr, "%s", usage_string);
                         return -1;
                 }
         }
 
         if (optind != argc || grp == NULL || ses == NULL) {
-                fprintf(stderr, usage_string);
+                fprintf(stderr, "%s", usage_string);
                 return -1;
         }
 
index e518022..c8adc90 100644 (file)
@@ -128,7 +128,7 @@ do_stat (int fd)
    }
    
    if (last == 0.0) {
-          printf ("M %lu(%lu) E %lu S %lu/%llu R %lu/%llu F %lu/%llu D %lu/%llu\n", 
+          printf ("M %lu(%lu) E %lu S %llu/%lu R %llu/%lu F %llu/%lu D %llu/%lu\n",
                   new_counter.msgs_alloc, new_counter.msgs_max,
                   new_counter.errors,
                   new_counter.send_length, new_counter.send_count,
index 7baec8c..bac1928 100644 (file)
@@ -409,7 +409,7 @@ void __liblustre_cleanup_(void)
          * but it can't fix the situation that liblustre is mounted
          * at "/".
          */
-        chdir("/");
+        if (!chdir("/")) {}
 #if 0
         umount(lustre_path);
 #endif
index 5e1da4e..66c3d10 100644 (file)
@@ -50,6 +50,7 @@
 #include <fcntl.h>
 #include <sys/queue.h>
 #include <getopt.h>
+#include <sys/wait.h>
 
 #include <sysio.h>
 #include <mount.h>
@@ -149,7 +150,8 @@ void cleanup_dir(const char *path)
             sprintf(cmd,                                                   \
                     "%s %s \"echo %lu > /proc/sys/lustre/fail_loc\"",      \
                     ssh_cmd, mds_server, drop_arr[drop_index].code);       \
-            if ((rc = system(cmd))) {                                      \
+            if ((rc = system(cmd)) != 0) {                                 \
+                rc = WEXITSTATUS(rc);                                      \
                 printf("error excuting remote command: %d\n", rc);         \
                 exit(rc);                                                  \
             }                                                              \
@@ -163,7 +165,7 @@ void cleanup_dir(const char *path)
         if (drop_arr[drop_index].name) {                                   \
             sprintf(cmd, "%s %s \"echo 0 > /proc/sys/lustre/fail_loc\"",   \
                     ssh_cmd, mds_server);                                  \
-            system(cmd);                                                   \
+            if (!system(cmd)) {}                                           \
         }                                                                  \
     } while (0)
 
index 0fe2645..c0c3c05 100644 (file)
@@ -579,7 +579,7 @@ static int check_file_size(char *file, long long size)
         }
         if (statbuf.st_size != size) {
                 printf("size of %s: %lld != %lld\n", file,
-                       (long long)statbuf.st_size, size);
+                       (long long)statbuf.st_size, (long long )size);
                 return(-1);
         }
         return 0;
@@ -614,7 +614,7 @@ int t20(char *name)
         int fd;
         struct iovec iov[2];
         char buf[100];
-        ssize_t ret;
+        long ret;
         ENTER("trap app's general bad pointer for file i/o");
         snprintf(file, MAX_PATH_LENGTH, "%s/test_t20_file", lustre_path);
 
@@ -731,7 +731,7 @@ int t22(char *name)
         int fd;
         char *str = "1234567890";
         char buf[100];
-        ssize_t ret;
+        long ret;
         ENTER("make sure O_APPEND take effect");
         snprintf(file, MAX_PATH_LENGTH, "%s/test_t22_file", lustre_path);
 
@@ -1093,8 +1093,14 @@ int t52(char *name)
         printf("st_atime=%s", ctime(&statbuf.st_atime));
         atime = statbuf.st_atime;
         for (i = 0; i < 3; i++) {
+                ssize_t num_read;
                 sleep(2);
-                read(fd, buf, sizeof(buf));
+                /* should not ignore read(2)'s return value */
+                num_read = read(fd, buf, sizeof(buf));
+                if (num_read < 0 ) {
+                        printf("read from %s: %s\n", file, strerror(errno));
+                        return -1;
+                }
                 stat(file, &statbuf);
                 printf("st_atime=%s", ctime(&statbuf.st_atime));
                 diff = statbuf.st_atime - atime;
@@ -1361,7 +1367,7 @@ int t56(char *name)
         int fd;
         size_t nbytes;
         off_t basep = 0;
-        ssize_t rc = 0;
+        long rc = 0;
         cfs_dirent_t dir;
 
         ENTER("getdirentries should fail if nbytes is too small");
index cb95e85..b14b9f9 100644 (file)
@@ -114,7 +114,7 @@ struct fsfilt_operations *fsfilt_get_ops(const char *type)
                 snprintf(name, sizeof(name) - 1, "fsfilt_%s", type);
                 name[sizeof(name) - 1] = '\0';
 
-                if (!(rc = request_module(name))) {
+                if (!(rc = request_module("%s", name))) {
                         fs_ops = fsfilt_search_type(type);
                         CDEBUG(D_INFO, "Loaded module '%s'\n", name);
                         if (!fs_ops)
index 00527cb..0c137d9 100644 (file)
@@ -485,7 +485,7 @@ static int __init mds_cmd_init(void)
         struct lprocfs_static_vars lvars;
         int rc;
 
-        request_module("lquota");
+        request_module("%s", "lquota");
         mds_quota_interface_ref = PORTAL_SYMBOL_GET(mds_quota_interface);
         rc = lquota_init(mds_quota_interface_ref);
         if (rc) {
index ba47564..c15e96d 100644 (file)
@@ -289,9 +289,12 @@ int capa_encrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen)
         struct blkcipher_desc desc;
         unsigned int min;
         int rc;
+        char alg[CRYPTO_MAX_ALG_NAME+1] = "aes";
         ENTRY;
 
-        tfm = ll_crypto_alloc_blkcipher("aes", 0, 0 );
+        /* passing "aes" in a variable instead of a constant string keeps gcc
+         * 4.3.2 happy */
+        tfm = ll_crypto_alloc_blkcipher(alg, 0, 0 );
         if (tfm == NULL) {
                 CERROR("failed to load transform for aes\n");
                 RETURN(-EFAULT);
@@ -341,9 +344,12 @@ int capa_decrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen)
         struct blkcipher_desc desc;
         unsigned int min;
         int rc;
+        char alg[CRYPTO_MAX_ALG_NAME+1] = "aes";
         ENTRY;
 
-        tfm = ll_crypto_alloc_blkcipher("aes", 0, 0 );
+        /* passing "aes" in a variable instead of a constant string keeps gcc
+         * 4.3.2 happy */
+        tfm = ll_crypto_alloc_blkcipher(alg, 0, 0 );
         if (tfm == NULL) {
                 CERROR("failed to load transform for aes\n");
                 RETURN(-EFAULT);
index 6e0a2b6..51b4d7e 100644 (file)
@@ -120,7 +120,7 @@ struct obd_type *class_get_type(const char *name)
 #ifdef CONFIG_KMOD
         if (!type) {
                 const char *modname = name;
-                if (!request_module(modname)) {
+                if (!request_module("%s", modname)) {
                         CDEBUG(D_INFO, "Loaded module '%s'\n", modname);
                         type = class_search_type(name);
                 } else {
index 14f6889..c1aa19d 100644 (file)
@@ -4631,7 +4631,7 @@ static int __init obdfilter_init(void)
 
         lprocfs_filter_init_vars(&lvars);
 
-        request_module("lquota");
+        request_module("%s", "lquota");
         OBD_ALLOC(obdfilter_created_scratchpad,
                   OBDFILTER_CREATED_SCRATCHPAD_ENTRIES *
                   sizeof(*obdfilter_created_scratchpad));
index c8f043b..a9f3f9d 100644 (file)
@@ -360,7 +360,7 @@ int ptlrpcd_start(const char *name, struct ptlrpcd_ctl *pc)
         init_completion(&pc->pc_starting);
         init_completion(&pc->pc_finishing);
         spin_lock_init(&pc->pc_lock);
-        snprintf(pc->pc_name, sizeof (pc->pc_name), "%s", name);
+        strncpy(pc->pc_name, name, sizeof(pc->pc_name) - 1);
         pc->pc_set = ptlrpc_prep_set();
         if (pc->pc_set == NULL)
                 GOTO(out, rc = -ENOMEM);
index af93599..f645b08 100644 (file)
@@ -529,8 +529,15 @@ check_trunc_hack(void)
        struct stat statbuf;
        int fd = get_fd();
 
-       ftruncate(fd, (off_t)0);
-       ftruncate(fd, (off_t)100000);
+        /* should not ignore ftruncate(2)'s return value */
+        if (ftruncate(fd, (off_t)0) < 0) {
+                prterr("trunc_hack: ftruncate(0)");
+                exit(1);
+        }
+        if (ftruncate(fd, (off_t)100000) < 0) {
+                prterr("trunc_hack: ftruncate(100000)");
+                exit(1);
+        }
        if (fstat(fd, &statbuf)) {
                prterr("trunc_hack: fstat");
                statbuf.st_size = -1;
@@ -539,7 +546,10 @@ check_trunc_hack(void)
                prt("no extend on truncate! not posix!\n");
                exit(130);
        }
-       ftruncate(fd, 0);
+        if (ftruncate(fd, 0) < 0) {
+                prterr("trunc_hack: ftruncate(0) (2nd call)");
+                exit(1);
+        }
 }
 
 static char *tf_buf = NULL;
index 012c8b9..22ca9bf 100644 (file)
@@ -158,7 +158,11 @@ static int mmap_tst1(char *mnt)
                 perror(mmap_file);
                 return errno;
         }
-        ftruncate(fd, region);
+        if (ftruncate(fd, region) < 0) {
+                perror("ftruncate()");
+                rc = errno;
+                goto out_close;
+        }
 
         ptr = mmap(NULL, region, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
         if (ptr == MAP_FAILED) {
@@ -193,7 +197,11 @@ static int mmap_tst2(char *mnt)
                 perror(mmap_file);
                 return errno;
         }
-        ftruncate(fd, page_size);
+        if (ftruncate(fd, page_size) < 0) {
+                perror("ftruncate()");
+                rc = errno;
+                goto out_close;
+        }
 
         ptr = mmap(NULL, page_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
         if (ptr == MAP_FAILED) {
@@ -250,7 +258,11 @@ static int mmap_tst3(char *mnt)
                 perror(mmap_file);
                 return errno;
         }
-        ftruncate(fd, region);
+        if (ftruncate(fd, region) < 0) {
+                perror("ftruncate()");
+                rc = errno;
+                goto out_close;
+        }
 
         ptr = mmap(NULL, region, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
         if (ptr == MAP_FAILED) {
@@ -328,14 +340,22 @@ static int mmap_tst4(char *mnt)
                 perror(fileb);
                 return errno;
         }
-        ftruncate(fdr, region);
+        if (ftruncate(fdr, region) < 0) {
+                perror("ftruncate()");
+                rc = errno;
+                goto out_close;
+        }
         fdw = open(filea, O_CREAT|O_RDWR, 0600);
         if (fdw < 0) {
                 perror(filea);
                 rc = errno;
                 goto out_close;
         }
-        ftruncate(fdw, region);
+        if (ftruncate(fdw, region) < 0) {
+                perror("ftruncate()");
+                rc = errno;
+                goto out_close;
+        }
         
         ptr = mmap(NULL, region, PROT_READ|PROT_WRITE, MAP_SHARED, fdr, 0);
         if (ptr == MAP_FAILED) {
@@ -494,7 +514,11 @@ static int mmap_tst5(char *mnt)
                 perror(mmap_file);
                 return errno;
         }
-        ftruncate(fd, region);
+        if (ftruncate(fd, region) < 0) {
+                perror("ftruncate()");
+                rc = errno;
+                goto out_close;
+        }
 
         ptr = mmap(NULL, region, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
         if (ptr == MAP_FAILED) {
@@ -549,7 +573,11 @@ static int mmap_tst6(char *mnt)
                 perror(mmap_file);
                 return errno;
         }
-        ftruncate(fd, page_size);
+        if (ftruncate(fd, page_size) < 0) {
+                perror("ftruncate()");
+                rc = errno;
+                goto out;
+        }
 
         fd2 = open(mmap_file2, O_RDWR, 0600);
         if (fd2 < 0) {
index b5e54b4..0e582ed 100644 (file)
@@ -2224,8 +2224,13 @@ static int lfs_flushctx(int argc, char **argv)
                 }
         }
 
-        if (kdestroy)
-                system("kdestroy > /dev/null");
+        if (kdestroy) {
+            int rc;
+            if ((rc = system("kdestroy > /dev/null")) != 0) {
+                rc = WEXITSTATUS(rc);
+                fprintf(stderr, "error destroying tickets: %d, continuing\n", rc);
+            }
+        }
 
         if (optind >= argc) {
                 /* flush for all mounted lustre fs. */
index f8643c6..d0ae79a 100644 (file)
@@ -2677,8 +2677,8 @@ int llapi_changelog_start(void **priv, int flags, const char *device,
         struct changelog_private *cp;
         struct changelog_show cs = {};
         char mdtname[20];
-        char pattern[100];
-        char trigger[100];
+        char pattern[PATH_MAX];
+        char trigger[PATH_MAX];
         int fd, rc, pid;
 
         /* Find mdtname from path, fsname, mdtname, or mdtname_UUID */
index 94db011..085b551 100644 (file)
@@ -502,7 +502,10 @@ int main(int argc, char **argv)
        if (!force && writeoption) {
                printf("%s: permanently overwrite all data on %s (yes/no)? ",
                       progname, devname);
-               scanf("%3s", yesno);
+                if (scanf("%3s", yesno) == EOF && ferror(stdin)) {
+                        perror("reading from stdin");
+                        return -1;
+                }
                if (!(strcasecmp("yes", yesno) || strcasecmp("y", yesno))) {
                        printf("Not continuing due to '%s' response", yesno);
                        return 0;
index b9aeb49..f29dc73 100644 (file)
@@ -1110,7 +1110,8 @@ int lr_write_log()
 
         lr_backup_log();
 
-        fd = open(statuslog, O_WRONLY | O_CREAT | O_SYNC);
+        fd = open(statuslog, O_WRONLY | O_CREAT | O_SYNC,
+                             S_IRUSR | S_IWUSR);
         if (fd == -1) {
                 fprintf(stderr, "Error opening log file for writing (%s)\n",
                         statuslog);
index f8be123..95f7260 100644 (file)
@@ -195,7 +195,12 @@ int get_os_version()
                         fprintf(stderr, "%s: Warning: Can't resolve kernel "
                                 "version, assuming 2.6\n", progname);
                 else {
-                        read(fd, release, 4);
+                        if (read(fd, release, 4) < 0) {
+                                fprintf(stderr, "reading from /proc/sys/kernel"
+                                                "/osrelease: %s\n", strerror(errno));
+                                close(fd);
+                                exit(-1);
+                        }
                         close(fd);
                 }
                 if (strncmp(release, "2.4.", 4) == 0)
@@ -815,6 +820,7 @@ int write_local_files(struct mkfs_opts *mop)
         char *dev;
         FILE *filep;
         int ret = 0;
+        size_t num;
 
         /* Mount this device temporarily in order to write these files */
         if (!mkdtemp(mntpt)) {
@@ -860,7 +866,12 @@ int write_local_files(struct mkfs_opts *mop)
                         progname, filepnm, strerror(errno));
                 goto out_umnt;
         }
-        fwrite(&mop->mo_ldd, sizeof(mop->mo_ldd), 1, filep);
+        num = fwrite(&mop->mo_ldd, sizeof(mop->mo_ldd), 1, filep);
+        if (num < 1 && ferror(filep)) {
+                fprintf(stderr, "%s: Unable to write to file (%s): %s\n",
+                        progname, filepnm, strerror(errno));
+                goto out_umnt;
+        }
         fclose(filep);
         /* COMPAT_146 */
 #ifdef TUNEFS
@@ -965,8 +976,14 @@ int read_local_files(struct mkfs_opts *mop)
         sprintf(filepnm, "%s/mountdata", tmpdir);
         filep = fopen(filepnm, "r");
         if (filep) {
+                size_t num_read;
                 vprint("Reading %s\n", MOUNT_DATA_FILE);
-                fread(&mop->mo_ldd, sizeof(mop->mo_ldd), 1, filep);
+                num_read = fread(&mop->mo_ldd, sizeof(mop->mo_ldd), 1, filep);
+                if (num_read < 1 && ferror(filep)) {
+                        fprintf(stderr, "%s: Unable to read from file (%s): %s\n",
+                                progname, filepnm, strerror(errno));
+                        goto out_close;
+                }
         } else {
                 /* COMPAT_146 */
                 /* Try to read pre-1.6 config from last_rcvd */
index 52b9989..f8fdb0f 100644 (file)
@@ -326,7 +326,12 @@ int read_file(char *path, char *buf, int size)
         if (fd == NULL)
                 return errno;
 
-        fgets(buf, size, fd);
+        /* should not ignore fgets(3)'s return value */
+        if (!fgets(buf, size, fd)) {
+                fprintf(stderr, "reading from %s: %s", path, strerror(errno));
+                fclose(fd);
+                return 1;
+        }
         fclose(fd);
         return 0;
 }
@@ -716,8 +721,12 @@ int main(int argc, char *const argv[])
                 /* May as well try to clean up loop devs */
                 if (strncmp(usource, "/dev/loop", 9) == 0) {
                         char cmd[256];
+                        int ret;
                         sprintf(cmd, "/sbin/losetup -d %s", usource);
-                        system(cmd);
+                        if ((ret = system(cmd)) < 0)
+                                rc = errno;
+                        else if (ret > 0)
+                                rc = WEXITSTATUS(ret);
                 }
 
         } else if (!nomtab) {
index b36a1df..d624656 100644 (file)
@@ -131,8 +131,14 @@ int get_mountdata(char *dev, struct lustre_disk_data *mo_ldd)
         sprintf(filepnm, "%s/mountdata", tmpdir);
         filep = fopen(filepnm, "r");
         if (filep) {
+                size_t num_read;
                 vprint("Reading %s\n", MOUNT_DATA_FILE);
-                fread(mo_ldd, sizeof(*mo_ldd), 1, filep);
+                num_read = fread(mo_ldd, sizeof(*mo_ldd), 1, filep);
+                if (num_read < 1 && ferror(filep)) {
+                        fprintf(stderr, "%s: Unable to read from file (%s): %s\n",
+                                progname, filepnm, strerror(errno));
+                        goto out_close;
+                }
         } else {
                 verrprint("%s: Unable to read %d.%d config %s.\n",
                           progname, LUSTRE_MAJOR, LUSTRE_MINOR, filepnm);
index a912496..4542228 100644 (file)
@@ -953,7 +953,12 @@ try_mdc:
                 goto fail;
 
 got_one:
-        fgets(buf, sizeof(buf), fp);
+        /* should not ignore fgets(3)'s return value */
+        if (!fgets(buf, sizeof(buf), fp)) {
+                fprintf(stderr, "reading from %s: %s", buf, strerror(errno));
+                fclose(fp);
+                return;
+        }
         fclose(fp);
 
         /* trim trailing newlines */