staging: lustre: obdclass: Use !x to check for kzalloc failure
!x is more normal for kzalloc failure in the kernel. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ expression x; statement S1, S2; @@ x = kzalloc(...); if ( - x == NULL + !x ) S1 else S2 // </smpl> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>hifive-unleashed-5.1
parent
c829be8176
commit
485640b536
|
@ -232,7 +232,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
|
|||
goto out;
|
||||
}
|
||||
lcfg = kzalloc(data->ioc_plen1, GFP_NOFS);
|
||||
if (lcfg == NULL) {
|
||||
if (!lcfg) {
|
||||
err = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
|
|
@ -172,7 +172,7 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
|
|||
|
||||
rc = -ENOMEM;
|
||||
type = kzalloc(sizeof(*type), GFP_NOFS);
|
||||
if (type == NULL)
|
||||
if (!type)
|
||||
return rc;
|
||||
|
||||
type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS);
|
||||
|
@ -1016,7 +1016,7 @@ struct obd_import *class_new_import(struct obd_device *obd)
|
|||
struct obd_import *imp;
|
||||
|
||||
imp = kzalloc(sizeof(*imp), GFP_NOFS);
|
||||
if (imp == NULL)
|
||||
if (!imp)
|
||||
return NULL;
|
||||
|
||||
INIT_LIST_HEAD(&imp->imp_pinger_chain);
|
||||
|
@ -1819,7 +1819,7 @@ void *kuc_alloc(int payload_len, int transport, int type)
|
|||
int len = kuc_len(payload_len);
|
||||
|
||||
lh = kzalloc(len, GFP_NOFS);
|
||||
if (lh == NULL)
|
||||
if (!lh)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
lh->kuc_magic = KUC_MAGIC;
|
||||
|
|
|
@ -61,7 +61,7 @@ static struct llog_handle *llog_alloc_handle(void)
|
|||
struct llog_handle *loghandle;
|
||||
|
||||
loghandle = kzalloc(sizeof(*loghandle), GFP_NOFS);
|
||||
if (loghandle == NULL)
|
||||
if (!loghandle)
|
||||
return NULL;
|
||||
|
||||
init_rwsem(&loghandle->lgh_lock);
|
||||
|
@ -208,7 +208,7 @@ int llog_init_handle(const struct lu_env *env, struct llog_handle *handle,
|
|||
LASSERT(handle->lgh_hdr == NULL);
|
||||
|
||||
llh = kzalloc(sizeof(*llh), GFP_NOFS);
|
||||
if (llh == NULL)
|
||||
if (!llh)
|
||||
return -ENOMEM;
|
||||
handle->lgh_hdr = llh;
|
||||
/* first assign flags to use llog_client_ops */
|
||||
|
@ -435,7 +435,7 @@ int llog_process_or_fork(const struct lu_env *env,
|
|||
int rc;
|
||||
|
||||
lpi = kzalloc(sizeof(*lpi), GFP_NOFS);
|
||||
if (lpi == NULL) {
|
||||
if (!lpi) {
|
||||
CERROR("cannot alloc pointer\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
|
|
@ -275,7 +275,7 @@ struct dentry *ldebugfs_add_symlink(const char *name, struct dentry *parent,
|
|||
return NULL;
|
||||
|
||||
dest = kzalloc(MAX_STRING_SIZE + 1, GFP_KERNEL);
|
||||
if (dest == NULL)
|
||||
if (!dest)
|
||||
return NULL;
|
||||
|
||||
va_start(ap, format);
|
||||
|
|
|
@ -105,7 +105,7 @@ int class_add_uuid(const char *uuid, __u64 nid)
|
|||
return -EOVERFLOW;
|
||||
|
||||
data = kzalloc(sizeof(*data), GFP_NOFS);
|
||||
if (data == NULL)
|
||||
if (!data)
|
||||
return -ENOMEM;
|
||||
|
||||
obd_str2uuid(&data->un_uuid, uuid);
|
||||
|
|
|
@ -835,7 +835,7 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc,
|
|||
CDEBUG(D_CONFIG, "Add profile %s\n", prof);
|
||||
|
||||
lprof = kzalloc(sizeof(*lprof), GFP_NOFS);
|
||||
if (lprof == NULL)
|
||||
if (!lprof)
|
||||
return -ENOMEM;
|
||||
INIT_LIST_HEAD(&lprof->lp_list);
|
||||
|
||||
|
@ -979,7 +979,7 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg,
|
|||
new_len = LUSTRE_CFG_BUFLEN(cfg, 1) + strlen(new_name) - name_len;
|
||||
|
||||
new_param = kzalloc(new_len, GFP_NOFS);
|
||||
if (new_param == NULL)
|
||||
if (!new_param)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
strcpy(new_param, new_name);
|
||||
|
@ -987,7 +987,7 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg,
|
|||
strcat(new_param, value);
|
||||
|
||||
bufs = kzalloc(sizeof(*bufs), GFP_NOFS);
|
||||
if (bufs == NULL) {
|
||||
if (!bufs) {
|
||||
kfree(new_param);
|
||||
return ERR_PTR(-ENOMEM);
|
||||
}
|
||||
|
@ -1461,7 +1461,7 @@ int class_config_llog_handler(const struct lu_env *env,
|
|||
inst_len = LUSTRE_CFG_BUFLEN(lcfg, 0) +
|
||||
sizeof(clli->cfg_instance) * 2 + 4;
|
||||
inst_name = kzalloc(inst_len, GFP_NOFS);
|
||||
if (inst_name == NULL) {
|
||||
if (!inst_name) {
|
||||
rc = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
@ -1639,7 +1639,7 @@ int class_config_dump_handler(const struct lu_env *env,
|
|||
int rc = 0;
|
||||
|
||||
outstr = kzalloc(256, GFP_NOFS);
|
||||
if (outstr == NULL)
|
||||
if (!outstr)
|
||||
return -ENOMEM;
|
||||
|
||||
if (rec->lrh_type == OBD_CFG_REC) {
|
||||
|
|
|
@ -85,7 +85,7 @@ int lustre_process_log(struct super_block *sb, char *logname,
|
|||
LASSERT(cfg);
|
||||
|
||||
bufs = kzalloc(sizeof(*bufs), GFP_NOFS);
|
||||
if (bufs == NULL)
|
||||
if (!bufs)
|
||||
return -ENOMEM;
|
||||
|
||||
/* mgc_process_config */
|
||||
|
@ -258,7 +258,7 @@ int lustre_start_mgc(struct super_block *sb)
|
|||
mgssec = lsi->lsi_lmd->lmd_mgssec ? lsi->lsi_lmd->lmd_mgssec : "";
|
||||
|
||||
data = kzalloc(sizeof(*data), GFP_NOFS);
|
||||
if (data == NULL) {
|
||||
if (!data) {
|
||||
rc = -ENOMEM;
|
||||
goto out_free;
|
||||
}
|
||||
|
@ -885,7 +885,7 @@ static int lmd_parse_mgssec(struct lustre_mount_data *lmd, char *ptr)
|
|||
length = tail - ptr;
|
||||
|
||||
lmd->lmd_mgssec = kzalloc(length + 1, GFP_NOFS);
|
||||
if (lmd->lmd_mgssec == NULL)
|
||||
if (!lmd->lmd_mgssec)
|
||||
return -ENOMEM;
|
||||
|
||||
memcpy(lmd->lmd_mgssec, ptr, length);
|
||||
|
@ -911,7 +911,7 @@ static int lmd_parse_string(char **handle, char *ptr)
|
|||
length = tail - ptr;
|
||||
|
||||
*handle = kzalloc(length + 1, GFP_NOFS);
|
||||
if (*handle == NULL)
|
||||
if (!*handle)
|
||||
return -ENOMEM;
|
||||
|
||||
memcpy(*handle, ptr, length);
|
||||
|
@ -941,7 +941,7 @@ static int lmd_parse_mgs(struct lustre_mount_data *lmd, char **ptr)
|
|||
oldlen = strlen(lmd->lmd_mgs) + 1;
|
||||
|
||||
mgsnid = kzalloc(oldlen + length + 1, GFP_NOFS);
|
||||
if (mgsnid == NULL)
|
||||
if (!mgsnid)
|
||||
return -ENOMEM;
|
||||
|
||||
if (lmd->lmd_mgs != NULL) {
|
||||
|
@ -983,7 +983,7 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd)
|
|||
lmd->lmd_magic = LMD_MAGIC;
|
||||
|
||||
lmd->lmd_params = kzalloc(4096, GFP_NOFS);
|
||||
if (lmd->lmd_params == NULL)
|
||||
if (!lmd->lmd_params)
|
||||
return -ENOMEM;
|
||||
lmd->lmd_params[0] = '\0';
|
||||
|
||||
|
|
Loading…
Reference in New Issue