Re: is there small mistake in lib/vsprintf.c of kernel 2.4.20 ?

From: viro@parcelfarce.linux.theplanet.co.uk
Date: Fri May 02 2003 - 04:08:35 EST


On Fri, May 02, 2003 at 11:06:32AM +0200, Bodo Rzany wrote:
> PROBLEM:
> Hex/Octal decoding with sscanf from kernel library does not work
> within kernel 2.4.20
>
> DESCRIPTION:
> Line 570 in lib/vsprintf.c
>
> 14677 11. Okt 2001 vsprintf.c
>
> holds ' base = 10; '
>
> which prevents the real conversion routines ('simple_strtoul' a.s.o.)
> from decoding numbers from bases other than 10.

It's not a problem, it's standard-mandated behaviour.

>From vsscanf(3):
       The following conversions are available:
...
       d Matches an optionally signed decimal integer; the next pointer
              must be a pointer to int.
...
       i Matches an optionally signed integer; the next pointer must be a
              pointer to int. The integer is read in base 16 if it begins
              with `0x' or `0X', in base 8 if it begins with `0', and in base
              10 otherwise. Only characters that correspond to the base are
              used.

IOW, %d _does_ mean base=10. base=0 is %i. That goes both for kernel and
userland implementations of scanf family (and for any standard-compliant
implementation, for that matter).
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed May 07 2003 - 22:00:15 EST