From: SF Markus Elfring <elfring@users.sourceforge.net>
To: netdev@vger.kernel.org, "Alexey Dobriyan" <adobriyan@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Florian Westphal" <fw@strlen.de>,
"Günter Röck" <linux@roeck-us.net>,
"John Fastabend" <john.fastabend@gmail.com>,
"Paolo Abeni" <pabeni@redhat.com>,
"Willem de Bruijn" <willemb@google.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 3/3] net: pktgen: Adjust five checks for null pointers
Date: Mon, 22 May 2017 11:14:37 +0200 [thread overview]
Message-ID: <9cbf8dea-1a36-9388-af71-9c07d788d0af@users.sourceforge.net> (raw)
In-Reply-To: <79472009-7764-bb92-5f29-60bb21793cec@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 22 May 2017 10:44:16 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The script “checkpatch.pl” pointed information out like the following.
Comparison to NULL could be written !…
Thus fix the affected source code places.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
net/core/pktgen.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 51008ddc7af6..a28350c9ac67 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -1986,7 +1986,7 @@ static void pktgen_mark_device(const struct pktgen_net *pn, const char *ifname)
while (1) {
pkt_dev = __pktgen_NN_threads(pn, ifname, REMOVE);
- if (pkt_dev == NULL)
+ if (!pkt_dev)
break; /* success */
mutex_unlock(&pktgen_thread_lock);
@@ -3274,7 +3274,7 @@ static struct pktgen_dev *next_to_run(struct pktgen_thread *t)
list_for_each_entry_rcu(pkt_dev, &t->if_list, list) {
if (!pkt_dev->running)
continue;
- if (best == NULL)
+ if (!best)
best = pkt_dev;
else if (ktime_compare(pkt_dev->next_tx, best->next_tx) < 0)
best = pkt_dev;
@@ -3402,7 +3402,7 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)
kfree_skb(pkt_dev->skb);
pkt_dev->skb = fill_packet(odev, pkt_dev);
- if (pkt_dev->skb == NULL) {
+ if (!pkt_dev->skb) {
pr_err("ERROR: couldn't allocate skb in fill_packet\n");
schedule();
pkt_dev->clone_count--; /* back out increment, OOM */
@@ -3685,7 +3685,7 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname)
strcpy(pkt_dev->odevname, ifname);
pkt_dev->flows = vzalloc_node(MAX_CFLOWS * sizeof(struct flow_state),
node);
- if (pkt_dev->flows == NULL) {
+ if (!pkt_dev->flows) {
kfree(pkt_dev);
return -ENOMEM;
}
@@ -3868,7 +3868,7 @@ static int __net_init pg_net_init(struct net *net)
return -ENODEV;
}
pe = proc_create(PGCTRL, 0600, pn->proc_dir, &pktgen_fops);
- if (pe == NULL) {
+ if (!pe) {
pr_err("cannot create %s procfs entry\n", PGCTRL);
ret = -EINVAL;
goto remove;
--
2.13.0
prev parent reply other threads:[~2017-05-22 9:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-22 9:11 [PATCH 0/3] net-pktgen: Adjustments for some function implementations SF Markus Elfring
2017-05-22 9:12 ` [PATCH 1/3] net: pktgen: Improve four size determinations SF Markus Elfring
2017-05-22 9:13 ` [PATCH 2/3] net: pktgen: Delete an error message for a failed memory allocation in pktgen_create_thread() SF Markus Elfring
2017-05-22 9:14 ` SF Markus Elfring [this message]
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=9cbf8dea-1a36-9388-af71-9c07d788d0af@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=adobriyan@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=john.fastabend@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemb@google.com \
/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).