From: singhalsimran0@gmail.com (simran singhal)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/3] staging: speakup: Clean up tests if NULL returned on failure
Date: Sat, 4 Mar 2017 22:16:54 +0530 [thread overview]
Message-ID: <1488646015-7059-3-git-send-email-singhalsimran0@gmail.com> (raw)
In-Reply-To: <1488646015-7059-1-git-send-email-singhalsimran0@gmail.com>
Some functions like kmalloc/kzalloc return NULL on failure.
When NULL represents failure, !x is commonly used.
This was done using Coccinelle:
@@
expression *e;
identifier l1;
@@
e = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\)(...);
...
- e == NULL
+ !e
Signed-off-by: simran singhal <singhalsimran0@gmail.com>
---
drivers/staging/speakup/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
index c2f70ef..e8268bc 100644
--- a/drivers/staging/speakup/main.c
+++ b/drivers/staging/speakup/main.c
@@ -1324,7 +1324,7 @@ static int speakup_allocate(struct vc_data *vc)
if (speakup_console[vc_num] == NULL) {
speakup_console[vc_num] = kzalloc(sizeof(*speakup_console[0]),
GFP_ATOMIC);
- if (speakup_console[vc_num] == NULL)
+ if (!speakup_console[vc_num])
return -ENOMEM;
speakup_date(vc);
} else if (!spk_parked)
--
2.7.4
next prev parent reply other threads:[~2017-03-04 16:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-04 16:46 [PATCH 0/3] staging: Clean up tests if NULL returned on failure simran singhal
2017-03-04 16:46 ` [PATCH 1/3] staging: rtl8192u: " simran singhal
2017-03-04 16:46 ` simran singhal [this message]
2017-03-04 16:46 ` [PATCH 3/3] staging: vc04_services: " simran singhal
2017-03-04 17:29 ` [Outreachy kernel] [PATCH 0/3] staging: " Julia Lawall
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=1488646015-7059-3-git-send-email-singhalsimran0@gmail.com \
--to=singhalsimran0@gmail.com \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).