Skip to content

Commit

Permalink
scripts: modpost: fix compilation warning
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
mina86 authored and rustyrussell committed Jul 27, 2014
1 parent 37549e9 commit fcd38ed
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions scripts/mod/modpost.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit fcd38ed

Please sign in to comment.