blob: aa6196ee9011e6d667e82cf101fe23cea5cec593 [file] [log] [blame]
Patrick Williamsb48b7b42016-08-17 15:04:38 -05001From 94094cc4ee7ae585da3e5e7e83e7d82b5d6de656 Mon Sep 17 00:00:00 2001
2From: Alexander Stein <alexander.stein@systec-electronic.com>
3Date: Wed, 14 Nov 2012 12:13:06 +0100
4Subject: [PATCH] Use strcmp instead of sizeof on char* string
5
6This bug was detected by the clang warning:
7libsocketcan.c:384:16: warning: argument to 'sizeof' in 'strncmp' call
8is the same expression as the source; did you mean to provide an
9explicit length? [-Wsizeof-pointer-memaccess]
10sizeof(name)) != 0)
11~~~~~~~^~~~~~
12
13Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
14Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
15---
16Upstream-Status: Backport
17
18 src/libsocketcan.c | 5 ++---
19 1 file changed, 2 insertions(+), 3 deletions(-)
20
21diff --git a/src/libsocketcan.c b/src/libsocketcan.c
22index fedcbdc..841c2ed 100644
23--- a/src/libsocketcan.c
24+++ b/src/libsocketcan.c
25@@ -379,9 +379,8 @@ static int do_get_nl_link(int fd, __u8 acquire, const char *name, void *res)
26 nl_msg->nlmsg_len - NLMSG_LENGTH(sizeof(struct ifaddrmsg));
27 parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len);
28
29- if (strncmp
30- ((char *)RTA_DATA(tb[IFLA_IFNAME]), name,
31- sizeof(name)) != 0)
32+ if (strcmp
33+ ((char *)RTA_DATA(tb[IFLA_IFNAME]), name) != 0)
34 continue;
35
36 if (tb[IFLA_LINKINFO])
37--
381.8.3.1
39