diff mbox series

[ethtool,v2,05/13] ethtool: fix extra warnings

Message ID 20221208011122.2343363-6-jesse.brandeburg@intel.com (mailing list archive)
State Changes Requested
Delegated to: Michal Kubecek
Headers show
Series ethtool: clean up and fix | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Jesse Brandeburg Dec. 8, 2022, 1:11 a.m. UTC
'$ scan-build make' reports

netlink/permaddr.c:44:2: warning: Value stored to 'ifinfo' is never read [deadcode.DeadStores]
        ifinfo = mnl_nlmsg_put_extra_header(nlhdr, sizeof(*ifinfo));
        ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

So just remove the extra assignment which is never used.

Fixes: 7f3585b22a4b ("netlink: add handler for permaddr (-P)")
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
---
 netlink/permaddr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michal Kubecek Dec. 8, 2022, 10:43 a.m. UTC | #1
On Wed, Dec 07, 2022 at 05:11:14PM -0800, Jesse Brandeburg wrote:
> '$ scan-build make' reports
> 
> netlink/permaddr.c:44:2: warning: Value stored to 'ifinfo' is never read [deadcode.DeadStores]
>         ifinfo = mnl_nlmsg_put_extra_header(nlhdr, sizeof(*ifinfo));
>         ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> So just remove the extra assignment which is never used.
> 
> Fixes: 7f3585b22a4b ("netlink: add handler for permaddr (-P)")
> Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
> ---
>  netlink/permaddr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/netlink/permaddr.c b/netlink/permaddr.c
> index 006eac6c0094..dccb0c6cfdb7 100644
> --- a/netlink/permaddr.c
> +++ b/netlink/permaddr.c
> @@ -41,7 +41,7 @@ static int permaddr_prep_request(struct nl_socket *nlsk)
>  	nlhdr->nlmsg_type = RTM_GETLINK;
>  	nlhdr->nlmsg_flags = nlm_flags;
>  	msgbuff->nlhdr = nlhdr;
> -	ifinfo = mnl_nlmsg_put_extra_header(nlhdr, sizeof(*ifinfo));
> +	mnl_nlmsg_put_extra_header(nlhdr, sizeof(*ifinfo));

Good point. But looking at the code, the variable isn't in fact used
at all, except of the two occurences of sizeof(*ifinfo). So we can
just as well replace them with sizeof(struct ifinfomsg) and drop the
variable.

Michal

>  
>  	if (devname) {
>  		uint16_t type = IFLA_IFNAME;
> -- 
> 2.31.1
>
diff mbox series

Patch

diff --git a/netlink/permaddr.c b/netlink/permaddr.c
index 006eac6c0094..dccb0c6cfdb7 100644
--- a/netlink/permaddr.c
+++ b/netlink/permaddr.c
@@ -41,7 +41,7 @@  static int permaddr_prep_request(struct nl_socket *nlsk)
 	nlhdr->nlmsg_type = RTM_GETLINK;
 	nlhdr->nlmsg_flags = nlm_flags;
 	msgbuff->nlhdr = nlhdr;
-	ifinfo = mnl_nlmsg_put_extra_header(nlhdr, sizeof(*ifinfo));
+	mnl_nlmsg_put_extra_header(nlhdr, sizeof(*ifinfo));
 
 	if (devname) {
 		uint16_t type = IFLA_IFNAME;