* [PATCH] scripts: modpost: fix compilation warning
@ 2014-06-13 13:39 Michal Nazarewicz
2014-07-09 1:09 ` Rusty Russell
0 siblings, 1 reply; 2+ messages in thread
From: Michal Nazarewicz @ 2014-06-13 13:39 UTC (permalink / raw)
To: Andi Kleen; +Cc: Rusty Russell, linux-kernel, Michal Nazarewicz
The scripts/mod/modpost.c triggers the following warning:
scripts/mod/modpost.c: In function ‘remove_dot’:
scripts/mod/modpost.c:1710:10: warning: ignoring return value of ‘strtoul’, declared with attribute warn_unused_result [-Wunused-result]
The remove_dot function that calls strtoul does not care about the
numeric value of the string that is parsed but only looks for the
end of the numeric sequence. As such, it's equivalent to just skip
over all digits.
Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
---
scripts/mod/modpost.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 0663556..c710651 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1703,12 +1703,11 @@ static void check_sec_ref(struct module *mod, const char *modname,
static char *remove_dot(char *s)
{
- char *end;
- int n = strcspn(s, ".");
+ size_t n = strcspn(s, ".");
- if (n > 0 && s[n] != 0) {
- strtoul(s + n + 1, &end, 10);
- if (end > s + n + 1 && (*end == '.' || *end == 0))
+ if (n && s[n]) {
+ size_t m = strspn(s + n + 1, "0123456789");
+ if (m && (s[n + m] == '.' || s[n + m] == 0))
s[n] = 0;
}
return s;
--
2.0.0.526.g5318336
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] scripts: modpost: fix compilation warning
2014-06-13 13:39 [PATCH] scripts: modpost: fix compilation warning Michal Nazarewicz
@ 2014-07-09 1:09 ` Rusty Russell
0 siblings, 0 replies; 2+ messages in thread
From: Rusty Russell @ 2014-07-09 1:09 UTC (permalink / raw)
To: Michal Nazarewicz, Andi Kleen; +Cc: linux-kernel, Michal Nazarewicz
Michal Nazarewicz <mina86@mina86.com> writes:
> The scripts/mod/modpost.c triggers the following warning:
>
> scripts/mod/modpost.c: In function ‘remove_dot’:
> scripts/mod/modpost.c:1710:10: warning: ignoring return value of ‘strtoul’, declared with attribute warn_unused_result [-Wunused-result]
That's a stupid warning, but your improvement is appreciated.
Applied,
Rusty.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-07-09 1:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-13 13:39 [PATCH] scripts: modpost: fix compilation warning Michal Nazarewicz
2014-07-09 1:09 ` Rusty Russell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox