Whamcloud - gitweb
LU-2444 build: fix 'error handling' issues
authorSebastien Buisson <sebastien.buisson@bull.net>
Fri, 7 Dec 2012 15:12:38 +0000 (16:12 +0100)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 9 Feb 2013 03:14:46 +0000 (22:14 -0500)
Fix 'error handling issues' defects found by Coverity version
6.0.3:
Unchecked return value (CHECKED_RETURN)
Value returned from a function is not checked for errors before
being used.
Argument cannot be negative (NEGATIVE_RETURNS)
Negative value used as argument to a function expecting a
positive value.

Signed-off-by: Sebastien Buisson <sebastien.buisson@bull.net>
Change-Id: I44022a7d7227ee46345b77701b4c5199a74c386d
Reviewed-on: http://review.whamcloud.com/4772
Tested-by: Hudson
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Keith Mannthey <keith.mannthey@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/ldlm/ldlm_pool.c
lustre/mgc/mgc_request.c
lustre/mgs/mgs_llog.c
lustre/obdclass/lu_object.c
lustre/ofd/ofd_io.c
lustre/osd-ldiskfs/osd_lproc.c
lustre/utils/mount_lustre.c
lustre/utils/mount_utils.c
lustre/utils/obd.c

index c952970..820a50d 100644 (file)
@@ -845,7 +845,7 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl)
         lprocfs_counter_init(pl->pl_stats, LDLM_POOL_TIMING_STAT,
                              LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
                              "recalc_timing", "sec");
         lprocfs_counter_init(pl->pl_stats, LDLM_POOL_TIMING_STAT,
                              LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
                              "recalc_timing", "sec");
-        lprocfs_register_stats(pl->pl_proc_dir, "stats", pl->pl_stats);
+       rc = lprocfs_register_stats(pl->pl_proc_dir, "stats", pl->pl_stats);
 
         EXIT;
 out_free_name:
 
         EXIT;
 out_free_name:
index 4550de5..411909f 100644 (file)
@@ -1592,8 +1592,9 @@ static int mgc_llog_is_empty(struct obd_device *obd, struct llog_ctxt *ctxt,
        push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
        rc = llog_open(NULL, ctxt, &llh, NULL, name, LLOG_OPEN_EXISTS);
        if (rc == 0) {
        push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
        rc = llog_open(NULL, ctxt, &llh, NULL, name, LLOG_OPEN_EXISTS);
        if (rc == 0) {
-               llog_init_handle(NULL, llh, LLOG_F_IS_PLAIN, NULL);
-               rc = llog_get_size(llh);
+               rc = llog_init_handle(NULL, llh, LLOG_F_IS_PLAIN, NULL);
+               if (rc == 0)
+                       rc = llog_get_size(llh);
                llog_close(NULL, llh);
        } else if (rc == -ENOENT) {
                rc = 0;
                llog_close(NULL, llh);
        } else if (rc == -ENOENT) {
                rc = 0;
index cf43a4b..32c5e03 100644 (file)
@@ -1480,7 +1480,7 @@ static int mgs_log_is_empty(const struct lu_env *env,
                GOTO(out_ctxt, rc);
        }
 
                GOTO(out_ctxt, rc);
        }
 
-       llog_init_handle(env, llh, LLOG_F_IS_PLAIN, NULL);
+       rc = llog_init_handle(env, llh, LLOG_F_IS_PLAIN, NULL);
        if (rc)
                GOTO(out_close, rc);
        rc = llog_get_size(llh);
        if (rc)
                GOTO(out_close, rc);
        rc = llog_get_size(llh);
index fc2596f..2679063 100644 (file)
@@ -1916,9 +1916,9 @@ int lu_printk_printer(const struct lu_env *env,
         return 0;
 }
 
         return 0;
 }
 
-void lu_debugging_setup(void)
+int lu_debugging_setup(void)
 {
 {
-        lu_env_init(&lu_debugging_env, ~0);
+       return lu_env_init(&lu_debugging_env, ~0);
 }
 
 void lu_context_keys_dump(void)
 }
 
 void lu_context_keys_dump(void)
index 043c7ed..ea54334 100644 (file)
@@ -459,7 +459,7 @@ retry:
        }
 
        /* get attr to return */
        }
 
        /* get attr to return */
-       dt_attr_get(env, o, la, ofd_object_capa(env, fo));
+       rc = dt_attr_get(env, o, la, ofd_object_capa(env, fo));
 
 out_stop:
        /* Force commit to make the just-deleted blocks
 
 out_stop:
        /* Force commit to make the just-deleted blocks
index ae2e593..0f522d8 100644 (file)
@@ -228,8 +228,8 @@ static int osd_stats_init(struct osd_device *osd)
                                      LPROCFS_CNTR_AVGMINMAX,
                                      "thandle closing", "usec");
 #endif
                                      LPROCFS_CNTR_AVGMINMAX,
                                      "thandle closing", "usec");
 #endif
-               lprocfs_seq_create(osd->od_proc_entry, "brw_stats",
-                                  0644, &osd_brw_stats_fops, osd);
+               result = lprocfs_seq_create(osd->od_proc_entry, "brw_stats",
+                                           0644, &osd_brw_stats_fops, osd);
         } else
                 result = -ENOMEM;
 
         } else
                 result = -ENOMEM;
 
index 234dbbb..57348a5 100644 (file)
@@ -331,7 +331,8 @@ static int parse_ldd(char *source, struct mount_opts *mop, char *options)
        rc = osd_read_ldd(source, ldd);
        if (rc) {
                fprintf(stderr, "%s: %s failed to read permanent mount"
        rc = osd_read_ldd(source, ldd);
        if (rc) {
                fprintf(stderr, "%s: %s failed to read permanent mount"
-                       " data: %s\n", progname, source, strerror(rc));
+                       " data: %s\n", progname, source,
+                       rc >= 0 ? strerror(rc) : "");
                return rc;
        }
 
                return rc;
        }
 
index b8e97c4..00e5d5c 100644 (file)
@@ -339,7 +339,8 @@ int loop_setup(struct mkfs_opts *mop)
                                continue;
                        if (ret) {
                                fprintf(stderr, "%s: error %d on losetup: %s\n",
                                continue;
                        if (ret) {
                                fprintf(stderr, "%s: error %d on losetup: %s\n",
-                                       progname, ret, strerror(ret));
+                                       progname, ret,
+                                       ret >= 0 ? strerror(ret) : "");
                                return ret;
                        }
                        strscpy(mop->mo_loopdev, l_device,
                                return ret;
                        }
                        strscpy(mop->mo_loopdev, l_device,
index f59b738..e6b9f11 100644 (file)
@@ -233,10 +233,10 @@ static int do_name2dev(char *func, char *name)
 
         memset(buf, 0, sizeof(rawbuf));
         rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
 
         memset(buf, 0, sizeof(rawbuf));
         rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
-        if (rc) {
+       if (rc < 0) {
                 fprintf(stderr, "error: %s: invalid ioctl\n",
                         jt_cmdname(func));
                 fprintf(stderr, "error: %s: invalid ioctl\n",
                         jt_cmdname(func));
-                return rc;
+               return -rc;
         }
         rc = l2_ioctl(OBD_DEV_ID, OBD_IOC_NAME2DEV, buf);
         if (rc < 0)
         }
         rc = l2_ioctl(OBD_DEV_ID, OBD_IOC_NAME2DEV, buf);
         if (rc < 0)