From: Joe Perches <joe@perches.com>
To: Wang Hai <wanghai38@huawei.com>,
dchickles@marvell.com, sburla@marvell.com, fmanlunas@marvell.com,
davem@davemloft.net, kuba@kernel.org
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] liquidio: Remove unneeded cast from memory allocation
Date: Fri, 24 Jul 2020 14:29:39 -0700 [thread overview]
Message-ID: <2cdef8d442bb5da39aed17bf994a800e768942f7.camel@perches.com> (raw)
In-Reply-To: <20200724130001.71528-1-wanghai38@huawei.com>
On Fri, 2020-07-24 at 21:00 +0800, Wang Hai wrote:
> Remove casting the values returned by memory allocation function.
>
> Coccinelle emits WARNING:
>
> ./drivers/net/ethernet/cavium/liquidio/octeon_device.c:1155:14-36: WARNING:
> casting value returned by memory allocation function to (struct octeon_dispatch *) is useless.
[]
> diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_device.c b/drivers/net/ethernet/cavium/liquidio/octeon_device.c
[]
> @@ -1152,8 +1152,7 @@ octeon_register_dispatch_fn(struct octeon_device *oct,
>
> dev_dbg(&oct->pci_dev->dev,
> "Adding opcode to dispatch list linked list\n");
> - dispatch = (struct octeon_dispatch *)
> - vmalloc(sizeof(struct octeon_dispatch));
> + dispatch = vmalloc(sizeof(struct octeon_dispatch));
More the question is why this is vmalloc at all
as the structure size is very small.
Likely this should just be kmalloc.
drivers/net/ethernet/cavium/liquidio/octeon_device.h:struct octeon_dispatch {
drivers/net/ethernet/cavium/liquidio/octeon_device.h- /** List head for this entry */
drivers/net/ethernet/cavium/liquidio/octeon_device.h- struct list_head list;
drivers/net/ethernet/cavium/liquidio/octeon_device.h-
drivers/net/ethernet/cavium/liquidio/octeon_device.h- /** The opcode for which the dispatch function & arg should be used */
drivers/net/ethernet/cavium/liquidio/octeon_device.h- u16 opcode;
drivers/net/ethernet/cavium/liquidio/octeon_device.h-
drivers/net/ethernet/cavium/liquidio/octeon_device.h- /** The function to be called for a packet received by the driver */
drivers/net/ethernet/cavium/liquidio/octeon_device.h- octeon_dispatch_fn_t dispatch_fn;
drivers/net/ethernet/cavium/liquidio/octeon_device.h-
drivers/net/ethernet/cavium/liquidio/octeon_device.h- /* The application specified argument to be passed to the above
drivers/net/ethernet/cavium/liquidio/octeon_device.h- * function along with the received packet
drivers/net/ethernet/cavium/liquidio/octeon_device.h- */
drivers/net/ethernet/cavium/liquidio/octeon_device.h- void *arg;
drivers/net/ethernet/cavium/liquidio/octeon_device.h-}
> if (!dispatch) {
> dev_err(&oct->pci_dev->dev,
> "No memory to add dispatch function\n");
And this dev_err is unnecessary.
next prev parent reply other threads:[~2020-07-24 21:29 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-24 13:00 [PATCH net-next] liquidio: Remove unneeded cast from memory allocation Wang Hai
2020-07-24 21:29 ` Joe Perches [this message]
2020-07-28 8:42 ` wanghai (M)
2020-07-28 9:11 ` Joe Perches
2020-07-28 13:38 ` wanghai (M)
2020-07-28 15:54 ` Joe Perches
2020-07-30 6:19 ` wanghai (M)
2020-07-28 15:39 Derek Chickles
2020-07-28 15:56 ` Joe Perches
2020-07-28 16:32 Derek Chickles
2020-09-01 14:11 YueHaibing
2020-09-01 18:49 ` David Miller
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=2cdef8d442bb5da39aed17bf994a800e768942f7.camel@perches.com \
--to=joe@perches.com \
--cc=davem@davemloft.net \
--cc=dchickles@marvell.com \
--cc=fmanlunas@marvell.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sburla@marvell.com \
--cc=wanghai38@huawei.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).