From 124909c94a1322205484d5014152a3a77ff1e0fe Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Mon, 29 Jul 2013 17:25:47 +0200 Subject: [PATCH] LU-3097 build: fix 'deadcode' errors Fix 'deadcode' issues found by Coverity version 6.5.1: Logically dead code (DEADCODE) Execution cannot reach this statement. Signed-off-by: Sebastien Buisson Change-Id: I720a5ae6f963cd2cc77208a854ca4587758a82d5 Reviewed-on: http://review.whamcloud.com/7167 Reviewed-by: Dmitry Eremin Tested-by: Hudson Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin --- libcfs/libcfs/linux/linux-curproc.c | 4 +-- lustre/ldlm/ldlm_flock.c | 6 ----- lustre/ldlm/ldlm_lib.c | 52 +++++++++++++++++-------------------- lustre/obdclass/obd_mount_server.c | 3 --- lustre/utils/lustre_cfg.c | 13 ---------- 5 files changed, 25 insertions(+), 53 deletions(-) diff --git a/libcfs/libcfs/linux/linux-curproc.c b/libcfs/libcfs/linux/linux-curproc.c index 313c012..2c11370 100644 --- a/libcfs/libcfs/linux/linux-curproc.c +++ b/libcfs/libcfs/linux/linux-curproc.c @@ -254,7 +254,7 @@ static int cfs_access_process_vm(struct task_struct *tsk, unsigned long addr, int cfs_get_environ(const char *key, char *value, int *val_len) { struct mm_struct *mm; - char *buffer, *tmp_buf = NULL; + char *buffer; int buf_len = PAGE_CACHE_SIZE; int key_len = strlen(key); unsigned long addr; @@ -346,8 +346,6 @@ int cfs_get_environ(const char *key, char *value, int *val_len) out: mmput(mm); kfree((void *)buffer); - if (tmp_buf) - kfree((void *)tmp_buf); return rc; } EXPORT_SYMBOL(cfs_get_environ); diff --git a/lustre/ldlm/ldlm_flock.c b/lustre/ldlm/ldlm_flock.c index c141438..2f6e357 100644 --- a/lustre/ldlm/ldlm_flock.c +++ b/lustre/ldlm/ldlm_flock.c @@ -704,12 +704,6 @@ granted: RETURN(-EIO); } - if (rc) { - LDLM_DEBUG(lock, "client-side enqueue waking up: failed (%d)", - rc); - RETURN(rc); - } - LDLM_DEBUG(lock, "client-side enqueue granted"); lock_res_and_lock(lock); diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 84d7660..a5b875a 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -868,34 +868,30 @@ int target_handle_connect(struct ptlrpc_request *req) if (rc) GOTO(out, rc); - if (lustre_msg_get_op_flags(req->rq_reqmsg) & MSG_CONNECT_LIBCLIENT) { - if (!data) { - DEBUG_REQ(D_WARNING, req, "Refusing old (unversioned) " - "libclient connection attempt"); - GOTO(out, rc = -EPROTO); - } else if (data->ocd_version < LUSTRE_VERSION_CODE - - LUSTRE_VERSION_ALLOWED_OFFSET || - data->ocd_version > LUSTRE_VERSION_CODE + - LUSTRE_VERSION_ALLOWED_OFFSET) { - DEBUG_REQ(D_WARNING, req, "Refusing %s (%d.%d.%d.%d) " - "libclient connection attempt", - data->ocd_version < LUSTRE_VERSION_CODE ? - "old" : "new", - OBD_OCD_VERSION_MAJOR(data->ocd_version), - OBD_OCD_VERSION_MINOR(data->ocd_version), - OBD_OCD_VERSION_PATCH(data->ocd_version), - OBD_OCD_VERSION_FIX(data->ocd_version)); - data = req_capsule_server_sized_get(&req->rq_pill, - &RMF_CONNECT_DATA, - offsetof(typeof(*data), ocd_version) + - sizeof(data->ocd_version)); - if (data) { - data->ocd_connect_flags = OBD_CONNECT_VERSION; - data->ocd_version = LUSTRE_VERSION_CODE; - } - GOTO(out, rc = -EPROTO); - } - } + if (lustre_msg_get_op_flags(req->rq_reqmsg) & MSG_CONNECT_LIBCLIENT) { + if (data->ocd_version < LUSTRE_VERSION_CODE - + LUSTRE_VERSION_ALLOWED_OFFSET || + data->ocd_version > LUSTRE_VERSION_CODE + + LUSTRE_VERSION_ALLOWED_OFFSET) { + DEBUG_REQ(D_WARNING, req, "Refusing %s (%d.%d.%d.%d) " + "libclient connection attempt", + data->ocd_version < LUSTRE_VERSION_CODE ? + "old" : "new", + OBD_OCD_VERSION_MAJOR(data->ocd_version), + OBD_OCD_VERSION_MINOR(data->ocd_version), + OBD_OCD_VERSION_PATCH(data->ocd_version), + OBD_OCD_VERSION_FIX(data->ocd_version)); + data = req_capsule_server_sized_get(&req->rq_pill, + &RMF_CONNECT_DATA, + offsetof(typeof(*data), ocd_version) + + sizeof(data->ocd_version)); + if (data) { + data->ocd_connect_flags = OBD_CONNECT_VERSION; + data->ocd_version = LUSTRE_VERSION_CODE; + } + GOTO(out, rc = -EPROTO); + } + } if ((lustre_msg_get_op_flags(req->rq_reqmsg) & MSG_CONNECT_INITIAL) && (data->ocd_connect_flags & OBD_CONNECT_MDS)) diff --git a/lustre/obdclass/obd_mount_server.c b/lustre/obdclass/obd_mount_server.c index ad35237..c3352d7 100644 --- a/lustre/obdclass/obd_mount_server.c +++ b/lustre/obdclass/obd_mount_server.c @@ -567,7 +567,6 @@ out: **/ static int lustre_lwp_setup(struct lustre_cfg *lcfg, struct lustre_sb_info *lsi) { - struct obd_connect_data *data = NULL; struct obd_device *obd; char *lwpname = NULL; char *lwpuuid = NULL; @@ -612,8 +611,6 @@ static int lustre_lwp_setup(struct lustre_cfg *lcfg, struct lustre_sb_info *lsi) if (rc != 0) CERROR("%s: connect failed: rc = %d\n", lwpname, rc); out: - if (data != NULL) - OBD_FREE_PTR(data); if (lwpname != NULL) OBD_FREE(lwpname, MTI_NAME_MAXLEN); if (lwpuuid != NULL) diff --git a/lustre/utils/lustre_cfg.c b/lustre/utils/lustre_cfg.c index e709115..016ae70 100644 --- a/lustre/utils/lustre_cfg.c +++ b/lustre/utils/lustre_cfg.c @@ -139,19 +139,6 @@ int jt_lcfg_attach(int argc, char **argv) if (rc < 0) { fprintf(stderr, "error: %s: LCFG_ATTACH %s\n", jt_cmdname(argv[0]), strerror(rc = errno)); - } else if (argc == 3) { - char name[1024]; - - lcfg_set_devname(argv[2]); - if (strlen(argv[2]) > 128) { - printf("Name too long to set environment\n"); - return -EINVAL; - } - snprintf(name, 512, "LUSTRE_DEV_%s", argv[2]); - rc = setenv(name, argv[1], 1); - if (rc) { - printf("error setting env variable %s\n", name); - } } else { lcfg_set_devname(argv[2]); } -- 1.8.3.1