[Python-Dev] Re: sre warnings

Gustavo Niemeyer niemeyer at conectiva.com
Fri Jan 9 23:40:33 EST 2004


> >>The changes to re are still throwing off signed/unsigned warnings.  Can
> >>you please get that fixed up?
> >
> >
> >My changes to sre have nothing to do with these warnings.
> 
> This is not true. I get
> 
> Modules/_sre.c:811: warning: comparison between signed and unsigned
> 
> Now, line 811 is
> 
>     DATA_ALLOC(SRE_MATCH_CONTEXT, ctx);

Ohh.. I wasn't aware about this case, since I get no errors at all at
this line. Do you see any others? I personally get these:

Modules/_sre.c:381: warning: comparison is always true due to limited
range of data type
Modules/_sre.c:383: warning: comparison is always true due to limited
range of data type
Modules/_sre.c:390: warning: comparison is always true due to limited
range of data type
Modules/_sre.c:392: warning: comparison is always true due to limited
range of data type
Modules/_sre.c: In function `sre_charset':
Modules/_sre.c:487: warning: comparison is always true due to limited
range of data type
Modules/_sre.c: In function `sre_ucharset':
Modules/_sre.c:487: warning: comparison is always true due to limited
range of data type

Suggestions welcome.

> The culprit is the line
> 
>     if (state->data_stack_size < alloc_pos+sizeof(type)) { \
> 
> because data_stack_size is signed, and sizeof(type) is
> size_t. This line is yours
> 
> 2.101        (niemeyer 17-Oct-03):     if (state->data_stack_size < 
> alloc_pos+sizeof (type)) {
>
> Changing the type of data_stack_size to unsigned makes the
> warning go away.

It will be a pleasure to fix that once I'm back from vacation (dialup
tsc tsc), and get the necessary time. Thanks for pointing me out.

> Please change all uses of sizes/positions to "size_t", and
> change the special -1 marker to (size_t)-1.

Ditto.

-- 
Gustavo Niemeyer
http://niemeyer.net



More information about the Python-Dev mailing list