From: green@linuxhacker.ru
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
devel@driverdev.osuosl.org,
Andreas Dilger <andreas.dilger@intel.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Lustre Development List <lustre-devel@lists.lustre.org>,
Oleg Drokin <green@linuxhacker.ru>
Subject: [PATCH 22/45] staging/lustre/mgc: Adjust NULL comparison codestyle
Date: Tue, 16 Feb 2016 00:46:54 -0500 [thread overview]
Message-ID: <1455601637-3847710-23-git-send-email-green@linuxhacker.ru> (raw)
In-Reply-To: <1455601637-3847710-1-git-send-email-green@linuxhacker.ru>
From: Oleg Drokin <green@linuxhacker.ru>
All instances of "x == NULL" are changed to "!x" and
"x != NULL" to "x"
Also remove some redundant assertions.
Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
---
drivers/staging/lustre/lustre/mgc/mgc_request.c | 41 ++++++++++++-------------
1 file changed, 20 insertions(+), 21 deletions(-)
diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index ab4800c..bd34ab3 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -162,7 +162,7 @@ struct config_llog_data *config_log_find(char *logname,
struct config_llog_data *found = NULL;
void *instance;
- LASSERT(logname != NULL);
+ LASSERT(logname);
instance = cfg ? cfg->cfg_instance : NULL;
spin_lock(&config_list_lock);
@@ -300,7 +300,7 @@ static int config_log_add(struct obd_device *obd, char *logname,
* <fsname>-sptlrpc. multiple regular logs may share one sptlrpc log.
*/
ptr = strrchr(logname, '-');
- if (ptr == NULL || ptr - logname > 8) {
+ if (!ptr || ptr - logname > 8) {
CERROR("logname %s is too long\n", logname);
return -EINVAL;
}
@@ -309,7 +309,7 @@ static int config_log_add(struct obd_device *obd, char *logname,
strcpy(seclogname + (ptr - logname), "-sptlrpc");
sptlrpc_cld = config_log_find(seclogname, NULL);
- if (sptlrpc_cld == NULL) {
+ if (!sptlrpc_cld) {
sptlrpc_cld = do_config_log_add(obd, seclogname,
CONFIG_T_SPTLRPC, NULL, NULL);
if (IS_ERR(sptlrpc_cld)) {
@@ -376,7 +376,7 @@ static int config_log_end(char *logname, struct config_llog_instance *cfg)
int rc = 0;
cld = config_log_find(logname, cfg);
- if (cld == NULL)
+ if (!cld)
return -ENOENT;
mutex_lock(&cld->cld_lock);
@@ -455,7 +455,7 @@ int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data)
spin_lock(&config_list_lock);
list_for_each_entry(cld, &config_llog_list, cld_list_chain) {
- if (cld->cld_recover == NULL)
+ if (!cld->cld_recover)
continue;
seq_printf(m, " - { client: %s, nidtbl_version: %u }\n",
cld->cld_logname,
@@ -883,7 +883,7 @@ static int mgc_enqueue(struct obd_export *exp, struct lov_stripe_md *lsm,
req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp),
&RQF_LDLM_ENQUEUE, LUSTRE_DLM_VERSION,
LDLM_ENQUEUE);
- if (req == NULL)
+ if (!req)
return -ENOMEM;
req_capsule_set_size(&req->rq_pill, &RMF_DLM_LVB, RCL_SERVER, 0);
@@ -921,7 +921,7 @@ static int mgc_target_register(struct obd_export *exp,
req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp),
&RQF_MGS_TARGET_REG, LUSTRE_MGS_VERSION,
MGS_TARGET_REG);
- if (req == NULL)
+ if (!req)
return -ENOMEM;
req_mti = req_capsule_client_get(&req->rq_pill, &RMF_MGS_TARGET_INFO);
@@ -1109,7 +1109,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc,
int rc = 0;
int off = 0;
- LASSERT(cfg->cfg_instance != NULL);
+ LASSERT(cfg->cfg_instance);
LASSERT(cfg->cfg_sb == cfg->cfg_instance);
inst = kzalloc(PAGE_CACHE_SIZE, GFP_KERNEL);
@@ -1195,7 +1195,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc,
/* lustre-OST0001-osc-<instance #> */
strcpy(obdname, cld->cld_logname);
cname = strrchr(obdname, '-');
- if (cname == NULL) {
+ if (!cname) {
CERROR("mgc %s: invalid logname %s\n",
mgc->obd_name, obdname);
break;
@@ -1212,7 +1212,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc,
/* find the obd by obdname */
obd = class_name2obd(obdname);
- if (obd == NULL) {
+ if (!obd) {
CDEBUG(D_INFO, "mgc %s: cannot find obdname %s\n",
mgc->obd_name, obdname);
rc = 0;
@@ -1227,7 +1227,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc,
uuid = buf + pos;
down_read(&obd->u.cli.cl_sem);
- if (obd->u.cli.cl_import == NULL) {
+ if (!obd->u.cli.cl_import) {
/* client does not connect to the OST yet */
up_read(&obd->u.cli.cl_sem);
rc = 0;
@@ -1257,7 +1257,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc,
rc = -ENOMEM;
lcfg = lustre_cfg_new(LCFG_PARAM, &bufs);
- if (lcfg == NULL) {
+ if (!lcfg) {
CERROR("mgc: cannot allocate memory\n");
break;
}
@@ -1309,14 +1309,14 @@ static int mgc_process_recover_log(struct obd_device *obd,
nrpages = CONFIG_READ_NRPAGES_INIT;
pages = kcalloc(nrpages, sizeof(*pages), GFP_KERNEL);
- if (pages == NULL) {
+ if (!pages) {
rc = -ENOMEM;
goto out;
}
for (i = 0; i < nrpages; i++) {
pages[i] = alloc_page(GFP_KERNEL);
- if (pages[i] == NULL) {
+ if (!pages[i]) {
rc = -ENOMEM;
goto out;
}
@@ -1327,7 +1327,7 @@ again:
LASSERT(mutex_is_locked(&cld->cld_lock));
req = ptlrpc_request_alloc(class_exp2cliimp(cld->cld_mgcexp),
&RQF_MGS_CONFIG_READ);
- if (req == NULL) {
+ if (!req) {
rc = -ENOMEM;
goto out;
}
@@ -1338,7 +1338,6 @@ again:
/* pack request */
body = req_capsule_client_get(&req->rq_pill, &RMF_MGS_CONFIG_BODY);
- LASSERT(body != NULL);
LASSERT(sizeof(body->mcb_name) > strlen(cld->cld_logname));
if (strlcpy(body->mcb_name, cld->cld_logname, sizeof(body->mcb_name))
>= sizeof(body->mcb_name)) {
@@ -1353,7 +1352,7 @@ again:
/* allocate bulk transfer descriptor */
desc = ptlrpc_prep_bulk_imp(req, nrpages, 1, BULK_PUT_SINK,
MGS_BULK_PORTAL);
- if (desc == NULL) {
+ if (!desc) {
rc = -ENOMEM;
goto out;
}
@@ -1434,7 +1433,7 @@ out:
if (pages) {
for (i = 0; i < nrpages; i++) {
- if (pages[i] == NULL)
+ if (!pages[i])
break;
__free_page(pages[i]);
}
@@ -1635,7 +1634,7 @@ static int mgc_process_config(struct obd_device *obd, u32 len, void *buf)
if (rc)
break;
cld = config_log_find(logname, cfg);
- if (cld == NULL) {
+ if (!cld) {
rc = -ENOENT;
break;
}
@@ -1646,7 +1645,7 @@ static int mgc_process_config(struct obd_device *obd, u32 len, void *buf)
cld->cld_cfg.cfg_flags |= CFG_F_COMPAT146;
rc = mgc_process_log(obd, cld);
- if (rc == 0 && cld->cld_recover != NULL) {
+ if (rc == 0 && cld->cld_recover) {
if (OCD_HAS_FLAG(&obd->u.cli.cl_import->
imp_connect_data, IMP_RECOV)) {
rc = mgc_process_log(obd, cld->cld_recover);
@@ -1660,7 +1659,7 @@ static int mgc_process_config(struct obd_device *obd, u32 len, void *buf)
CERROR("Cannot process recover llog %d\n", rc);
}
- if (rc == 0 && cld->cld_params != NULL) {
+ if (rc == 0 && cld->cld_params) {
rc = mgc_process_log(obd, cld->cld_params);
if (rc == -ENOENT) {
CDEBUG(D_MGC,
--
2.1.0
next prev parent reply other threads:[~2016-02-16 5:56 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-16 5:46 [PATCH 00/45] Lustre cleanups green
2016-02-16 5:46 ` [PATCH 01/45] staging/lustre/ptlrpc: Get rid of /proc references in comments green
2016-02-16 5:46 ` [PATCH 02/45] staging/lustre/obdclass: " green
2016-02-16 5:46 ` [PATCH 03/45] staging/lustre/libcfs: " green
2016-02-16 5:46 ` [PATCH 04/45] staging/lustre/llite: " green
2016-02-16 5:46 ` [PATCH 05/45] staging/lustre/lov: " green
2016-02-16 5:46 ` [PATCH 06/45] staging/lustre: Remove unused function oti_init green
2016-02-16 5:46 ` [PATCH 07/45] staging/lustre: Remove unused osc_on_mdt function green
2016-02-16 5:46 ` [PATCH 08/45] staging/lustre: Remove server code from client_obd_setup() green
2016-02-16 5:46 ` [PATCH 09/45] staging/lustre: Remove server code from class_get_type() green
2016-02-16 5:46 ` [PATCH 10/45] staging/lustre: Remove commented out lock_lock_multi_match green
2016-02-16 5:46 ` [PATCH 11/45] staging/lustre/osc: Remove commented out osc_page_protected() green
2016-02-16 5:46 ` [PATCH 12/45] staging/lustre/libcfs: Adjust NULL comparison codestyle green
2016-02-16 5:46 ` [PATCH 13/45] staging/lustre/lov: " green
2016-02-16 5:46 ` [PATCH 14/45] staging/lustre/llite: " green
2016-02-16 5:46 ` [PATCH 15/45] staging/lustre/ldlm: " green
2016-02-16 5:46 ` [PATCH 16/45] staging/lustre/lmv: " green
2016-02-16 5:46 ` [PATCH 17/45] staging/lustre/fid: " green
2016-02-16 5:46 ` [PATCH 18/45] staging/lustre/fld: " green
2016-02-16 5:46 ` [PATCH 19/45] staging/lustre/lclient: " green
2016-02-16 5:46 ` [PATCH 20/45] staging/lustre/include: " green
2016-02-16 5:46 ` [PATCH 21/45] staging/lustre/mdc: " green
2016-02-16 5:46 ` green [this message]
2016-02-16 5:46 ` [PATCH 23/45] staging/lustre/obdclass: " green
2016-02-16 5:46 ` [PATCH 24/45] staging/lustre/obdecho: " green
2016-02-16 5:46 ` [PATCH 25/45] staging/lustre/osc: " green
2016-02-16 5:46 ` [PATCH 26/45] staging/lustre/ptlrpc: " green
2016-02-16 5:46 ` [PATCH 27/45] staging/lustre: Remove the "write to FSF to get a copy of GPL" wording green
2016-02-16 5:47 ` [PATCH 28/45] staging/lustre/libcfs: Cleanup: parenthesis alignment adjustments green
2016-02-16 5:47 ` [PATCH 29/45] staging/lustre/libcfs: Move EXPORT_SYMBOLs under function/variable green
2016-02-16 5:47 ` [PATCH 30/45] staging/lustre/libcfs: style change to add missing spaces for operations green
2016-02-16 5:47 ` [PATCH 31/45] staging/lustre/libcfs: reformat cfs_tcd_for_each_type_lock define green
2016-02-16 5:47 ` [PATCH 32/45] staging/lustre/libcfs: Remove stray spaces after function name green
2016-02-16 5:47 ` [PATCH 33/45] staging/lustre/libcfs: Shortened too long lines green
2016-02-16 5:47 ` [PATCH 34/45] staging/lustre/libcfs: Remove unused cfs_tcd_owns_tage() function green
2016-02-16 5:47 ` [PATCH 35/45] staging/lustre/libcfs: Move private tracefile structs out of header green
2016-02-16 5:47 ` [PATCH 36/45] staging/lustre/libcfs: Update comments style to match kernel green
2016-02-16 5:47 ` [PATCH 37/45] staging/lustre/libcfs: Remove useless returns in void functions green
2016-02-16 5:47 ` [PATCH 38/45] staging/lustre/libcfs: Remove empty lines after/before braces green
2016-02-16 5:47 ` [PATCH 39/45] staging/lustre: Update cfs_cpu_notify switch statement with a comment green
2016-02-16 5:47 ` [PATCH 40/45] staging/lustre: Get rid of cfs_trace_buf_type_t typedef green
2016-02-16 5:47 ` [PATCH 41/45] staging/lustre/libcfs: Get rid of multiple assignments green
2016-02-16 5:47 ` [PATCH 42/45] staging/lustre: Remove space after cast in cfs_crypto_hash_final() green
2016-02-16 5:47 ` [PATCH 43/45] staging/lustre/libcfs: Replace use of printk with pr_<level> green
2016-02-16 5:55 ` Joe Perches
2016-02-16 16:12 ` Oleg Drokin
2016-02-20 22:34 ` Greg Kroah-Hartman
2016-02-16 5:47 ` [PATCH 44/45] staging/lustre: Convert cfs_trace_daemon_command to use kstrtoul green
2016-02-16 5:47 ` [PATCH 45/45] staging/lustre: Convert cfs_str2num_check " green
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1455601637-3847710-23-git-send-email-green@linuxhacker.ru \
--to=green@linuxhacker.ru \
--cc=andreas.dilger@intel.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lustre-devel@lists.lustre.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox