Hi Erwin,

> > The problem is, that it seems that sscanf doesn't check the 
> > range of the var to which the digits should be converted. 
> > 
> > [...]
> > 
> > In the first case, sscanf doesn't work fine. The problem is, that
> > th 
> > maximum integer is 0xffffffff whis is 4294967295. So, my input is 
> > bigger than the maximum value. 
> > I thought, that in this case, sscanf should set the &ouput 
> > to INFINITY. Or, at least, it should return 0. But it looks like
> > sscanf 
> > just returns a meaningless value. 
> 
> why don't you like the idea that I suggested a while ago to set errno=0
> before calling sscanf and check the value of errno afterwards?

I'm sorry, but i think that I have not been clear enough that while ago.
You're idea didn't work. I set errno=0 and after the call to sscanf it is 
still set to 0.

Here's my example:
    unsigned int output; 
    char input1[] = "9999999999\0"; 
    char input2[] = "999999999\0"; 
    errno=0;
    if (sscanf(input1, "%d", &output) != 1) 
    { 
            printf("sscanf returned an error for input 1\n"); 
            exit(0); 
    } 
    printf("we read %d for input 1 with errno %d\n", output, errno); 
    if (sscanf(input2, "%d", &output) != 1) 
    { 
            printf("sscanf returned an error for input 2\n"); 
            exit(0); 
    } 
    printf("we read %d for input 2 with errno %d\n", output, errno); 
    exit(0);

And the output is:
        we read 1410065407 for input 1 with errno 0
        we read 999999999 for input 2 with errno 0

What sscanf SHOULD do is: Set the errno to something like 
"number out of range" AND to return 0 to indicate the error.

In the uClibc list somebody ment to remeber, that this has been an 
error some time ago. So what I should try is to take a newer uClibc 
to check if the error is still there. So my next question is:
Has somebody ever tried to integrate a newer uClibc inside uClinux?

Cheers,
Mathias

_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

Reply via email to