continue;
token = fn(i);
- if (token == NULL) /* unused bit */
+ if (!token) /* unused bit */
continue;
if (len > 0) { /* separator? */
libcfs_console_min_delay = CDEBUG_DEFAULT_MIN_DELAY;
}
- if (libcfs_debug_file_path != NULL) {
+ if (libcfs_debug_file_path) {
strlcpy(libcfs_debug_file_path_arr,
libcfs_debug_file_path,
sizeof(libcfs_debug_file_path_arr));
dh = container_of(cfs_hash_dh_hhead(hs, bd),
struct cfs_hash_dhead, dh_head);
- if (dh->dh_tail != NULL) /* not empty */
+ if (dh->dh_tail) /* not empty */
hlist_add_behind(hnode, dh->dh_tail);
else /* empty list */
hlist_add_head(hnode, &dh->dh_head);
dh = container_of(cfs_hash_dh_hhead(hs, bd),
struct cfs_hash_dhead, dh_head);
- if (hnd->next == NULL) { /* it's the tail */
+ if (!hnd->next) { /* it's the tail */
dh->dh_tail = (hnd->pprev == &dh->dh_head.first) ? NULL :
container_of(hnd->pprev, struct hlist_node, next);
}
dh = container_of(cfs_hash_dd_hhead(hs, bd),
struct cfs_hash_dhead_dep, dd_head);
- if (dh->dd_tail != NULL) /* not empty */
+ if (dh->dd_tail) /* not empty */
hlist_add_behind(hnode, dh->dd_tail);
else /* empty list */
hlist_add_head(hnode, &dh->dd_head);
dh = container_of(cfs_hash_dd_hhead(hs, bd),
struct cfs_hash_dhead_dep, dd_head);
- if (hnd->next == NULL) { /* it's the tail */
+ if (!hnd->next) { /* it's the tail */
dh->dd_tail = (hnd->pprev == &dh->dd_head.first) ? NULL :
container_of(hnd->pprev, struct hlist_node, next);
}
cfs_hash_bd_get(struct cfs_hash *hs, const void *key, struct cfs_hash_bd *bd)
{
/* NB: caller should hold hs->hs_rwlock if REHASH is set */
- if (likely(hs->hs_rehash_buckets == NULL)) {
+ if (likely(!hs->hs_rehash_buckets)) {
cfs_hash_bd_from_key(hs, hs->hs_buckets,
hs->hs_cur_bits, key, bd);
} else {
if (!cfs_hash_keycmp(hs, key, ehnode))
continue;
- if (match != NULL && match != ehnode) /* can't match */
+ if (match && match != ehnode) /* can't match */
continue;
/* match and ... */
if (!intent_add)
return NULL;
- LASSERT(hnode != NULL);
+ LASSERT(hnode);
cfs_hash_bd_add_locked(hs, bd, hnode);
return hnode;
}
if (prev == bds[i].bd_bucket)
continue;
- LASSERT(prev == NULL ||
- prev->hsb_index < bds[i].bd_bucket->hsb_index);
+ LASSERT(!prev || prev->hsb_index < bds[i].bd_bucket->hsb_index);
cfs_hash_bd_lock(hs, &bds[i], excl);
prev = bds[i].bd_bucket;
}
cfs_hash_for_each_bd(bds, n, i) {
ehnode = cfs_hash_bd_lookup_intent(hs, &bds[i], key, NULL,
CFS_HS_LOOKUP_IT_FIND);
- if (ehnode != NULL)
+ if (ehnode)
return ehnode;
}
return NULL;
int intent;
unsigned i;
- LASSERT(hnode != NULL);
+ LASSERT(hnode);
intent = (!noref * CFS_HS_LOOKUP_MASK_REF) | CFS_HS_LOOKUP_IT_PEEK;
cfs_hash_for_each_bd(bds, n, i) {
ehnode = cfs_hash_bd_lookup_intent(hs, &bds[i], key,
NULL, intent);
- if (ehnode != NULL)
+ if (ehnode)
return ehnode;
}
cfs_hash_for_each_bd(bds, n, i) {
ehnode = cfs_hash_bd_lookup_intent(hs, &bds[i], key, hnode,
CFS_HS_LOOKUP_IT_FINDDEL);
- if (ehnode != NULL)
+ if (ehnode)
return ehnode;
}
return NULL;
{
int rc;
- if (bd2->bd_bucket == NULL)
+ if (!bd2->bd_bucket)
return;
- if (bd1->bd_bucket == NULL) {
+ if (!bd1->bd_bucket) {
*bd1 = *bd2;
bd2->bd_bucket = NULL;
return;
/* NB: caller should hold hs_lock.rw if REHASH is set */
cfs_hash_bd_from_key(hs, hs->hs_buckets,
hs->hs_cur_bits, key, &bds[0]);
- if (likely(hs->hs_rehash_buckets == NULL)) {
+ if (likely(!hs->hs_rehash_buckets)) {
/* no rehash or not rehashing */
bds[1].bd_bucket = NULL;
return;
int i;
for (i = prev_size; i < size; i++) {
- if (buckets[i] != NULL)
+ if (buckets[i])
LIBCFS_FREE(buckets[i], bkt_size);
}
struct cfs_hash_bucket **new_bkts;
int i;
- LASSERT(old_size == 0 || old_bkts != NULL);
+ LASSERT(old_size == 0 || old_bkts);
- if (old_bkts != NULL && old_size == new_size)
+ if (old_bkts && old_size == new_size)
return old_bkts;
LIBCFS_ALLOC(new_bkts, sizeof(new_bkts[0]) * new_size);
- if (new_bkts == NULL)
+ if (!new_bkts)
return NULL;
- if (old_bkts != NULL) {
+ if (old_bkts) {
memcpy(new_bkts, old_bkts,
min(old_size, new_size) * sizeof(*old_bkts));
}
struct cfs_hash_bd bd;
LIBCFS_ALLOC(new_bkts[i], cfs_hash_bkt_size(hs));
- if (new_bkts[i] == NULL) {
+ if (!new_bkts[i]) {
cfs_hash_buckets_free(new_bkts, cfs_hash_bkt_size(hs),
old_size, new_size);
return NULL;
CLASSERT(CFS_HASH_THETA_BITS < 15);
- LASSERT(name != NULL);
- LASSERT(ops != NULL);
+ LASSERT(name);
LASSERT(ops->hs_key);
LASSERT(ops->hs_hash);
LASSERT(ops->hs_object);
LASSERT(ops->hs_keycmp);
- LASSERT(ops->hs_get != NULL);
- LASSERT(ops->hs_put_locked != NULL);
+ LASSERT(ops->hs_get);
+ LASSERT(ops->hs_put_locked);
if ((flags & CFS_HASH_REHASH) != 0)
flags |= CFS_HASH_COUNTER; /* must have counter */
LASSERT(ergo((flags & CFS_HASH_REHASH) == 0, cur_bits == max_bits));
LASSERT(ergo((flags & CFS_HASH_REHASH) != 0,
(flags & CFS_HASH_NO_LOCK) == 0));
- LASSERT(ergo((flags & CFS_HASH_REHASH_KEY) != 0,
- ops->hs_keycpy != NULL));
+ LASSERT(ergo((flags & CFS_HASH_REHASH_KEY) != 0, ops->hs_keycpy));
len = (flags & CFS_HASH_BIGNAME) == 0 ?
CFS_HASH_NAME_LEN : CFS_HASH_BIGNAME_LEN;
LIBCFS_ALLOC(hs, offsetof(struct cfs_hash, hs_name[len]));
- if (hs == NULL)
+ if (!hs)
return NULL;
strlcpy(hs->hs_name, name, len);
hs->hs_buckets = cfs_hash_buckets_realloc(hs, NULL, 0,
CFS_HASH_NBKT(hs));
- if (hs->hs_buckets != NULL)
+ if (hs->hs_buckets)
return hs;
LIBCFS_FREE(hs, offsetof(struct cfs_hash, hs_name[len]));
struct cfs_hash_bd bd;
int i;
- LASSERT(hs != NULL);
+ LASSERT(hs);
LASSERT(!cfs_hash_is_exiting(hs) &&
!cfs_hash_is_iterating(hs));
cfs_hash_depth_wi_cancel(hs);
/* rehash should be done/canceled */
- LASSERT(hs->hs_buckets != NULL &&
- hs->hs_rehash_buckets == NULL);
+ LASSERT(hs->hs_buckets && !hs->hs_rehash_buckets);
cfs_hash_for_each_bucket(hs, &bd, i) {
struct hlist_head *hhead;
- LASSERT(bd.bd_bucket != NULL);
+ LASSERT(bd.bd_bucket);
/* no need to take this lock, just for consistent code */
cfs_hash_bd_lock(hs, &bd, 1);
cfs_hash_dual_bd_get_and_lock(hs, key, bds, 1);
/* NB: do nothing if @hnode is not in hash table */
- if (hnode == NULL || !hlist_unhashed(hnode)) {
- if (bds[1].bd_bucket == NULL && hnode != NULL) {
+ if (!hnode || !hlist_unhashed(hnode)) {
+ if (!bds[1].bd_bucket && hnode) {
cfs_hash_bd_del_locked(hs, &bds[0], hnode);
} else {
hnode = cfs_hash_dual_bd_finddel_locked(hs, bds,
}
}
- if (hnode != NULL) {
+ if (hnode) {
obj = cfs_hash_object(hs, hnode);
bits = cfs_hash_rehash_bits(hs);
}
cfs_hash_dual_bd_get_and_lock(hs, key, bds, 0);
hnode = cfs_hash_dual_bd_lookup_locked(hs, bds, key);
- if (hnode != NULL)
+ if (hnode)
obj = cfs_hash_object(hs, hnode);
cfs_hash_dual_bd_unlock(hs, bds, 0);
struct hlist_head *hhead;
cfs_hash_bd_lock(hs, &bd, excl);
- if (func == NULL) { /* only glimpse size */
+ if (!func) { /* only glimpse size */
count += bd.bd_bucket->hsb_count;
cfs_hash_bd_unlock(hs, &bd, excl);
continue;
stop_on_change = cfs_hash_with_rehash_key(hs) ||
!cfs_hash_with_no_itemref(hs) ||
- hs->hs_ops->hs_put_locked == NULL;
+ !hs->hs_ops->hs_put_locked;
cfs_hash_lock(hs, 0);
LASSERT(!cfs_hash_is_rehashing(hs));
version = cfs_hash_bd_version_get(&bd);
cfs_hash_bd_for_each_hlist(hs, &bd, hhead) {
- for (hnode = hhead->first; hnode != NULL;) {
+ for (hnode = hhead->first; hnode;) {
cfs_hash_bucket_validate(hs, &bd, hnode);
cfs_hash_get(hs, hnode);
cfs_hash_bd_unlock(hs, &bd, 0);
!cfs_hash_with_no_itemref(hs))
return -EOPNOTSUPP;
- if (hs->hs_ops->hs_get == NULL ||
- (hs->hs_ops->hs_put == NULL &&
- hs->hs_ops->hs_put_locked == NULL))
+ if (!hs->hs_ops->hs_get ||
+ (!hs->hs_ops->hs_put && !hs->hs_ops->hs_put_locked))
return -EOPNOTSUPP;
cfs_hash_for_each_enter(hs);
if (cfs_hash_with_no_lock(hs))
return -EOPNOTSUPP;
- if (hs->hs_ops->hs_get == NULL ||
- (hs->hs_ops->hs_put == NULL &&
- hs->hs_ops->hs_put_locked == NULL))
+ if (!hs->hs_ops->hs_get ||
+ (!hs->hs_ops->hs_put && !hs->hs_ops->hs_put_locked))
return -EOPNOTSUPP;
cfs_hash_for_each_enter(hs);
cfs_hash_bd_for_each_hlist(hs, old, hhead) {
hlist_for_each_safe(hnode, pos, hhead) {
key = cfs_hash_key(hs, hnode);
- LASSERT(key != NULL);
+ LASSERT(key);
/* Validate hnode is in the correct bucket. */
cfs_hash_bucket_validate(hs, old, hnode);
/*
int rc = 0;
int i;
- LASSERT(hs != NULL && cfs_hash_with_rehash(hs));
+ LASSERT(hs && cfs_hash_with_rehash(hs));
cfs_hash_lock(hs, 0);
LASSERT(cfs_hash_is_rehashing(hs));
bkts = cfs_hash_buckets_realloc(hs, hs->hs_buckets,
old_size, new_size);
cfs_hash_lock(hs, 1);
- if (bkts == NULL) {
+ if (!bkts) {
rc = -ENOMEM;
goto out;
}
goto out;
}
- LASSERT(hs->hs_rehash_buckets == NULL);
+ LASSERT(!hs->hs_rehash_buckets);
hs->hs_rehash_buckets = bkts;
rc = 0;
bsize = cfs_hash_bkt_size(hs);
cfs_hash_unlock(hs, 1);
/* can't refer to @hs anymore because it could be destroyed */
- if (bkts != NULL)
+ if (bkts)
cfs_hash_buckets_free(bkts, bsize, new_size, old_size);
if (rc != 0)
CDEBUG(D_INFO, "early quit of rehashing: %d\n", rc);
cfs_hash_bd_order(&bds[0], &bds[1]);
cfs_hash_multi_bd_lock(hs, bds, 3, 1);
- if (likely(old_bds[1].bd_bucket == NULL)) {
+ if (likely(!old_bds[1].bd_bucket)) {
cfs_hash_bd_move_locked(hs, &old_bds[0], &new_bd, hnode);
} else {
cfs_hash_dual_bd_finddel_locked(hs, old_bds, old_key, hnode);
cfs_hash_full_bkts(struct cfs_hash *hs)
{
/* NB: caller should hold hs->hs_rwlock if REHASH is set */
- if (hs->hs_rehash_buckets == NULL)
+ if (!hs->hs_rehash_buckets)
return hs->hs_buckets;
LASSERT(hs->hs_rehash_bits != 0);
cfs_hash_full_nbkt(struct cfs_hash *hs)
{
/* NB: caller should hold hs->hs_rwlock if REHASH is set */
- if (hs->hs_rehash_buckets == NULL)
+ if (!hs->hs_rehash_buckets)
return CFS_HASH_NBKT(hs);
LASSERT(hs->hs_rehash_bits != 0);
}
LIBCFS_ALLOC(cptab, sizeof(*cptab));
- if (cptab != NULL) {
+ if (cptab) {
cptab->ctb_version = CFS_CPU_VERSION_MAGIC;
node_set(0, cptab->ctb_nodemask);
cptab->ctb_nparts = ncpt;
void
cfs_cpu_fini(void)
{
- if (cfs_cpt_table != NULL) {
+ if (cfs_cpt_table) {
cfs_cpt_table_free(cfs_cpt_table);
cfs_cpt_table = NULL;
}
{
cfs_cpt_table = cfs_cpt_table_alloc(1);
- return cfs_cpt_table != NULL ? 0 : -1;
+ return cfs_cpt_table ? 0 : -1;
}
#endif /* HAVE_LIBCFS_CPT */
void
cfs_percpt_lock_free(struct cfs_percpt_lock *pcl)
{
- LASSERT(pcl->pcl_locks != NULL);
+ LASSERT(pcl->pcl_locks);
LASSERT(!pcl->pcl_locked);
cfs_percpt_free(pcl->pcl_locks);
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])
LIBCFS_FREE(arr->va_ptrs[i], arr->va_size);
}
found = 0;
for (i = 0; i < 32; i++) {
debugstr = bit2str(i);
- if (debugstr != NULL &&
- strlen(debugstr) == len &&
+ if (debugstr && strlen(debugstr) == len &&
strncasecmp(str, debugstr, len) == 0) {
if (op == '-')
newmask &= ~(1 << i);
{
char *end;
- if (next->ls_str == NULL)
+ if (!next->ls_str)
return 0;
/* skip leading white spaces */
res->ls_str = next->ls_str;
end = memchr(next->ls_str, delim, next->ls_len);
- if (end == NULL) {
+ if (!end) {
/* there is no the delimeter in the string */
end = next->ls_str + next->ls_len;
next->ls_str = NULL;
struct cfs_lstr tok;
LIBCFS_ALLOC(re, sizeof(*re));
- if (re == NULL)
+ if (!re)
return -ENOMEM;
if (src->ls_len == 1 && src->ls_str[0] == '*') {
}
LIBCFS_ALLOC(val, sizeof(val[0]) * count);
- if (val == NULL)
+ if (!val)
return -ENOMEM;
count = 0;
int rc;
LIBCFS_ALLOC(expr_list, sizeof(*expr_list));
- if (expr_list == NULL)
+ if (!expr_list)
return -ENOMEM;
src.ls_str = str;
src.ls_len -= 2;
rc = -EINVAL;
- while (src.ls_str != NULL) {
+ while (src.ls_str) {
struct cfs_lstr tok;
if (!cfs_gettok(&src, ',', &tok)) {
{
int i;
- if (cptab->ctb_cpu2cpt != NULL) {
+ if (cptab->ctb_cpu2cpt) {
LIBCFS_FREE(cptab->ctb_cpu2cpt,
num_possible_cpus() *
sizeof(cptab->ctb_cpu2cpt[0]));
}
- for (i = 0; cptab->ctb_parts != NULL && i < cptab->ctb_nparts; i++) {
+ for (i = 0; cptab->ctb_parts && i < cptab->ctb_nparts; i++) {
struct cfs_cpu_partition *part = &cptab->ctb_parts[i];
- if (part->cpt_nodemask != NULL) {
+ if (part->cpt_nodemask) {
LIBCFS_FREE(part->cpt_nodemask,
sizeof(*part->cpt_nodemask));
}
- if (part->cpt_cpumask != NULL)
+ if (part->cpt_cpumask)
LIBCFS_FREE(part->cpt_cpumask, cpumask_size());
}
- if (cptab->ctb_parts != NULL) {
+ if (cptab->ctb_parts) {
LIBCFS_FREE(cptab->ctb_parts,
cptab->ctb_nparts * sizeof(cptab->ctb_parts[0]));
}
- if (cptab->ctb_nodemask != NULL)
+ if (cptab->ctb_nodemask)
LIBCFS_FREE(cptab->ctb_nodemask, sizeof(*cptab->ctb_nodemask));
- if (cptab->ctb_cpumask != NULL)
+ if (cptab->ctb_cpumask)
LIBCFS_FREE(cptab->ctb_cpumask, cpumask_size());
LIBCFS_FREE(cptab, sizeof(*cptab));
int i;
LIBCFS_ALLOC(cptab, sizeof(*cptab));
- if (cptab == NULL)
+ if (!cptab)
return NULL;
cptab->ctb_nparts = ncpt;
LIBCFS_ALLOC(cptab->ctb_cpumask, cpumask_size());
LIBCFS_ALLOC(cptab->ctb_nodemask, sizeof(*cptab->ctb_nodemask));
- if (cptab->ctb_cpumask == NULL || cptab->ctb_nodemask == NULL)
+ if (!cptab->ctb_cpumask || !cptab->ctb_nodemask)
goto failed;
LIBCFS_ALLOC(cptab->ctb_cpu2cpt,
num_possible_cpus() * sizeof(cptab->ctb_cpu2cpt[0]));
- if (cptab->ctb_cpu2cpt == NULL)
+ if (!cptab->ctb_cpu2cpt)
goto failed;
memset(cptab->ctb_cpu2cpt, -1,
num_possible_cpus() * sizeof(cptab->ctb_cpu2cpt[0]));
LIBCFS_ALLOC(cptab->ctb_parts, ncpt * sizeof(cptab->ctb_parts[0]));
- if (cptab->ctb_parts == NULL)
+ if (!cptab->ctb_parts)
goto failed;
for (i = 0; i < ncpt; i++) {
LIBCFS_ALLOC(part->cpt_cpumask, cpumask_size());
LIBCFS_ALLOC(part->cpt_nodemask, sizeof(*part->cpt_nodemask));
- if (part->cpt_cpumask == NULL || part->cpt_nodemask == NULL)
+ if (!part->cpt_cpumask || !part->cpt_nodemask)
goto failed;
}
/* allocate scratch buffer */
LIBCFS_ALLOC(socket, cpumask_size());
LIBCFS_ALLOC(core, cpumask_size());
- if (socket == NULL || core == NULL) {
+ if (!socket || !core) {
rc = -ENOMEM;
goto out;
}
}
out:
- if (socket != NULL)
+ if (socket)
LIBCFS_FREE(socket, cpumask_size());
- if (core != NULL)
+ if (core)
LIBCFS_FREE(core, cpumask_size());
return rc;
}
}
cptab = cfs_cpt_table_alloc(ncpt);
- if (cptab == NULL) {
+ if (!cptab) {
CERROR("Failed to allocate CPU map(%d)\n", ncpt);
goto failed;
}
}
LIBCFS_ALLOC(mask, cpumask_size());
- if (mask == NULL) {
+ if (!mask) {
CERROR("Failed to allocate scratch cpumask\n");
goto failed;
}
CERROR("Failed to setup CPU-partition-table with %d CPU-partitions, online HW nodes: %d, HW cpus: %d.\n",
ncpt, num_online_nodes(), num_online_cpus());
- if (mask != NULL)
+ if (mask)
LIBCFS_FREE(mask, cpumask_size());
- if (cptab != NULL)
+ if (cptab)
cfs_cpt_table_free(cptab);
return NULL;
for (ncpt = 0;; ncpt++) { /* quick scan bracket */
str = strchr(str, '[');
- if (str == NULL)
+ if (!str)
break;
str++;
}
high = node ? MAX_NUMNODES - 1 : nr_cpu_ids - 1;
cptab = cfs_cpt_table_alloc(ncpt);
- if (cptab == NULL) {
+ if (!cptab) {
CERROR("Failed to allocate cpu partition table\n");
return NULL;
}
int i;
int n;
- if (bracket == NULL) {
+ if (!bracket) {
if (*str != 0) {
CERROR("Invalid pattern %s\n", str);
goto failed;
}
bracket = strchr(str, ']');
- if (bracket == NULL) {
+ if (!bracket) {
CERROR("missing right bracket for cpt %d, %s\n",
cpt, str);
goto failed;
void
cfs_cpu_fini(void)
{
- if (cfs_cpt_table != NULL)
+ if (cfs_cpt_table)
cfs_cpt_table_free(cfs_cpt_table);
#ifdef CONFIG_HOTPLUG_CPU
unregister_hotcpu_notifier(&cfs_cpu_notifier);
#endif
- if (cpt_data.cpt_cpumask != NULL)
+ if (cpt_data.cpt_cpumask)
LIBCFS_FREE(cpt_data.cpt_cpumask, cpumask_size());
}
int
cfs_cpu_init(void)
{
- LASSERT(cfs_cpt_table == NULL);
+ LASSERT(!cfs_cpt_table);
memset(&cpt_data, 0, sizeof(cpt_data));
LIBCFS_ALLOC(cpt_data.cpt_cpumask, cpumask_size());
- if (cpt_data.cpt_cpumask == NULL) {
+ if (!cpt_data.cpt_cpumask) {
CERROR("Failed to allocate scratch buffer\n");
return -1;
}
if (*cpu_pattern != 0) {
cfs_cpt_table = cfs_cpt_table_create_pattern(cpu_pattern);
- if (cfs_cpt_table == NULL) {
+ if (!cfs_cpt_table) {
CERROR("Failed to create cptab from pattern %s\n",
cpu_pattern);
goto failed;
} else {
cfs_cpt_table = cfs_cpt_table_create(cpu_npartitions);
- if (cfs_cpt_table == NULL) {
+ if (!cfs_cpt_table) {
CERROR("Failed to create ptable with npartitions %d\n",
cpu_npartitions);
goto failed;
*type = cfs_crypto_hash_type(alg_id);
- if (*type == NULL) {
+ if (!*type) {
CWARN("Unsupported hash algorithm id = %d, max id is %d\n",
alg_id, CFS_HASH_ALG_MAX);
return -EINVAL;
}
desc->tfm = crypto_alloc_hash((*type)->cht_name, 0, 0);
- if (desc->tfm == NULL)
+ if (!desc->tfm)
return -EINVAL;
if (IS_ERR(desc->tfm)) {
* Skip this function for digest, because we use shash logic at
* cfs_crypto_hash_alloc.
*/
- if (key != NULL)
+ if (key)
err = crypto_hash_setkey(desc->tfm, key, key_len);
else if ((*type)->cht_key != 0)
err = crypto_hash_setkey(desc->tfm,
int err;
const struct cfs_crypto_hash_type *type;
- if (buf == NULL || buf_len == 0 || hash_len == NULL)
+ if (!buf || buf_len == 0 || !hash_len)
return -EINVAL;
err = cfs_crypto_hash_alloc(alg_id, &type, &hdesc, key, key_len);
if (err != 0)
return err;
- if (hash == NULL || *hash_len < type->cht_size) {
+ if (!hash || *hash_len < type->cht_size) {
*hash_len = type->cht_size;
crypto_free_hash(hdesc.tfm);
return -ENOSPC;
const struct cfs_crypto_hash_type *type;
hdesc = kmalloc(sizeof(*hdesc), 0);
- if (hdesc == NULL)
+ if (!hdesc)
return ERR_PTR(-ENOMEM);
err = cfs_crypto_hash_alloc(alg_id, &type, hdesc, key, key_len);
int err;
int size = crypto_hash_digestsize(((struct hash_desc *)hdesc)->tfm);
- if (hash_len == NULL) {
+ if (!hash_len) {
crypto_free_hash(((struct hash_desc *)hdesc)->tfm);
kfree(hdesc);
return 0;
}
- if (hash == NULL || *hash_len < size) {
+ if (!hash || *hash_len < size) {
*hash_len = size;
return -ENOSPC;
}
unsigned int data_len = 1 * 128 * 1024;
data = kmalloc(data_len, 0);
- if (data == NULL) {
+ if (!data) {
CERROR("Failed to allocate mem\n");
return -ENOMEM;
}
argv[0] = lnet_debug_log_upcall;
- LASSERTF(file != NULL, "called on a null filename\n");
+ LASSERTF(file, "called on a null filename\n");
argv[1] = file; /* only need to pass the path of the file */
argv[2] = NULL;
argv[0] = lnet_upcall;
argc = 1;
- while (argv[argc] != NULL)
+ while (argv[argc])
argc++;
LASSERT(argc >= 2);
if (!inode)
return -EINVAL;
- if (libcfs_psdev_ops.p_open != NULL)
+ if (libcfs_psdev_ops.p_open)
rc = libcfs_psdev_ops.p_open(0, NULL);
else
return -EPERM;
if (!inode)
return -EINVAL;
- if (libcfs_psdev_ops.p_close != NULL)
+ if (libcfs_psdev_ops.p_close)
rc = libcfs_psdev_ops.p_close(0, NULL);
else
rc = -EPERM;
return 0;
}
- if (libcfs_psdev_ops.p_ioctl != NULL)
+ if (libcfs_psdev_ops.p_ioctl)
rc = libcfs_psdev_ops.p_ioctl(&pfile, cmd, (void __user *)arg);
else
rc = -EPERM;
cfs_trace_data[i] =
kmalloc(sizeof(union cfs_trace_data_union) *
num_possible_cpus(), GFP_KERNEL);
- if (cfs_trace_data[i] == NULL)
+ if (!cfs_trace_data[i])
goto out;
}
kmalloc(CFS_TRACE_CONSOLE_BUFFER_SIZE,
GFP_KERNEL);
- if (cfs_trace_console_buffers[i][j] == NULL)
+ if (!cfs_trace_console_buffers[i][j])
goto out;
}
cfs_trace_console_buffers[i][j] = NULL;
}
- for (i = 0; cfs_trace_data[i] != NULL; i++) {
+ for (i = 0; cfs_trace_data[i]; i++) {
kfree(cfs_trace_data[i]);
cfs_trace_data[i] = NULL;
}
* Handled in arch/cfs_module.c
*/
case IOC_LIBCFS_MARK_DEBUG:
- if (data->ioc_inlbuf1 == NULL ||
+ if (!data->ioc_inlbuf1 ||
data->ioc_inlbuf1[data->ioc_inllen1 - 1] != '\0')
return -EINVAL;
libcfs_debug_mark_buffer(data->ioc_inlbuf1);
int err = 0;
LIBCFS_ALLOC_GFP(buf, 1024, GFP_KERNEL);
- if (buf == NULL)
+ if (!buf)
return -ENOMEM;
/* 'cmd' and permissions get checked in our arch-specific caller */
if (write)
return -EPERM;
- LASSERT(cfs_cpt_table != NULL);
+ LASSERT(cfs_cpt_table);
while (1) {
LIBCFS_ALLOC(buf, len);
- if (buf == NULL)
+ if (!buf)
return -ENOMEM;
rc = cfs_cpt_table_print(cfs_cpt_table, buf, len);
rc = cfs_trace_copyout_string(buffer, nob, buf + pos, NULL);
out:
- if (buf != NULL)
+ if (buf)
LIBCFS_FREE(buf, len);
return rc;
}
void lustre_insert_debugfs(struct ctl_table *table,
const struct lnet_debugfs_symlink_def *symlinks)
{
- if (lnet_debugfs_root == NULL)
+ if (!lnet_debugfs_root)
lnet_debugfs_root = debugfs_create_dir("lnet", NULL);
/* Even if we cannot create, just ignore it altogether) */
static void lustre_remove_debugfs(void)
{
- if (lnet_debugfs_root != NULL)
- debugfs_remove_recursive(lnet_debugfs_root);
+ debugfs_remove_recursive(lnet_debugfs_root);
lnet_debugfs_root = NULL;
}
*/
gfp |= __GFP_NOWARN;
page = alloc_page(gfp);
- if (page == NULL)
+ if (!page)
return NULL;
tage = kmalloc(sizeof(*tage), gfp);
- if (tage == NULL) {
+ if (!tage) {
__free_page(page);
return NULL;
}
static void cfs_tage_free(struct cfs_trace_page *tage)
{
- __LASSERT(tage != NULL);
- __LASSERT(tage->page != NULL);
-
__free_page(tage->page);
kfree(tage);
atomic_dec(&cfs_tage_allocated);
static void cfs_tage_to_tail(struct cfs_trace_page *tage,
struct list_head *queue)
{
- __LASSERT(tage != NULL);
- __LASSERT(queue != NULL);
-
list_move_tail(&tage->linkage, queue);
}
struct cfs_trace_page *tage;
tage = cfs_tage_alloc(gfp);
- if (tage == NULL)
+ if (!tage)
break;
list_add_tail(&tage->linkage, stock);
}
list_del_init(&tage->linkage);
} else {
tage = cfs_tage_alloc(GFP_ATOMIC);
- if (unlikely(tage == NULL)) {
+ if (unlikely(!tage)) {
if ((!memory_pressure_get() ||
in_interrupt()) && printk_ratelimit())
printk(KERN_WARNING
}
tage = cfs_trace_get_tage_try(tcd, len);
- if (tage != NULL)
+ if (tage)
return tage;
if (thread_running)
cfs_tcd_shrink(tcd);
* warning on Linux when debugging is enabled. */
cfs_set_ptldebug_header(&header, msgdata, CDEBUG_STACK());
- if (tcd == NULL) /* arch may not log in IRQ context */
+ if (!tcd) /* arch may not log in IRQ context */
goto console;
if (tcd->tcd_cur_pages == 0)
*/
for (i = 0; i < 2; i++) {
tage = cfs_trace_get_tage(tcd, needed + known_size + 1);
- if (tage == NULL) {
+ if (!tage) {
if (needed + known_size > PAGE_CACHE_SIZE)
mask |= D_ERROR;
console:
if ((mask & libcfs_printk) == 0) {
/* no console output requested */
- if (tcd != NULL)
+ if (tcd)
cfs_trace_put_tcd(tcd);
return 1;
}
- if (cdls != NULL) {
+ if (cdls) {
if (libcfs_console_ratelimit &&
cdls->cdls_next != 0 && /* not first time ever */
!cfs_time_after(cfs_time_current(), cdls->cdls_next)) {
/* skipping a console message */
cdls->cdls_count++;
- if (tcd != NULL)
+ if (tcd)
cfs_trace_put_tcd(tcd);
return 1;
}
cdls->cdls_next = (cfs_time_current() + cdls->cdls_delay) | 1;
}
- if (tcd != NULL) {
+ if (tcd) {
cfs_print_to_console(&header, mask, string_buf, needed, file,
msgdata->msg_fn);
cfs_trace_put_tcd(tcd);
string_buf = cfs_trace_get_console_buffer();
needed = 0;
- if (format1 != NULL) {
+ if (format1) {
va_copy(ap, args);
needed = vsnprintf(string_buf,
CFS_TRACE_CONSOLE_BUFFER_SIZE,
format1, ap);
va_end(ap);
}
- if (format2 != NULL) {
+ if (format2) {
remain = CFS_TRACE_CONSOLE_BUFFER_SIZE - needed;
if (remain > 0) {
va_start(ap, format2);
put_cpu();
}
- if (cdls != NULL && cdls->cdls_count != 0) {
+ if (cdls && cdls->cdls_count != 0) {
string_buf = cfs_trace_get_console_buffer();
needed = snprintf(string_buf, CFS_TRACE_CONSOLE_BUFFER_SIZE,
if (copy_to_user(usr_buffer, knl_buffer, nob))
return -EFAULT;
- if (append != NULL && nob < usr_buffer_nob) {
+ if (append && nob < usr_buffer_nob) {
if (copy_to_user(usr_buffer + nob, append, 1))
return -EFAULT;
return -EINVAL;
*str = kmalloc(nob, GFP_KERNEL | __GFP_ZERO);
- if (*str == NULL)
+ if (!*str)
return -ENOMEM;
return 0;
}
}
cfs_tracefile_read_unlock();
- if (filp == NULL) {
+ if (!filp) {
put_pages_on_daemon_list(&pc);
__LASSERT(list_empty(&pc.pc_pages));
goto end_loop;
extern union cfs_trace_data_union (*cfs_trace_data[TCD_MAX_TYPES])[NR_CPUS];
#define cfs_tcd_for_each(tcd, i, j) \
- for (i = 0; cfs_trace_data[i] != NULL; i++) \
- for (j = 0, ((tcd) = &(*cfs_trace_data[i])[j].tcd); \
- j < num_possible_cpus(); \
- j++, (tcd) = &(*cfs_trace_data[i])[j].tcd)
+ for (i = 0; cfs_trace_data[i]; i++) \
+ for (j = 0, ((tcd) = &(*cfs_trace_data[i])[j].tcd); \
+ j < num_possible_cpus(); \
+ j++, (tcd) = &(*cfs_trace_data[i])[j].tcd)
#define cfs_tcd_for_each_type_lock(tcd, i, cpu) \
for (i = 0; cfs_trace_data[i] && \
#define __LASSERT_TAGE_INVARIANT(tage) \
do { \
- __LASSERT(tage != NULL); \
- __LASSERT(tage->page != NULL); \
+ __LASSERT(tage); \
+ __LASSERT(tage->page); \
__LASSERT(tage->used <= PAGE_CACHE_SIZE); \
__LASSERT(page_count(tage->page) > 0); \
} while (0)
cfs_block_allsigs();
/* CPT affinity scheduler? */
- if (sched->ws_cptab != NULL)
+ if (sched->ws_cptab)
if (cfs_cpt_bind(sched->ws_cptab, sched->ws_cpt) != 0)
CWARN("Failed to bind %s on CPT %d\n",
sched->ws_name, sched->ws_cpt);
LASSERT(cfs_wi_data.wi_init);
LASSERT(!cfs_wi_data.wi_stopping);
- LASSERT(cptab == NULL || cpt == CFS_CPT_ANY ||
+ LASSERT(!cptab || cpt == CFS_CPT_ANY ||
(cpt >= 0 && cpt < cfs_cpt_number(cptab)));
LIBCFS_ALLOC(sched, sizeof(*sched));
- if (sched == NULL)
+ if (!sched)
return -ENOMEM;
strlcpy(sched->ws_name, name, CFS_WS_NAME_LEN);
sched->ws_starting++;
spin_unlock(&cfs_wi_data.wi_glock);
- if (sched->ws_cptab != NULL && sched->ws_cpt >= 0) {
+ if (sched->ws_cptab && sched->ws_cpt >= 0) {
snprintf(name, sizeof(name), "%s_%02d_%02u",
sched->ws_name, sched->ws_cpt,
sched->ws_nthreads);