From: SF Markus Elfring <elfring@users.sourceforge.net>
To: tipc-discussion@lists.sourceforge.net, netdev@vger.kernel.org,
"David S. Miller" <davem@davemloft.net>,
Jon Maloy <jon.maloy@ericsson.com>,
Ying Xue <ying.xue@windriver.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH] tipc: Delete error messages for failed memory allocations in three functions
Date: Tue, 23 May 2017 13:07:01 +0000 [thread overview]
Message-ID: <7ac9d513-6f9f-a096-e68f-81a722c2723c@users.sourceforge.net> (raw)
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 23 May 2017 14:45:25 +0200
Omit four extra messages for memory allocation failures in these functions.
This issue was detected by using the Coccinelle software.
Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
net/tipc/name_table.c | 15 ++++-----------
net/tipc/node.c | 5 ++---
2 files changed, 6 insertions(+), 14 deletions(-)
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index bd0aac87b41a..7e731af8a1a7 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -117,10 +117,8 @@ static struct publication *publ_create(u32 type, u32 lower, u32 upper,
u32 key)
{
struct publication *publ = kzalloc(sizeof(*publ), GFP_ATOMIC);
- if (publ = NULL) {
- pr_warn("Publication creation failure, no memory\n");
+ if (!publ)
return NULL;
- }
publ->type = type;
publ->lower = lower;
@@ -270,11 +268,9 @@ static struct publication *tipc_nameseq_insert_publ(struct net *net,
if (nseq->first_free = nseq->alloc) {
struct sub_seq *sseqs = tipc_subseq_alloc(nseq->alloc * 2);
- if (!sseqs) {
- pr_warn("Cannot publish {%u,%u,%u}, no memory\n",
- type, lower, upper);
+ if (!sseqs)
return NULL;
- }
+
memcpy(sseqs, nseq->sseqs,
nseq->alloc * sizeof(struct sub_seq));
kfree(nseq->sseqs);
@@ -283,11 +279,8 @@ static struct publication *tipc_nameseq_insert_publ(struct net *net,
}
info = kzalloc(sizeof(*info), GFP_ATOMIC);
- if (!info) {
- pr_warn("Cannot publish {%u,%u,%u}, no memory\n",
- type, lower, upper);
+ if (!info)
return NULL;
- }
INIT_LIST_HEAD(&info->node_list);
INIT_LIST_HEAD(&info->cluster_list);
diff --git a/net/tipc/node.c b/net/tipc/node.c
index aeef8011ac7d..0c7f5f755a28 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -324,10 +324,9 @@ struct tipc_node *tipc_node_create(struct net *net, u32 addr, u16 capabilities)
goto exit;
}
n = kzalloc(sizeof(*n), GFP_ATOMIC);
- if (!n) {
- pr_warn("Node creation failed, no memory\n");
+ if (!n)
goto exit;
- }
+
n->addr = addr;
n->net = net;
n->capabilities = capabilities;
--
2.13.0
next reply other threads:[~2017-05-23 13:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-23 13:07 SF Markus Elfring [this message]
2017-05-23 14:02 ` [PATCH] tipc: Delete error messages for failed memory allocations in three functions Joe Perches
2017-05-23 16:23 ` SF Markus Elfring
2017-05-23 16:39 ` Joe Perches
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=7ac9d513-6f9f-a096-e68f-81a722c2723c@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=davem@davemloft.net \
--cc=jon.maloy@ericsson.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=tipc-discussion@lists.sourceforge.net \
--cc=ying.xue@windriver.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