From d2a13989d2e29b1f4cb38b50462e047cb935e96b Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Tue, 16 Feb 2016 00:46:52 -0500 Subject: [PATCH] staging/lustre/include: Adjust NULL comparison codestyle All instances of "x == NULL" are changed to "!x" and "x != NULL" to "x" Also remove some redundant assertions. Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/include/cl_object.h | 6 +-- .../staging/lustre/lustre/include/lclient.h | 4 +- .../staging/lustre/lustre/include/linux/obd.h | 6 +-- .../lustre/lustre/include/lprocfs_status.h | 6 +-- .../staging/lustre/lustre/include/lu_object.h | 6 +-- .../lustre/lustre/include/lustre/lustre_idl.h | 6 +-- .../lustre/lustre/include/lustre_cfg.h | 5 +- .../lustre/lustre/include/lustre_dlm.h | 16 +++--- .../lustre/lustre/include/lustre_export.h | 11 ----- .../lustre/lustre/include/lustre_lib.h | 8 +-- .../lustre/lustre/include/lustre_log.h | 12 ++--- .../lustre/lustre/include/lustre_mdc.h | 10 ++-- .../lustre/lustre/include/lustre_net.h | 13 ++--- drivers/staging/lustre/lustre/include/obd.h | 7 ++- .../staging/lustre/lustre/include/obd_class.h | 49 +++++++++---------- .../lustre/lustre/include/obd_support.h | 1 - 16 files changed, 72 insertions(+), 94 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h index c8f45695dd85..373e772e360d 100644 --- a/drivers/staging/lustre/lustre/include/cl_object.h +++ b/drivers/staging/lustre/lustre/include/cl_object.h @@ -2653,7 +2653,7 @@ static inline int lu_device_is_cl(const struct lu_device *d) static inline struct cl_device *lu2cl_dev(const struct lu_device *d) { - LASSERT(d == NULL || IS_ERR(d) || lu_device_is_cl(d)); + LASSERT(!d || IS_ERR(d) || lu_device_is_cl(d)); return container_of0(d, struct cl_device, cd_lu_dev); } @@ -2664,7 +2664,7 @@ static inline struct lu_device *cl2lu_dev(struct cl_device *d) static inline struct cl_object *lu2cl(const struct lu_object *o) { - LASSERT(o == NULL || IS_ERR(o) || lu_device_is_cl(o->lo_dev)); + LASSERT(!o || IS_ERR(o) || lu_device_is_cl(o->lo_dev)); return container_of0(o, struct cl_object, co_lu); } @@ -2681,7 +2681,7 @@ static inline struct cl_object *cl_object_next(const struct cl_object *obj) static inline struct cl_device *cl_object_device(const struct cl_object *o) { - LASSERT(o == NULL || IS_ERR(o) || lu_device_is_cl(o->co_lu.lo_dev)); + LASSERT(!o || IS_ERR(o) || lu_device_is_cl(o->co_lu.lo_dev)); return container_of0(o->co_lu.lo_dev, struct cl_device, cd_lu_dev); } diff --git a/drivers/staging/lustre/lustre/include/lclient.h b/drivers/staging/lustre/lustre/include/lclient.h index 36e7a6767e71..7f0a045a3b4d 100644 --- a/drivers/staging/lustre/lustre/include/lclient.h +++ b/drivers/staging/lustre/lustre/include/lclient.h @@ -127,7 +127,7 @@ static inline struct ccc_thread_info *ccc_env_info(const struct lu_env *env) struct ccc_thread_info *info; info = lu_context_key_get(&env->le_ctx, &ccc_key); - LASSERT(info != NULL); + LASSERT(info); return info; } @@ -156,7 +156,7 @@ static inline struct ccc_session *ccc_env_session(const struct lu_env *env) struct ccc_session *ses; ses = lu_context_key_get(env->le_ses, &ccc_session_key); - LASSERT(ses != NULL); + LASSERT(ses); return ses; } diff --git a/drivers/staging/lustre/lustre/include/linux/obd.h b/drivers/staging/lustre/lustre/include/linux/obd.h index 468bc28be895..240947b74590 100644 --- a/drivers/staging/lustre/lustre/include/linux/obd.h +++ b/drivers/staging/lustre/lustre/include/linux/obd.h @@ -73,7 +73,7 @@ static inline void __client_obd_list_lock(client_obd_lock_t *lock, while (1) { if (spin_trylock(&lock->lock)) { - LASSERT(lock->task == NULL); + LASSERT(!lock->task); lock->task = current; lock->func = func; lock->line = line; @@ -85,7 +85,7 @@ static inline void __client_obd_list_lock(client_obd_lock_t *lock, time_before(lock->time + 5 * HZ, jiffies)) { struct task_struct *task = lock->task; - if (task == NULL) + if (!task) continue; LCONSOLE_WARN("%s:%d: lock %p was acquired by <%s:%d:%s:%d> for %lu seconds.\n", @@ -108,7 +108,7 @@ static inline void __client_obd_list_lock(client_obd_lock_t *lock, static inline void client_obd_list_unlock(client_obd_lock_t *lock) { - LASSERT(lock->task != NULL); + LASSERT(lock->task); lock->task = NULL; lock->time = jiffies; spin_unlock(&lock->lock); diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 97c2d7e9161d..88f754e39c2e 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -407,7 +407,7 @@ static inline int lprocfs_stats_lock(struct lprocfs_stats *stats, int opc, } else { unsigned int cpuid = get_cpu(); - if (unlikely(stats->ls_percpu[cpuid] == NULL)) { + if (unlikely(!stats->ls_percpu[cpuid])) { rc = lprocfs_stats_alloc_one(stats, cpuid); if (rc < 0) { put_cpu(); @@ -521,11 +521,11 @@ static inline __u64 lprocfs_stats_collector(struct lprocfs_stats *stats, unsigned long flags = 0; __u64 ret = 0; - LASSERT(stats != NULL); + LASSERT(stats); num_cpu = lprocfs_stats_lock(stats, LPROCFS_GET_NUM_CPU, &flags); for (i = 0; i < num_cpu; i++) { - if (stats->ls_percpu[i] == NULL) + if (!stats->ls_percpu[i]) continue; ret += lprocfs_read_helper( lprocfs_stats_counter_get(stats, i, idx), diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h index 0b22e5ee99ac..c1c7aa1bc484 100644 --- a/drivers/staging/lustre/lustre/include/lu_object.h +++ b/drivers/staging/lustre/lustre/include/lu_object.h @@ -392,7 +392,7 @@ struct lu_device_type_operations { static inline int lu_device_is_md(const struct lu_device *d) { - return ergo(d != NULL, d->ld_type->ldt_tags & LU_DEVICE_MD); + return ergo(d, d->ld_type->ldt_tags & LU_DEVICE_MD); } /** @@ -1119,7 +1119,7 @@ struct lu_context_key { CLASSERT(PAGE_CACHE_SIZE >= sizeof (*value)); \ \ value = kzalloc(sizeof(*value), GFP_NOFS); \ - if (value == NULL) \ + if (!value) \ value = ERR_PTR(-ENOMEM); \ \ return value; \ @@ -1174,7 +1174,7 @@ void lu_context_key_revive (struct lu_context_key *key); do { \ LU_CONTEXT_KEY_INIT(key); \ key = va_arg(args, struct lu_context_key *); \ - } while (key != NULL); \ + } while (key); \ va_end(args); \ } diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index b064b5821e3f..c64642669c60 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -807,7 +807,7 @@ static inline void fid_be_to_cpu(struct lu_fid *dst, const struct lu_fid *src) static inline int fid_is_sane(const struct lu_fid *fid) { - return fid != NULL && + return fid && ((fid_seq(fid) >= FID_SEQ_START && fid_ver(fid) == 0) || fid_is_igif(fid) || fid_is_idif(fid) || fid_seq_is_rsvd(fid_seq(fid))); @@ -3273,7 +3273,7 @@ static inline void lustre_set_wire_obdo(struct obd_connect_data *ocd, { *wobdo = *lobdo; wobdo->o_flags &= ~OBD_FL_LOCAL_MASK; - if (ocd == NULL) + if (!ocd) return; if (unlikely(!(ocd->ocd_connect_flags & OBD_CONNECT_FID)) && @@ -3300,7 +3300,7 @@ static inline void lustre_get_wire_obdo(struct obd_connect_data *ocd, lobdo->o_flags &= ~OBD_FL_LOCAL_MASK; lobdo->o_flags |= local_flags; } - if (ocd == NULL) + if (!ocd) return; if (unlikely(!(ocd->ocd_connect_flags & OBD_CONNECT_FID)) && diff --git a/drivers/staging/lustre/lustre/include/lustre_cfg.h b/drivers/staging/lustre/lustre/include/lustre_cfg.h index d30d8b054c92..1bc35c41075d 100644 --- a/drivers/staging/lustre/lustre/include/lustre_cfg.h +++ b/drivers/staging/lustre/lustre/include/lustre_cfg.h @@ -128,7 +128,7 @@ static inline void lustre_cfg_bufs_set(struct lustre_cfg_bufs *bufs, { if (index >= LUSTRE_CFG_MAX_BUFCOUNT) return; - if (bufs == NULL) + if (!bufs) return; if (bufs->lcfg_bufcount <= index) @@ -158,7 +158,6 @@ static inline void *lustre_cfg_buf(struct lustre_cfg *lcfg, int index) int offset; int bufcount; - LASSERT (lcfg != NULL); LASSERT (index >= 0); bufcount = lcfg->lcfg_bufcount; @@ -191,7 +190,7 @@ static inline char *lustre_cfg_string(struct lustre_cfg *lcfg, int index) return NULL; s = lustre_cfg_buf(lcfg, index); - if (s == NULL) + if (!s) return NULL; /* diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index 11a841a1c87c..51f416dd54d8 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -465,7 +465,6 @@ struct ldlm_namespace { */ static inline int ns_connect_cancelset(struct ldlm_namespace *ns) { - LASSERT(ns != NULL); return !!(ns->ns_connect_flags & OBD_CONNECT_CANCELSET); } @@ -474,14 +473,12 @@ static inline int ns_connect_cancelset(struct ldlm_namespace *ns) */ static inline int ns_connect_lru_resize(struct ldlm_namespace *ns) { - LASSERT(ns != NULL); return !!(ns->ns_connect_flags & OBD_CONNECT_LRU_RESIZE); } static inline void ns_register_cancel(struct ldlm_namespace *ns, ldlm_cancel_for_recovery arg) { - LASSERT(ns != NULL); ns->ns_cancel_for_recovery = arg; } @@ -921,7 +918,7 @@ static inline int ldlm_lvbo_init(struct ldlm_resource *res) { struct ldlm_namespace *ns = ldlm_res_to_ns(res); - if (ns->ns_lvbo != NULL && ns->ns_lvbo->lvbo_init != NULL) + if (ns->ns_lvbo && ns->ns_lvbo->lvbo_init) return ns->ns_lvbo->lvbo_init(res); return 0; @@ -931,7 +928,7 @@ static inline int ldlm_lvbo_size(struct ldlm_lock *lock) { struct ldlm_namespace *ns = ldlm_lock_to_ns(lock); - if (ns->ns_lvbo != NULL && ns->ns_lvbo->lvbo_size != NULL) + if (ns->ns_lvbo && ns->ns_lvbo->lvbo_size) return ns->ns_lvbo->lvbo_size(lock); return 0; @@ -941,10 +938,9 @@ static inline int ldlm_lvbo_fill(struct ldlm_lock *lock, void *buf, int len) { struct ldlm_namespace *ns = ldlm_lock_to_ns(lock); - if (ns->ns_lvbo != NULL) { - LASSERT(ns->ns_lvbo->lvbo_fill != NULL); + if (ns->ns_lvbo) return ns->ns_lvbo->lvbo_fill(lock, buf, len); - } + return 0; } @@ -1015,7 +1011,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, /** Non-rate-limited lock printing function for debugging purposes. */ #define LDLM_DEBUG(lock, fmt, a...) do { \ - if (likely(lock != NULL)) { \ + if (likely(lock)) { \ LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_DLMTRACE, NULL); \ ldlm_lock_debug(&msgdata, D_DLMTRACE, NULL, lock, \ "### " fmt, ##a); \ @@ -1091,7 +1087,7 @@ ldlm_handle2lock_long(const struct lustre_handle *h, __u64 flags) struct ldlm_lock *lock; lock = __ldlm_handle2lock(h, flags); - if (lock != NULL) + if (lock) LDLM_LOCK_REF_DEL(lock); return lock; } diff --git a/drivers/staging/lustre/lustre/include/lustre_export.h b/drivers/staging/lustre/lustre/include/lustre_export.h index a030a98f5656..86f91ce08691 100644 --- a/drivers/staging/lustre/lustre/include/lustre_export.h +++ b/drivers/staging/lustre/lustre/include/lustre_export.h @@ -228,7 +228,6 @@ static inline __u64 exp_connect_flags(struct obd_export *exp) static inline int exp_max_brw_size(struct obd_export *exp) { - LASSERT(exp != NULL); if (exp_connect_flags(exp) & OBD_CONNECT_BRW_SIZE) return exp->exp_connect_data.ocd_brw_size; @@ -242,19 +241,16 @@ static inline int exp_connect_multibulk(struct obd_export *exp) static inline int exp_connect_cancelset(struct obd_export *exp) { - LASSERT(exp != NULL); return !!(exp_connect_flags(exp) & OBD_CONNECT_CANCELSET); } static inline int exp_connect_lru_resize(struct obd_export *exp) { - LASSERT(exp != NULL); return !!(exp_connect_flags(exp) & OBD_CONNECT_LRU_RESIZE); } static inline int exp_connect_rmtclient(struct obd_export *exp) { - LASSERT(exp != NULL); return !!(exp_connect_flags(exp) & OBD_CONNECT_RMT_CLIENT); } @@ -268,14 +264,11 @@ static inline int client_is_remote(struct obd_export *exp) static inline int exp_connect_vbr(struct obd_export *exp) { - LASSERT(exp != NULL); - LASSERT(exp->exp_connection); return !!(exp_connect_flags(exp) & OBD_CONNECT_VBR); } static inline int exp_connect_som(struct obd_export *exp) { - LASSERT(exp != NULL); return !!(exp_connect_flags(exp) & OBD_CONNECT_SOM); } @@ -288,7 +281,6 @@ static inline int imp_connect_lru_resize(struct obd_import *imp) { struct obd_connect_data *ocd; - LASSERT(imp != NULL); ocd = &imp->imp_connect_data; return !!(ocd->ocd_connect_flags & OBD_CONNECT_LRU_RESIZE); } @@ -300,7 +292,6 @@ static inline int exp_connect_layout(struct obd_export *exp) static inline bool exp_connect_lvb_type(struct obd_export *exp) { - LASSERT(exp != NULL); if (exp_connect_flags(exp) & OBD_CONNECT_LVB_TYPE) return true; else @@ -311,7 +302,6 @@ static inline bool imp_connect_lvb_type(struct obd_import *imp) { struct obd_connect_data *ocd; - LASSERT(imp != NULL); ocd = &imp->imp_connect_data; if (ocd->ocd_connect_flags & OBD_CONNECT_LVB_TYPE) return true; @@ -331,7 +321,6 @@ static inline bool imp_connect_disp_stripe(struct obd_import *imp) { struct obd_connect_data *ocd; - LASSERT(imp != NULL); ocd = &imp->imp_connect_data; return ocd->ocd_connect_flags & OBD_CONNECT_DISP_STRIPE; } diff --git a/drivers/staging/lustre/lustre/include/lustre_lib.h b/drivers/staging/lustre/lustre/include/lustre_lib.h index cfccf7ca04c4..8f821df3bd3f 100644 --- a/drivers/staging/lustre/lustre/include/lustre_lib.h +++ b/drivers/staging/lustre/lustre/include/lustre_lib.h @@ -540,7 +540,7 @@ do { \ l_add_wait(&wq, &__wait); \ \ /* Block all signals (just the non-fatal ones if no timeout). */ \ - if (info->lwi_on_signal != NULL && (__timeout == 0 || __allow_intr)) \ + if (info->lwi_on_signal && (__timeout == 0 || __allow_intr)) \ __blocked = cfs_block_sigsinv(LUSTRE_FATAL_SIGS); \ else \ __blocked = cfs_block_sigsinv(0); \ @@ -562,13 +562,13 @@ do { \ __timeout = cfs_time_sub(__timeout, \ cfs_time_sub(interval, remaining));\ if (__timeout == 0) { \ - if (info->lwi_on_timeout == NULL || \ + if (!info->lwi_on_timeout || \ info->lwi_on_timeout(info->lwi_cb_data)) { \ ret = -ETIMEDOUT; \ break; \ } \ /* Take signals after the timeout expires. */ \ - if (info->lwi_on_signal != NULL) \ + if (info->lwi_on_signal) \ (void)cfs_block_sigsinv(LUSTRE_FATAL_SIGS);\ } \ } \ @@ -578,7 +578,7 @@ do { \ if (condition) \ break; \ if (cfs_signal_pending()) { \ - if (info->lwi_on_signal != NULL && \ + if (info->lwi_on_signal && \ (__timeout == 0 || __allow_intr)) { \ if (info->lwi_on_signal != LWI_ON_SIGNAL_NOOP) \ info->lwi_on_signal(info->lwi_cb_data);\ diff --git a/drivers/staging/lustre/lustre/include/lustre_log.h b/drivers/staging/lustre/lustre/include/lustre_log.h index e4fc8b5e1336..155a0e6bef08 100644 --- a/drivers/staging/lustre/lustre/include/lustre_log.h +++ b/drivers/staging/lustre/lustre/include/lustre_log.h @@ -255,7 +255,7 @@ struct llog_ctxt { static inline int llog_handle2ops(struct llog_handle *loghandle, struct llog_operations **lop) { - if (loghandle == NULL || loghandle->lgh_logops == NULL) + if (!loghandle || !loghandle->lgh_logops) return -EINVAL; *lop = loghandle->lgh_logops; @@ -272,7 +272,7 @@ static inline struct llog_ctxt *llog_ctxt_get(struct llog_ctxt *ctxt) static inline void llog_ctxt_put(struct llog_ctxt *ctxt) { - if (ctxt == NULL) + if (!ctxt) return; LASSERT_ATOMIC_GT_LT(&ctxt->loc_refcount, 0, LI_POISON); CDEBUG(D_INFO, "PUTting ctxt %p : new refcount %d\n", ctxt, @@ -294,7 +294,7 @@ static inline int llog_group_set_ctxt(struct obd_llog_group *olg, LASSERT(index >= 0 && index < LLOG_MAX_CTXTS); spin_lock(&olg->olg_lock); - if (olg->olg_ctxts[index] != NULL) { + if (olg->olg_ctxts[index]) { spin_unlock(&olg->olg_lock); return -EEXIST; } @@ -311,7 +311,7 @@ static inline struct llog_ctxt *llog_group_get_ctxt(struct obd_llog_group *olg, LASSERT(index >= 0 && index < LLOG_MAX_CTXTS); spin_lock(&olg->olg_lock); - if (olg->olg_ctxts[index] == NULL) + if (!olg->olg_ctxts[index]) ctxt = NULL; else ctxt = llog_ctxt_get(olg->olg_ctxts[index]); @@ -335,7 +335,7 @@ static inline struct llog_ctxt *llog_get_context(struct obd_device *obd, static inline int llog_group_ctxt_null(struct obd_llog_group *olg, int index) { - return (olg->olg_ctxts[index] == NULL); + return (!olg->olg_ctxts[index]); } static inline int llog_ctxt_null(struct obd_device *obd, int index) @@ -354,7 +354,7 @@ static inline int llog_next_block(const struct lu_env *env, rc = llog_handle2ops(loghandle, &lop); if (rc) return rc; - if (lop->lop_next_block == NULL) + if (!lop->lop_next_block) return -EOPNOTSUPP; rc = lop->lop_next_block(env, loghandle, cur_idx, next_idx, diff --git a/drivers/staging/lustre/lustre/include/lustre_mdc.h b/drivers/staging/lustre/lustre/include/lustre_mdc.h index 3da373315856..db460049b43f 100644 --- a/drivers/staging/lustre/lustre/include/lustre_mdc.h +++ b/drivers/staging/lustre/lustre/include/lustre_mdc.h @@ -81,8 +81,8 @@ static inline void mdc_init_rpc_lock(struct mdc_rpc_lock *lck) static inline void mdc_get_rpc_lock(struct mdc_rpc_lock *lck, struct lookup_intent *it) { - if (it != NULL && (it->it_op == IT_GETATTR || it->it_op == IT_LOOKUP || - it->it_op == IT_LAYOUT)) + if (it && (it->it_op == IT_GETATTR || it->it_op == IT_LOOKUP || + it->it_op == IT_LAYOUT)) return; /* This would normally block until the existing request finishes. @@ -112,15 +112,15 @@ static inline void mdc_get_rpc_lock(struct mdc_rpc_lock *lck, goto again; } - LASSERT(lck->rpcl_it == NULL); + LASSERT(!lck->rpcl_it); lck->rpcl_it = it; } static inline void mdc_put_rpc_lock(struct mdc_rpc_lock *lck, struct lookup_intent *it) { - if (it != NULL && (it->it_op == IT_GETATTR || it->it_op == IT_LOOKUP || - it->it_op == IT_LAYOUT)) + if (it && (it->it_op == IT_GETATTR || it->it_op == IT_LOOKUP || + it->it_op == IT_LAYOUT)) return; if (lck->rpcl_it == MDC_FAKE_RPCL_IT) { /* OBD_FAIL_MDC_RPCS_SEM */ diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index d9c726769de6..c4a0b004f3d0 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -1518,7 +1518,7 @@ struct ptlrpc_request { static inline int ptlrpc_req_interpret(const struct lu_env *env, struct ptlrpc_request *req, int rc) { - if (req->rq_interpret_reply != NULL) { + if (req->rq_interpret_reply) { req->rq_status = req->rq_interpret_reply(env, req, &req->rq_async_args, rc); @@ -2141,8 +2141,8 @@ struct ptlrpc_service_part { #define ptlrpc_service_for_each_part(part, i, svc) \ for (i = 0; \ i < (svc)->srv_ncpts && \ - (svc)->srv_parts != NULL && \ - ((part) = (svc)->srv_parts[i]) != NULL; i++) + (svc)->srv_parts && \ + ((part) = (svc)->srv_parts[i]); i++) /** * Declaration of ptlrpcd control structure @@ -2259,7 +2259,6 @@ static inline bool nrs_policy_compat_all(const struct ptlrpc_service *svc, static inline bool nrs_policy_compat_one(const struct ptlrpc_service *svc, const struct ptlrpc_nrs_pol_desc *desc) { - LASSERT(desc->pd_compat_svc_name != NULL); return strcmp(svc->srv_name, desc->pd_compat_svc_name) == 0; } @@ -2303,7 +2302,6 @@ static inline int ptlrpc_client_bulk_active(struct ptlrpc_request *req) struct ptlrpc_bulk_desc *desc; int rc; - LASSERT(req != NULL); desc = req->rq_bulk; if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_BULK_UNLINK) && @@ -2726,7 +2724,7 @@ ptlrpc_client_recv_or_unlink(struct ptlrpc_request *req) static inline void ptlrpc_client_wake_req(struct ptlrpc_request *req) { - if (req->rq_set == NULL) + if (!req->rq_set) wake_up(&req->rq_reply_waitq); else wake_up(&req->rq_set->set_waitq); @@ -2750,7 +2748,7 @@ ptlrpc_rs_decref(struct ptlrpc_reply_state *rs) /* Should only be called once per req */ static inline void ptlrpc_req_drop_rs(struct ptlrpc_request *req) { - if (req->rq_reply_state == NULL) + if (!req->rq_reply_state) return; /* shouldn't occur */ ptlrpc_rs_decref(req->rq_reply_state); req->rq_reply_state = NULL; @@ -2807,7 +2805,6 @@ ptlrpc_server_get_timeout(struct ptlrpc_service_part *svcpt) static inline struct ptlrpc_service * ptlrpc_req2svc(struct ptlrpc_request *req) { - LASSERT(req->rq_rqbd != NULL); return req->rq_rqbd->rqbd_svcpt->scp_service; } diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index c64a4999f20c..22453599d6e4 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -123,7 +123,7 @@ static inline bool lsm_is_released(struct lov_stripe_md *lsm) static inline bool lsm_has_objects(struct lov_stripe_md *lsm) { - if (lsm == NULL) + if (!lsm) return false; if (lsm_is_released(lsm)) return false; @@ -1224,7 +1224,7 @@ static inline struct md_open_data *obd_mod_alloc(void) struct md_open_data *mod; mod = kzalloc(sizeof(*mod), GFP_NOFS); - if (mod == NULL) + if (!mod) return NULL; atomic_set(&mod->mod_refcount, 1); return mod; @@ -1271,7 +1271,7 @@ static inline bool filename_is_volatile(const char *name, int namelen, int *idx) return false; /* caller does not care of idx */ - if (idx == NULL) + if (!idx) return true; /* volatile file, the MDT can be set from name */ @@ -1306,7 +1306,6 @@ bad_format: static inline int cli_brw_size(struct obd_device *obd) { - LASSERT(obd != NULL); return obd->u.cli.cl_max_pages_per_rpc << PAGE_CACHE_SHIFT; } diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 4f631e6bf048..a4d36003ac48 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -306,7 +306,7 @@ static inline int obd_check_dev_active(struct obd_device *obd) / sizeof(((struct obd_ops *)(0))->iocontrol)) #define OBD_COUNTER_INCREMENT(obdx, op) \ - if ((obdx)->obd_stats != NULL) { \ + if ((obdx)->obd_stats) { \ unsigned int coffset; \ coffset = (unsigned int)((obdx)->obd_cntr_base) + \ OBD_COUNTER_OFFSET(op); \ @@ -315,7 +315,7 @@ static inline int obd_check_dev_active(struct obd_device *obd) } #define EXP_COUNTER_INCREMENT(export, op) \ - if ((export)->exp_obd->obd_stats != NULL) { \ + if ((export)->exp_obd->obd_stats) { \ unsigned int coffset; \ coffset = (unsigned int)((export)->exp_obd->obd_cntr_base) + \ OBD_COUNTER_OFFSET(op); \ @@ -329,7 +329,7 @@ static inline int obd_check_dev_active(struct obd_device *obd) / sizeof(((struct md_ops *)(0))->getstatus)) #define MD_COUNTER_INCREMENT(obdx, op) \ - if ((obd)->md_stats != NULL) { \ + if ((obd)->md_stats) { \ unsigned int coffset; \ coffset = (unsigned int)((obdx)->md_cntr_base) + \ MD_COUNTER_OFFSET(op); \ @@ -338,24 +338,24 @@ static inline int obd_check_dev_active(struct obd_device *obd) } #define EXP_MD_COUNTER_INCREMENT(export, op) \ - if ((export)->exp_obd->obd_stats != NULL) { \ + if ((export)->exp_obd->obd_stats) { \ unsigned int coffset; \ coffset = (unsigned int)((export)->exp_obd->md_cntr_base) + \ MD_COUNTER_OFFSET(op); \ LASSERT(coffset < (export)->exp_obd->md_stats->ls_num); \ lprocfs_counter_incr((export)->exp_obd->md_stats, coffset); \ - if ((export)->exp_md_stats != NULL) \ + if ((export)->exp_md_stats) \ lprocfs_counter_incr( \ (export)->exp_md_stats, coffset); \ } #define EXP_CHECK_MD_OP(exp, op) \ do { \ - if ((exp) == NULL) { \ + if (!(exp)) { \ CERROR("obd_" #op ": NULL export\n"); \ return -ENODEV; \ } \ - if ((exp)->exp_obd == NULL || !OBT((exp)->exp_obd)) { \ + if (!(exp)->exp_obd || !OBT((exp)->exp_obd)) { \ CERROR("obd_" #op ": cleaned up obd\n"); \ return -EOPNOTSUPP; \ } \ @@ -379,11 +379,11 @@ do { \ #define EXP_CHECK_DT_OP(exp, op) \ do { \ - if ((exp) == NULL) { \ + if (!(exp)) { \ CERROR("obd_" #op ": NULL export\n"); \ return -ENODEV; \ } \ - if ((exp)->exp_obd == NULL || !OBT((exp)->exp_obd)) { \ + if (!(exp)->exp_obd || !OBT((exp)->exp_obd)) { \ CERROR("obd_" #op ": cleaned up obd\n"); \ return -EOPNOTSUPP; \ } \ @@ -467,7 +467,7 @@ static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg) DECLARE_LU_VARS(ldt, d); ldt = obd->obd_type->typ_lu; - if (ldt != NULL) { + if (ldt) { struct lu_context session_ctx; struct lu_env env; @@ -509,7 +509,7 @@ static inline int obd_precleanup(struct obd_device *obd, return rc; ldt = obd->obd_type->typ_lu; d = obd->obd_lu_dev; - if (ldt != NULL && d != NULL) { + if (ldt && d) { if (cleanup_stage == OBD_CLEANUP_EXPORTS) { struct lu_env env; @@ -538,7 +538,7 @@ static inline int obd_cleanup(struct obd_device *obd) ldt = obd->obd_type->typ_lu; d = obd->obd_lu_dev; - if (ldt != NULL && d != NULL) { + if (ldt && d) { struct lu_env env; rc = lu_env_init(&env, ldt->ldt_ctx_tags); @@ -586,7 +586,7 @@ obd_process_config(struct obd_device *obd, int datalen, void *data) obd->obd_process_conf = 1; ldt = obd->obd_type->typ_lu; d = obd->obd_lu_dev; - if (ldt != NULL && d != NULL) { + if (ldt && d) { struct lu_env env; rc = lu_env_init(&env, ldt->ldt_ctx_tags); @@ -674,7 +674,7 @@ static inline int obd_alloc_memmd(struct obd_export *exp, struct lov_stripe_md **mem_tgt) { LASSERT(mem_tgt); - LASSERT(*mem_tgt == NULL); + LASSERT(!*mem_tgt); return obd_unpackmd(exp, mem_tgt, NULL, 0); } @@ -767,7 +767,7 @@ static inline int obd_setattr_rqset(struct obd_export *exp, EXP_COUNTER_INCREMENT(exp, setattr_async); set = ptlrpc_prep_set(); - if (set == NULL) + if (!set) return -ENOMEM; rc = OBP(exp->exp_obd, setattr_async)(exp, oinfo, oti, set); @@ -858,7 +858,7 @@ static inline int obd_connect(const struct lu_env *env, rc = OBP(obd, connect)(env, exp, obd, cluuid, data, localdata); /* check that only subset is granted */ - LASSERT(ergo(data != NULL, (data->ocd_connect_flags & ocf) == + LASSERT(ergo(data, (data->ocd_connect_flags & ocf) == data->ocd_connect_flags)); return rc; } @@ -882,8 +882,7 @@ static inline int obd_reconnect(const struct lu_env *env, rc = OBP(obd, reconnect)(env, exp, obd, cluuid, d, localdata); /* check that only subset is granted */ - LASSERT(ergo(d != NULL, - (d->ocd_connect_flags & ocf) == d->ocd_connect_flags)); + LASSERT(ergo(d, (d->ocd_connect_flags & ocf) == d->ocd_connect_flags)); return rc; } @@ -998,7 +997,7 @@ static inline int obd_init_export(struct obd_export *exp) { int rc = 0; - if ((exp)->exp_obd != NULL && OBT((exp)->exp_obd) && + if ((exp)->exp_obd && OBT((exp)->exp_obd) && OBP((exp)->exp_obd, init_export)) rc = OBP(exp->exp_obd, init_export)(exp); return rc; @@ -1006,7 +1005,7 @@ static inline int obd_init_export(struct obd_export *exp) static inline int obd_destroy_export(struct obd_export *exp) { - if ((exp)->exp_obd != NULL && OBT((exp)->exp_obd) && + if ((exp)->exp_obd && OBT((exp)->exp_obd) && OBP((exp)->exp_obd, destroy_export)) OBP(exp->exp_obd, destroy_export)(exp); return 0; @@ -1023,7 +1022,7 @@ static inline int obd_statfs_async(struct obd_export *exp, int rc = 0; struct obd_device *obd; - if (exp == NULL || exp->exp_obd == NULL) + if (!exp || !exp->exp_obd) return -EINVAL; obd = exp->exp_obd; @@ -1059,7 +1058,7 @@ static inline int obd_statfs_rqset(struct obd_export *exp, int rc = 0; set = ptlrpc_prep_set(); - if (set == NULL) + if (!set) return -ENOMEM; oinfo.oi_osfs = osfs; @@ -1081,7 +1080,7 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp, int rc = 0; struct obd_device *obd = exp->exp_obd; - if (obd == NULL) + if (!obd) return -EINVAL; OBD_CHECK_DT_OP(obd, statfs, -EOPNOTSUPP); @@ -1241,7 +1240,7 @@ static inline int obd_notify_observer(struct obd_device *observer, * Also, call non-obd listener, if any */ onu = &observer->obd_upcall; - if (onu->onu_upcall != NULL) + if (onu->onu_upcall) rc2 = onu->onu_upcall(observer, observed, ev, onu->onu_owner, NULL); else @@ -1287,7 +1286,7 @@ static inline int obd_health_check(const struct lu_env *env, int rc; /* don't use EXP_CHECK_DT_OP, because NULL method is normal here */ - if (obd == NULL || !OBT(obd)) { + if (!obd || !OBT(obd)) { CERROR("cleaned up obd\n"); return -EOPNOTSUPP; } diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h index d031437c0528..506753c32d2c 100644 --- a/drivers/staging/lustre/lustre/include/obd_support.h +++ b/drivers/staging/lustre/lustre/include/obd_support.h @@ -507,7 +507,6 @@ extern char obd_jobid_var[]; do { \ struct portals_handle *__h = (handle); \ \ - LASSERT(handle != NULL); \ __h->h_cookie = (unsigned long)(ptr); \ __h->h_size = (size); \ call_rcu(&__h->h_rcu, class_handle_free_cb); \ -- 2.30.2