Commit 7ae59eda authored by Oleg Drokin's avatar Oleg Drokin Committed by Greg Kroah-Hartman

staging/lustre/obdecho: 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: default avatarOleg Drokin <green@linuxhacker.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent cce3c2da
...@@ -146,7 +146,7 @@ static inline struct echo_thread_info *echo_env_info(const struct lu_env *env) ...@@ -146,7 +146,7 @@ static inline struct echo_thread_info *echo_env_info(const struct lu_env *env)
struct echo_thread_info *info; struct echo_thread_info *info;
info = lu_context_key_get(&env->le_ctx, &echo_thread_key); info = lu_context_key_get(&env->le_ctx, &echo_thread_key);
LASSERT(info != NULL); LASSERT(info);
return info; return info;
} }
...@@ -267,7 +267,7 @@ static void echo_page_completion(const struct lu_env *env, ...@@ -267,7 +267,7 @@ static void echo_page_completion(const struct lu_env *env,
const struct cl_page_slice *slice, const struct cl_page_slice *slice,
int ioret) int ioret)
{ {
LASSERT(slice->cpl_page->cp_sync_io != NULL); LASSERT(slice->cpl_page->cp_sync_io);
} }
static void echo_page_fini(const struct lu_env *env, static void echo_page_fini(const struct lu_env *env,
...@@ -393,13 +393,13 @@ static int echo_lock_init(const struct lu_env *env, ...@@ -393,13 +393,13 @@ static int echo_lock_init(const struct lu_env *env,
struct echo_lock *el; struct echo_lock *el;
el = kmem_cache_alloc(echo_lock_kmem, GFP_NOFS | __GFP_ZERO); el = kmem_cache_alloc(echo_lock_kmem, GFP_NOFS | __GFP_ZERO);
if (el != NULL) { if (el) {
cl_lock_slice_add(lock, &el->el_cl, obj, &echo_lock_ops); cl_lock_slice_add(lock, &el->el_cl, obj, &echo_lock_ops);
el->el_object = cl2echo_obj(obj); el->el_object = cl2echo_obj(obj);
INIT_LIST_HEAD(&el->el_chain); INIT_LIST_HEAD(&el->el_chain);
atomic_set(&el->el_refcount, 0); atomic_set(&el->el_refcount, 0);
} }
return el == NULL ? -ENOMEM : 0; return !el ? -ENOMEM : 0;
} }
static int echo_conf_set(const struct lu_env *env, struct cl_object *obj, static int echo_conf_set(const struct lu_env *env, struct cl_object *obj,
...@@ -439,7 +439,7 @@ static int echo_object_init(const struct lu_env *env, struct lu_object *obj, ...@@ -439,7 +439,7 @@ static int echo_object_init(const struct lu_env *env, struct lu_object *obj,
under = ed->ed_next; under = ed->ed_next;
below = under->ld_ops->ldo_object_alloc(env, obj->lo_header, below = under->ld_ops->ldo_object_alloc(env, obj->lo_header,
under); under);
if (below == NULL) if (!below)
return -ENOMEM; return -ENOMEM;
lu_object_add(obj, below); lu_object_add(obj, below);
} }
...@@ -470,12 +470,12 @@ static int echo_alloc_memmd(struct echo_device *ed, ...@@ -470,12 +470,12 @@ static int echo_alloc_memmd(struct echo_device *ed,
int lsm_size; int lsm_size;
/* If export is lov/osc then use their obd method */ /* If export is lov/osc then use their obd method */
if (ed->ed_next != NULL) if (ed->ed_next)
return obd_alloc_memmd(ed->ed_ec->ec_exp, lsmp); return obd_alloc_memmd(ed->ed_ec->ec_exp, lsmp);
/* OFD has no unpackmd method, do everything here */ /* OFD has no unpackmd method, do everything here */
lsm_size = lov_stripe_md_size(1); lsm_size = lov_stripe_md_size(1);
LASSERT(*lsmp == NULL); LASSERT(!*lsmp);
*lsmp = kzalloc(lsm_size, GFP_NOFS); *lsmp = kzalloc(lsm_size, GFP_NOFS);
if (!*lsmp) if (!*lsmp)
return -ENOMEM; return -ENOMEM;
...@@ -498,12 +498,11 @@ static int echo_free_memmd(struct echo_device *ed, struct lov_stripe_md **lsmp) ...@@ -498,12 +498,11 @@ static int echo_free_memmd(struct echo_device *ed, struct lov_stripe_md **lsmp)
int lsm_size; int lsm_size;
/* If export is lov/osc then use their obd method */ /* If export is lov/osc then use their obd method */
if (ed->ed_next != NULL) if (ed->ed_next)
return obd_free_memmd(ed->ed_ec->ec_exp, lsmp); return obd_free_memmd(ed->ed_ec->ec_exp, lsmp);
/* OFD has no unpackmd method, do everything here */ /* OFD has no unpackmd method, do everything here */
lsm_size = lov_stripe_md_size(1); lsm_size = lov_stripe_md_size(1);
LASSERT(*lsmp != NULL);
kfree((*lsmp)->lsm_oinfo[0]); kfree((*lsmp)->lsm_oinfo[0]);
kfree(*lsmp); kfree(*lsmp);
*lsmp = NULL; *lsmp = NULL;
...@@ -562,9 +561,9 @@ static struct lu_object *echo_object_alloc(const struct lu_env *env, ...@@ -562,9 +561,9 @@ static struct lu_object *echo_object_alloc(const struct lu_env *env,
struct lu_object *obj = NULL; struct lu_object *obj = NULL;
/* we're the top dev. */ /* we're the top dev. */
LASSERT(hdr == NULL); LASSERT(!hdr);
eco = kmem_cache_alloc(echo_object_kmem, GFP_NOFS | __GFP_ZERO); eco = kmem_cache_alloc(echo_object_kmem, GFP_NOFS | __GFP_ZERO);
if (eco != NULL) { if (eco) {
struct cl_object_header *hdr = &eco->eo_hdr; struct cl_object_header *hdr = &eco->eo_hdr;
obj = &echo_obj2cl(eco)->co_lu; obj = &echo_obj2cl(eco)->co_lu;
...@@ -627,7 +626,7 @@ static void *echo_thread_key_init(const struct lu_context *ctx, ...@@ -627,7 +626,7 @@ static void *echo_thread_key_init(const struct lu_context *ctx,
struct echo_thread_info *info; struct echo_thread_info *info;
info = kmem_cache_alloc(echo_thread_kmem, GFP_NOFS | __GFP_ZERO); info = kmem_cache_alloc(echo_thread_kmem, GFP_NOFS | __GFP_ZERO);
if (info == NULL) if (!info)
info = ERR_PTR(-ENOMEM); info = ERR_PTR(-ENOMEM);
return info; return info;
} }
...@@ -658,7 +657,7 @@ static void *echo_session_key_init(const struct lu_context *ctx, ...@@ -658,7 +657,7 @@ static void *echo_session_key_init(const struct lu_context *ctx,
struct echo_session_info *session; struct echo_session_info *session;
session = kmem_cache_alloc(echo_session_kmem, GFP_NOFS | __GFP_ZERO); session = kmem_cache_alloc(echo_session_kmem, GFP_NOFS | __GFP_ZERO);
if (session == NULL) if (!session)
session = ERR_PTR(-ENOMEM); session = ERR_PTR(-ENOMEM);
return session; return session;
} }
...@@ -715,11 +714,11 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env, ...@@ -715,11 +714,11 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env,
cleanup = 2; cleanup = 2;
obd = class_name2obd(lustre_cfg_string(cfg, 0)); obd = class_name2obd(lustre_cfg_string(cfg, 0));
LASSERT(obd != NULL); LASSERT(obd);
LASSERT(env != NULL); LASSERT(env);
tgt = class_name2obd(lustre_cfg_string(cfg, 1)); tgt = class_name2obd(lustre_cfg_string(cfg, 1));
if (tgt == NULL) { if (!tgt) {
CERROR("Can not find tgt device %s\n", CERROR("Can not find tgt device %s\n",
lustre_cfg_string(cfg, 1)); lustre_cfg_string(cfg, 1));
rc = -ENODEV; rc = -ENODEV;
...@@ -748,13 +747,12 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env, ...@@ -748,13 +747,12 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env,
/* if echo client is to be stacked upon ost device, the next is /* if echo client is to be stacked upon ost device, the next is
* NULL since ost is not a clio device so far */ * NULL since ost is not a clio device so far */
if (next != NULL && !lu_device_is_cl(next)) if (next && !lu_device_is_cl(next))
next = NULL; next = NULL;
tgt_type_name = tgt->obd_type->typ_name; tgt_type_name = tgt->obd_type->typ_name;
if (next != NULL) { if (next) {
LASSERT(next != NULL); if (next->ld_site) {
if (next->ld_site != NULL) {
rc = -EBUSY; rc = -EBUSY;
goto out; goto out;
} }
...@@ -1063,7 +1061,6 @@ static int cl_echo_cancel0(struct lu_env *env, struct echo_device *ed, ...@@ -1063,7 +1061,6 @@ static int cl_echo_cancel0(struct lu_env *env, struct echo_device *ed,
struct list_head *el; struct list_head *el;
int found = 0, still_used = 0; int found = 0, still_used = 0;
LASSERT(ec != NULL);
spin_lock(&ec->ec_lock); spin_lock(&ec->ec_lock);
list_for_each(el, &ec->ec_locks) { list_for_each(el, &ec->ec_locks) {
ecl = list_entry(el, struct echo_lock, el_chain); ecl = list_entry(el, struct echo_lock, el_chain);
...@@ -1121,7 +1118,7 @@ static int cl_echo_object_brw(struct echo_object *eco, int rw, u64 offset, ...@@ -1121,7 +1118,7 @@ static int cl_echo_object_brw(struct echo_object *eco, int rw, u64 offset,
int i; int i;
LASSERT((offset & ~CFS_PAGE_MASK) == 0); LASSERT((offset & ~CFS_PAGE_MASK) == 0);
LASSERT(ed->ed_next != NULL); LASSERT(ed->ed_next);
env = cl_env_get(&refcheck); env = cl_env_get(&refcheck);
if (IS_ERR(env)) if (IS_ERR(env))
return PTR_ERR(env); return PTR_ERR(env);
...@@ -1393,11 +1390,11 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, ...@@ -1393,11 +1390,11 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa,
brw_flags = OBD_BRW_ASYNC; brw_flags = OBD_BRW_ASYNC;
pga = kcalloc(npages, sizeof(*pga), GFP_NOFS); pga = kcalloc(npages, sizeof(*pga), GFP_NOFS);
if (pga == NULL) if (!pga)
return -ENOMEM; return -ENOMEM;
pages = kcalloc(npages, sizeof(*pages), GFP_NOFS); pages = kcalloc(npages, sizeof(*pages), GFP_NOFS);
if (pages == NULL) { if (!pages) {
kfree(pga); kfree(pga);
return -ENOMEM; return -ENOMEM;
} }
...@@ -1406,11 +1403,11 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, ...@@ -1406,11 +1403,11 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa,
i < npages; i < npages;
i++, pgp++, off += PAGE_CACHE_SIZE) { i++, pgp++, off += PAGE_CACHE_SIZE) {
LASSERT(pgp->pg == NULL); /* for cleanup */ LASSERT(!pgp->pg); /* for cleanup */
rc = -ENOMEM; rc = -ENOMEM;
pgp->pg = alloc_page(gfp_mask); pgp->pg = alloc_page(gfp_mask);
if (pgp->pg == NULL) if (!pgp->pg)
goto out; goto out;
pages[i] = pgp->pg; pages[i] = pgp->pg;
...@@ -1425,7 +1422,7 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, ...@@ -1425,7 +1422,7 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa,
} }
/* brw mode can only be used at client */ /* brw mode can only be used at client */
LASSERT(ed->ed_next != NULL); LASSERT(ed->ed_next);
rc = cl_echo_object_brw(eco, rw, offset, pages, npages, async); rc = cl_echo_object_brw(eco, rw, offset, pages, npages, async);
out: out:
...@@ -1433,7 +1430,7 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, ...@@ -1433,7 +1430,7 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa,
verify = 0; verify = 0;
for (i = 0, pgp = pga; i < npages; i++, pgp++) { for (i = 0, pgp = pga; i < npages; i++, pgp++) {
if (pgp->pg == NULL) if (!pgp->pg)
continue; continue;
if (verify) { if (verify) {
...@@ -1475,7 +1472,7 @@ static int echo_client_prep_commit(const struct lu_env *env, ...@@ -1475,7 +1472,7 @@ static int echo_client_prep_commit(const struct lu_env *env,
lnb = kcalloc(npages, sizeof(struct niobuf_local), GFP_NOFS); lnb = kcalloc(npages, sizeof(struct niobuf_local), GFP_NOFS);
rnb = kcalloc(npages, sizeof(struct niobuf_remote), GFP_NOFS); rnb = kcalloc(npages, sizeof(struct niobuf_remote), GFP_NOFS);
if (lnb == NULL || rnb == NULL) { if (!lnb || !rnb) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
} }
...@@ -1513,7 +1510,7 @@ static int echo_client_prep_commit(const struct lu_env *env, ...@@ -1513,7 +1510,7 @@ static int echo_client_prep_commit(const struct lu_env *env,
struct page *page = lnb[i].page; struct page *page = lnb[i].page;
/* read past eof? */ /* read past eof? */
if (page == NULL && lnb[i].rc == 0) if (!page && lnb[i].rc == 0)
continue; continue;
if (async) if (async)
...@@ -1582,7 +1579,7 @@ static int echo_client_brw_ioctl(const struct lu_env *env, int rw, ...@@ -1582,7 +1579,7 @@ static int echo_client_brw_ioctl(const struct lu_env *env, int rw,
if (test_mode == 1) if (test_mode == 1)
async = 0; async = 0;
if (ed->ed_next == NULL && test_mode != 3) { if (!ed->ed_next && test_mode != 3) {
test_mode = 3; test_mode = 3;
data->ioc_plen1 = data->ioc_count; data->ioc_plen1 = data->ioc_count;
} }
...@@ -1834,7 +1831,7 @@ static int echo_client_disconnect(struct obd_export *exp) ...@@ -1834,7 +1831,7 @@ static int echo_client_disconnect(struct obd_export *exp)
{ {
int rc; int rc;
if (exp == NULL) { if (!exp) {
rc = -EINVAL; rc = -EINVAL;
goto out; goto out;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment