From 7bf1d7c6cb7d0a7231b3fdcb9e3d3ec3129fb427 Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Fri, 7 Dec 2012 16:12:38 +0100 Subject: [PATCH] LU-2444 build: fix 'error handling' issues 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 Change-Id: I44022a7d7227ee46345b77701b4c5199a74c386d Reviewed-on: http://review.whamcloud.com/4772 Tested-by: Hudson Reviewed-by: Bob Glossman Tested-by: Maloo Reviewed-by: Keith Mannthey Reviewed-by: Oleg Drokin --- lustre/ldlm/ldlm_pool.c | 2 +- lustre/mgc/mgc_request.c | 5 +++-- lustre/mgs/mgs_llog.c | 2 +- lustre/obdclass/lu_object.c | 4 ++-- lustre/ofd/ofd_io.c | 2 +- lustre/osd-ldiskfs/osd_lproc.c | 4 ++-- lustre/utils/mount_lustre.c | 3 ++- lustre/utils/mount_utils.c | 3 ++- lustre/utils/obd.c | 4 ++-- 9 files changed, 16 insertions(+), 13 deletions(-) diff --git a/lustre/ldlm/ldlm_pool.c b/lustre/ldlm/ldlm_pool.c index c952970..820a50d 100644 --- a/lustre/ldlm/ldlm_pool.c +++ b/lustre/ldlm/ldlm_pool.c @@ -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_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: diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index 4550de5..411909f 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -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) { - 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; diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c index cf43a4b..32c5e03 100644 --- a/lustre/mgs/mgs_llog.c +++ b/lustre/mgs/mgs_llog.c @@ -1480,7 +1480,7 @@ static int mgs_log_is_empty(const struct lu_env *env, 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); diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index fc2596f..2679063 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -1916,9 +1916,9 @@ int lu_printk_printer(const struct lu_env *env, 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) diff --git a/lustre/ofd/ofd_io.c b/lustre/ofd/ofd_io.c index 043c7ed..ea54334 100644 --- a/lustre/ofd/ofd_io.c +++ b/lustre/ofd/ofd_io.c @@ -459,7 +459,7 @@ retry: } /* 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 diff --git a/lustre/osd-ldiskfs/osd_lproc.c b/lustre/osd-ldiskfs/osd_lproc.c index ae2e593..0f522d8 100644 --- a/lustre/osd-ldiskfs/osd_lproc.c +++ b/lustre/osd-ldiskfs/osd_lproc.c @@ -228,8 +228,8 @@ static int osd_stats_init(struct osd_device *osd) 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; diff --git a/lustre/utils/mount_lustre.c b/lustre/utils/mount_lustre.c index 234dbbb..57348a5 100644 --- a/lustre/utils/mount_lustre.c +++ b/lustre/utils/mount_lustre.c @@ -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" - " data: %s\n", progname, source, strerror(rc)); + " data: %s\n", progname, source, + rc >= 0 ? strerror(rc) : ""); return rc; } diff --git a/lustre/utils/mount_utils.c b/lustre/utils/mount_utils.c index b8e97c4..00e5d5c 100644 --- a/lustre/utils/mount_utils.c +++ b/lustre/utils/mount_utils.c @@ -339,7 +339,8 @@ int loop_setup(struct mkfs_opts *mop) 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, diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index f59b738..e6b9f11 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -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)); - if (rc) { + if (rc < 0) { 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) -- 1.8.3.1