develooper Front page | perl.perl5.porters | Postings from February 2003

Re: remaining signedness issue in Encode 1.88

Thread Previous | Thread Next
From:
Dan Kogai
Date:
February 26, 2003 23:56
Subject:
Re: remaining signedness issue in Encode 1.88
Message ID:
FAF4FE9F-4A28-11D7-ADA4-000393AE4244@dan.co.jp
On Wednesday, Feb 26, 2003, at 14:49 Asia/Tokyo, Craig A. Berry wrote:
> With bleadperl, my C compiler complains about a line in
> encode_method() like so:
>
>
>     if (slen <= 0){
> ........^
> %CC-I-QUESTCOMPARE, In this statement, the unsigned expression "slen" 
> is being compared with a relational operator to a constant whose value 
> is not greater than zero.  This might not be what you intended.
> at line number 85 in file D0:[CRAIG.PERL.EXT.ENCODE]Encode.xs;1

Hmm.  Let's see... slen is declared  STRLEN, which is defined as 
MEM_SIZE, which is defined as Size_t, meaning (32|64)-bit unsigned 
interger.

>     if (slen <= 0){
>         SvCUR_set(dst, 0);
>         SvPOK_only(dst);
>         goto ENCODE_END;
>     }

making slen a signed integer is easy but that make gcc complain when it 
is fed to SvPV().

> it seems like it would be a good idea to protect against that even if
> it's not supposed to happen.

I do agree with that.  The question is how...

(U8 *)"Dan the Encode Maintainer";

P.S. jhi, thanks for reminding anyway



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About