On Mon, 22 Sep 2008 16:39:01 +0300 Doron Shoham <dorons@xxxxxxxxxxxx> wrote: > Hi, > > I have noticed that on parser.c the return values of strtol/strtoul is being ignored. > > This is the warning messages when compiling the code: > parser.c: In function 'match_one': > parser.c:71: warning: ignoring return value of 'strtol', declared with attribute warn_unused_result > parser.c:74: warning: ignoring return value of 'strtoul', declared with attribute warn_unused_result > parser.c:77: warning: ignoring return value of 'strtoul', declared with attribute warn_unused_result > parser.c:80: warning: ignoring return value of 'strtoul', declared with attribute warn_unused_result > > Below is the code: > > switch (*p++) { > case 's': > if (strlen(s) == 0) > return 0; > else if (len == -1 || len > strlen(s)) > len = strlen(s); > args[argc].to = s + len; > break; > case 'd': > strtol(s, &args[argc].to, 0); > goto num; > case 'u': > strtoul(s, &args[argc].to, 0); > goto num; > case 'o': > strtoul(s, &args[argc].to, 8); > goto num; > case 'x': > strtoul(s, &args[argc].to, 16); > num: > if (args[argc].to == args[argc].from) > return 0; > break; > default: > return 0; > } > s = args[argc].to; > argc++; > } > > As I understand, today, all other options beside 's' are not in use. > Are they exist only for future use? iSNS uses "%d". > Anyway, if we keep this code we need to check the return values in > order to avoid the above warnings. Yeah, we need to kill the above warnings though we don't need the return value here. This patch works for you? My gcc doesn't give the above warnings so I can't test it. Thanks, diff --git a/usr/parser.c b/usr/parser.c index 7b892a5..0b244e4 100644 --- a/usr/parser.c +++ b/usr/parser.c @@ -30,6 +30,7 @@ static int match_one(char *s, char *p, substring_t args[]) { char *meta; int argc = 0; + unsigned long long ret; if (!p) return 1; @@ -68,16 +69,16 @@ static int match_one(char *s, char *p, substring_t args[]) args[argc].to = s + len; break; case 'd': - strtol(s, &args[argc].to, 0); + ret = strtol(s, &args[argc].to, 0); goto num; case 'u': - strtoul(s, &args[argc].to, 0); + ret = strtoul(s, &args[argc].to, 0); goto num; case 'o': - strtoul(s, &args[argc].to, 8); + ret = strtoul(s, &args[argc].to, 8); goto num; case 'x': - strtoul(s, &args[argc].to, 16); + ret = strtoul(s, &args[argc].to, 16); num: if (args[argc].to == args[argc].from) return 0; -- To unsubscribe from this list: send the line "unsubscribe stgt" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html