* [PATCH] Use strcmp instead of sizeof on char* string
@ 2012-11-14 11:13 Alexander Stein
2012-11-28 12:12 ` Marc Kleine-Budde
0 siblings, 1 reply; 2+ messages in thread
From: Alexander Stein @ 2012-11-14 11:13 UTC (permalink / raw)
To: linux-can; +Cc: Alexander Stein
This bug was detected by the clang warning:
libsocketcan.c:384:16: warning: argument to 'sizeof' in 'strncmp' call
is the same expression as the source; did you mean to provide an
explicit length? [-Wsizeof-pointer-memaccess]
sizeof(name)) != 0)
~~~~~~~^~~~~~
Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
---
src/libsocketcan.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/libsocketcan.c b/src/libsocketcan.c
index fedcbdc..841c2ed 100644
--- a/src/libsocketcan.c
+++ b/src/libsocketcan.c
@@ -379,9 +379,8 @@ static int do_get_nl_link(int fd, __u8 acquire, const char *name, void *res)
nl_msg->nlmsg_len - NLMSG_LENGTH(sizeof(struct ifaddrmsg));
parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len);
- if (strncmp
- ((char *)RTA_DATA(tb[IFLA_IFNAME]), name,
- sizeof(name)) != 0)
+ if (strcmp
+ ((char *)RTA_DATA(tb[IFLA_IFNAME]), name) != 0)
continue;
if (tb[IFLA_LINKINFO])
--
1.7.8.6
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Use strcmp instead of sizeof on char* string
2012-11-14 11:13 [PATCH] Use strcmp instead of sizeof on char* string Alexander Stein
@ 2012-11-28 12:12 ` Marc Kleine-Budde
0 siblings, 0 replies; 2+ messages in thread
From: Marc Kleine-Budde @ 2012-11-28 12:12 UTC (permalink / raw)
To: Alexander Stein; +Cc: linux-can
[-- Attachment #1: Type: text/plain, Size: 716 bytes --]
On 11/14/2012 12:13 PM, Alexander Stein wrote:
> This bug was detected by the clang warning:
> libsocketcan.c:384:16: warning: argument to 'sizeof' in 'strncmp' call
> is the same expression as the source; did you mean to provide an
> explicit length? [-Wsizeof-pointer-memaccess]
> sizeof(name)) != 0)
> ~~~~~~~^~~~~~
>
> Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Tnx, applied to master.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 261 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-11-28 12:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-14 11:13 [PATCH] Use strcmp instead of sizeof on char* string Alexander Stein
2012-11-28 12:12 ` Marc Kleine-Budde
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.