Staging: lustre: libcfs: libcfs_lock.c: Remove explicit NULL comparison
PATCH v2 7/16 Staging: lustre: libcfs: libcfs_lock.c: Remove explicit NULL comparison
Remove explicit NULL comparison and write it in its simpler form. Replacement done with coccinelle:
@replace_rule@
expression e;
@@
-e == NULL
+ !e
---
Change in v2-
No change
drivers/staging/lustre/lustre/libcfs/libcfs_lock.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/lustre/lustre/libcfs/libcfs_lock.c +3 -3
@@ -63,12 +63,12 @@ cfs_percpt_lock_alloc(struct cfs_cpt_table *cptab)/* NB: cptab can be NULL, pcl will be for HW CPUs on that case */ LIBCFS_ALLOC (pcl,sizeof (*pcl)); -if (pcl ==NULL ) +if (!pcl)return NULL ; pcl->pcl_cptab = cptab; pcl->pcl_locks =cfs_percpt_alloc (cptab,sizeof (*lock)); -if (pcl->pcl_locks ==NULL ) { +if (!pcl->pcl_locks) {LIBCFS_FREE (pcl,sizeof (*pcl));return NULL ; }
@@ -164,7 +164,7 @@ cfs_percpt_atomic_alloc(struct cfs_cpt_table *cptab, int init_val)int i; refs =cfs_percpt_alloc (cptab,sizeof (*ref)); -if (refs ==NULL ) +if (!refs)return NULL ;cfs_percpt_for_each (ref, i, refs)
Signature · 1 line
2.1.4
PATCH v2 8/16 Staging: lustre: libcfs: libcfs_mem.c: Remove explicit NULL comparison
Remove explicit NULL comparison and write it in its simpler form. Replacement done with coccinelle:
@replace_rule@
expression e;
@@
-e == NULL
+ !e
---
Change in v2-
No change
drivers/staging/lustre/lustre/libcfs/libcfs_mem.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/staging/lustre/lustre/libcfs/libcfs_mem.c +5 -5
@@ -84,7 +84,7 @@ cfs_percpt_alloc(struct cfs_cpt_table *cptab, unsigned int size) count =cfs_cpt_number (cptab); LIBCFS_ALLOC(arr, offsetof(struct cfs_var_array, va_ptrs[count])); -if (arr ==NULL ) +if (!arr)return NULL ; arr->va_size = size =L1_CACHE_ALIGN (size);
@@ -93,7 +93,7 @@ cfs_percpt_alloc(struct cfs_cpt_table *cptab, unsigned int size)for (i =0 ; i < count; i++) {LIBCFS_CPT_ALLOC (arr->va_ptrs[i], cptab, i, size); -if (arr->va_ptrs[i] ==NULL ) { +if (!arr->va_ptrs[i]) {cfs_percpt_free ((void *)&arr->va_ptrs[0 ]);return NULL ; }
@@ -160,7 +160,7 @@ cfs_array_free(void *vars) arr = container_of(vars, struct cfs_var_array, va_ptrs[0]);for (i =0 ; i < arr->va_count; i++) { -if (arr->va_ptrs[i] ==NULL ) +if (!arr->va_ptrs[i])continue ;LIBCFS_FREE (arr->va_ptrs[i], arr->va_size);
@@ -182,7 +182,7 @@ cfs_array_alloc(int count, unsigned int size)int i; LIBCFS_ALLOC(arr, offsetof(struct cfs_var_array, va_ptrs[count])); -if (arr ==NULL ) +if (!arr)return NULL ; arr->va_count = count;
@@ -191,7 +191,7 @@ cfs_array_alloc(int count, unsigned int size)for (i =0 ; i < count; i++) {LIBCFS_ALLOC (arr->va_ptrs[i], size); -if (arr->va_ptrs[i] ==NULL ) { +if (!arr->va_ptrs[i]) {cfs_array_free ((void *)&arr->va_ptrs[0 ]);return NULL ; }
Signature · 1 line
2.1.4
PATCH v2 9/16 Staging: lustre: obdclass: obd_config.c: Remove explicit NULL comparison
In reply to Shraddha BarkeRemove explicit NULL comparison and write it in its simpler form. Replacement done with coccinelle:
@replace_rule@
expression e;
@@
-e == NULL
+ !e
---
Change in v2-
No change
.../staging/lustre/lustre/obdclass/obd_config.c | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-)
drivers/staging/lustre/lustre/obdclass/obd_config.c +15 -15
@@ -61,7 +61,7 @@ int class_find_param(char *buf, char *key, char **valp)return 1 ; ptr =strstr (buf, key); -if (ptr ==NULL ) +if (!ptr)return 1 ;if (valp)
@@ -92,11 +92,11 @@ struct cfg_interop_param *class_find_old_param(const char *param,char *value =NULL ;int name_len =0 ; -if (param ==NULL || ptr ==NULL ) +if (!param || !ptr)return NULL ; value =strchr (param,'=' ); -if (value ==NULL ) +if (!value) name_len =strlen (param);else name_len = value - param;
@@ -144,7 +144,7 @@ int class_get_next_param(char **params, char *copy)while (1 ) { q1 =strpbrk (str," '\"" ); -if (q1 ==NULL ) { +if (!q1) { len =strlen (str);memcpy (copy, str, len); copy[len] ='\0' ;
@@ -165,7 +165,7 @@ int class_get_next_param(char **params, char *copy)/* search for the matching closing quote */ str = q1 +1 ; q2 =strchr (str, *q1); -if (q2 ==NULL ) { +if (!q2) {CERROR ("Unbalanced quota in parameters: \"%s\"\n" , *params);return -EINVAL ;
@@ -243,7 +243,7 @@ static int class_parse_value(char *buf, int opc, void *value, char **endh,/* nid separators or end of nids */ endp =strpbrk (buf,",: /" ); -if (endp ==NULL ) +if (!endp) endp = buf +strlen (buf); tmp = *endp;
@@ -841,14 +841,14 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc,LASSERT (proflen == (strlen (prof) +1 )); lprof->lp_profile =kmemdup (prof, proflen,GFP_NOFS ); -if (lprof->lp_profile ==NULL ) { +if (!lprof->lp_profile) { err = -ENOMEM ; goto free_lprof; }LASSERT (osclen == (strlen (osc) +1 )); lprof->lp_dt =kmemdup (osc, osclen,GFP_NOFS ); -if (lprof->lp_dt ==NULL ) { +if (!lprof->lp_dt) { err = -ENOMEM ; goto free_lp_profile; }
@@ -856,7 +856,7 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc,if (mdclen >0 ) {LASSERT (mdclen == (strlen (mdc) +1 )); lprof->lp_md =kmemdup (mdc, mdclen,GFP_NOFS ); -if (lprof->lp_md ==NULL ) { +if (!lprof->lp_md) { err = -ENOMEM ; goto free_lp_dt; }
@@ -963,15 +963,15 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg,int name_len =0 ;int new_len =0 ; -if (cfg ==NULL || new_name ==NULL ) +if (!cfg || !new_name)return ERR_PTR (-EINVAL ); param =lustre_cfg_string (cfg,1 ); -if (param ==NULL ) +if (!param)return ERR_PTR (-EINVAL ); value =strchr (param,'=' ); -if (value ==NULL ) +if (!value) name_len =strlen (param);else name_len = value - param;
@@ -1000,7 +1000,7 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg,kfree (new_param);kfree (bufs); -if (new_cfg ==NULL ) +if (!new_cfg)return ERR_PTR (-ENOMEM ); new_cfg->lcfg_num = cfg->lcfg_num;
@@ -1178,7 +1178,7 @@ int class_process_config(struct lustre_cfg *lcfg) }/* Commands that require a device */ obd =class_name2obd (lustre_cfg_string (lcfg,0 )); -if (obd ==NULL ) { +if (!obd) {if (!LUSTRE_CFG_BUFLEN (lcfg,0 ))CERROR ("this lcfg command requires a device name\n" );else
@@ -1481,7 +1481,7 @@ int class_config_llog_handler(const struct lu_env *env,* moving them to index [1] and [2], and insert MGC's * obdname at index [0]. */ -if (clli && clli->cfg_instance ==NULL && +if (clli && !clli->cfg_instance && lcfg->lcfg_command ==LCFG_SPTLRPC_CONF ) {lustre_cfg_bufs_set (&bufs,2 , bufs.lcfg_buf[1 ], bufs.lcfg_buflen[1 ]);
Signature · 1 line
2.1.4
PATCH v2 10/16 Staging: lustre: obdclass: genops.c: Remove explicit NULL comparison
In reply to Shraddha BarkeRemove explicit NULL comparison and write it in its simpler form. Replacement done with coccinelle:
@replace_rule@
expression e;
@@
-e == NULL
+ !e
---
Changes in v2-
Considering cases with != NULL also
drivers/staging/lustre/lustre/obdclass/genops.c | 54 ++++++++++++------------- 1 file changed, 27 insertions(+), 27 deletions(-)
drivers/staging/lustre/lustre/obdclass/genops.c +27 -27
@@ -178,9 +178,9 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, type->typ_md_ops =kzalloc (sizeof (*type->typ_md_ops),GFP_NOFS ); type->typ_name =kzalloc (strlen (name) +1 ,GFP_NOFS ); -if (type->typ_dt_ops ==NULL || - type->typ_md_ops ==NULL || - type->typ_name ==NULL ) +if (!type->typ_dt_ops || + !type->typ_md_ops || + !type->typ_name) goto failed; *(type->typ_dt_ops) = *dt_ops;
@@ -293,13 +293,13 @@ struct obd_device *class_newdev(const char *type_name, const char *name) } type =class_get_type (type_name); -if (type ==NULL ) { +if (!type) {CERROR ("OBD: unknown type: %s\n" , type_name);return ERR_PTR (-ENODEV ); } newdev =obd_device_alloc (); -if (newdev ==NULL ) { +if (!newdev) { result =ERR_PTR (-ENOMEM ); goto out_type; }
@@ -339,7 +339,7 @@ struct obd_device *class_newdev(const char *type_name, const char *name) }write_unlock (&obd_dev_lock); -if (result ==NULL && i >=class_devno_max ()) { +if (!result && i >=class_devno_max ()) {CERROR ("all %u OBD devices used, increase MAX_OBD_DEVICES\n" ,class_devno_max ()); result =ERR_PTR (-EOVERFLOW );
@@ -463,7 +463,7 @@ struct obd_device *class_num2obd(int num)if (num <class_devno_max ()) { obd = obd_devs[num]; -if (obd ==NULL ) +if (!obd)return NULL ; LASSERTF(obd->obd_magic == OBD_DEVICE_MAGIC,
@@ -509,7 +509,7 @@ void class_obd_list(void)for (i =0 ; i <class_devno_max (); i++) {struct obd_device *obd =class_num2obd (i); -if (obd ==NULL ) +if (!obd)continue ;if (obd->obd_stopping) status ="ST" ;
@@ -540,7 +540,7 @@ struct obd_device *class_find_client_obd(struct obd_uuid *tgt_uuid,for (i =0 ; i <class_devno_max (); i++) {struct obd_device *obd =class_num2obd (i); -if (obd ==NULL ) +if (!obd)continue ;if ((strncmp (obd->obd_type->typ_name, typ_name,strlen (typ_name)) ==0 )) {
@@ -567,7 +567,7 @@ struct obd_device *class_devices_in_group(struct obd_uuid *grp_uuid, int *next) {int i; -if (next ==NULL ) +if (!next) i =0 ;else if (*next >=0 && *next <class_devno_max ()) i = *next;
@@ -578,10 +578,10 @@ struct obd_device *class_devices_in_group(struct obd_uuid *grp_uuid, int *next)for (; i <class_devno_max (); i++) {struct obd_device *obd =class_num2obd (i); -if (obd ==NULL ) +if (!obd)continue ;if (obd_uuid_equals (grp_uuid, &obd->obd_uuid)) { -if (next !=NULL ) +if (next) *next = i+1 ;read_unlock (&obd_dev_lock);return obd;
@@ -609,7 +609,7 @@ int class_notify_sptlrpc_conf(const char *fsname, int namelen)for (i =0 ; i <class_devno_max (); i++) { obd =class_num2obd (i); -if (obd ==NULL || obd->obd_set_up ==0 || obd->obd_stopping) +if (!obd || obd->obd_set_up ==0 || obd->obd_stopping)continue ;/* only notify mdc, osc, mdt, ost */
@@ -659,27 +659,27 @@ void obd_cleanup_caches(void)int obd_init_caches (void ) { -LASSERT (obd_device_cachep ==NULL ); +LASSERT (!obd_device_cachep); obd_device_cachep =kmem_cache_create ("ll_obd_dev_cache" ,sizeof (struct obd_device ),0 ,0 ,NULL );if (!obd_device_cachep) goto out; -LASSERT (obdo_cachep ==NULL ); +LASSERT (!obdo_cachep); obdo_cachep =kmem_cache_create ("ll_obdo_cache" ,sizeof (struct obdo ),0 ,0 ,NULL );if (!obdo_cachep) goto out; -LASSERT (import_cachep ==NULL ); +LASSERT (!import_cachep); import_cachep =kmem_cache_create ("ll_import_cache" ,sizeof (struct obd_import ),0 ,0 ,NULL );if (!import_cachep) goto out; -LASSERT (capa_cachep ==NULL ); +LASSERT (!capa_cachep); capa_cachep =kmem_cache_create ("capa_cache" ,sizeof (struct obd_capa ),0 ,0 ,NULL );if (!capa_cachep)
@@ -740,7 +740,7 @@ struct obd_import *class_exp2cliimp(struct obd_export *exp) {struct obd_device *obd = exp->exp_obd; -if (obd ==NULL ) +if (!obd)return NULL ;return obd->u.cli.cl_import; }
@@ -750,7 +750,7 @@ struct obd_import *class_conn2cliimp(struct lustre_handle *conn) {struct obd_device *obd =class_conn2obd (conn); -if (obd ==NULL ) +if (!obd)return NULL ;return obd->u.cli.cl_import; }
@@ -875,7 +875,7 @@ struct obd_export *class_new_export(struct obd_device *obd, } hash =cfs_hash_getref (obd->obd_uuid_hash); -if (hash ==NULL ) { +if (!hash) { rc = -ENODEV ; goto exit_unlock; }
@@ -959,7 +959,7 @@ static void class_import_destroy(struct obd_import *imp)kfree (imp_conn); } -LASSERT (imp->imp_sec ==NULL ); +LASSERT (!imp->imp_sec);class_decref (imp->imp_obd,"import" , imp);OBD_FREE_RCU (imp,sizeof (*imp), &imp->imp_handle); }
@@ -1194,7 +1194,7 @@ int class_disconnect(struct obd_export *export) {int already_disconnected; -if (export ==NULL ) { +if (!export) {CWARN ("attempting to free NULL export %p\n" , export);return -EINVAL ; }
@@ -1343,7 +1343,7 @@ void class_disconnect_stale_exports(struct obd_device *obd, evicted++;CDEBUG (D_HA ,"%s: disconnect stale client %s@%s\n" , obd->obd_name, exp->exp_client_uuid.uuid, - exp->exp_connection ==NULL ?"<unknown>" : + !exp->exp_connection ?"<unknown>" :libcfs_nid2str (exp->exp_connection->c_peer.nid));print_export_data (exp,"EVICTING" ,0 ); }
@@ -1426,7 +1426,7 @@ int obd_export_evict_by_nid(struct obd_device *obd, const char *nid) do { doomed_exp = cfs_hash_lookup(nid_hash, &nid_key); - if (doomed_exp == NULL) + if (!doomed_exp) break; LASSERTF(doomed_exp->exp_connection->c_peer.nid == nid_key,
@@ -1479,7 +1479,7 @@ int obd_export_evict_by_uuid(struct obd_device *obd, const char *uuid) doomed_exp =cfs_hash_lookup (uuid_hash, &doomed_uuid); -if (doomed_exp ==NULL ) { +if (!doomed_exp) {CERROR ("%s: can't disconnect %s: no exports found\n" , obd->obd_name, uuid); }else {
@@ -1670,8 +1670,8 @@ static void obd_zombie_export_add(struct obd_export *exp)*/ static void obd_zombie_import_add (struct obd_import *imp) { -LASSERT (imp->imp_sec ==NULL ); -LASSERT (imp->imp_rq_pool ==NULL ); +LASSERT (!imp->imp_sec); +LASSERT (!imp->imp_rq_pool);spin_lock (&obd_zombie_impexp_lock);LASSERT (list_empty (&imp->imp_zombie_chain)); zombies_count++;
Signature · 1 line
2.1.4