From: Rafael Garcia-Suarez Date: Fri, 30 Jun 2006 13:28:46 +0000 (+0000) Subject: Fix casting warnings related to snprintf/vsnprintf X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=625dac9da817af72bb35414c226dadeb2d915f21;p=p5sagit%2Fp5-mst-13.2.git Fix casting warnings related to snprintf/vsnprintf p4raw-id: //depot/perl@28459 --- diff --git a/perl.h b/perl.h index 4921b73..3a762fa 100644 --- a/perl.h +++ b/perl.h @@ -1466,7 +1466,7 @@ int sockatmark(int); #if defined(HAS_SNPRINTF) && defined(HAS_C99_VARIADIC_MACROS) && !(defined(DEBUGGING) && !defined(PERL_USE_GCC_BRACE_GROUPS)) # ifdef PERL_USE_GCC_BRACE_GROUPS -# define my_snprintf(buffer, len, ...) ({ int __len__ = snprintf(buffer, len, __VA_ARGS__); if ((len) > 0 && __len__ >= (len)) Perl_croak(aTHX_ "panic: snprintf buffer overflow"); __len__; }) +# define my_snprintf(buffer, len, ...) ({ int __len__ = snprintf(buffer, len, __VA_ARGS__); if ((len) > 0 && (Size_t)__len__ >= (len)) Perl_croak(aTHX_ "panic: snprintf buffer overflow"); __len__; }) # define PERL_MY_SNPRINTF_GUARDED # else # define my_snprintf(buffer, len, ...) snprintf(buffer, len, __VA_ARGS__) @@ -1478,7 +1478,7 @@ int sockatmark(int); #if defined(HAS_VSNPRINTF) && defined(HAS_C99_VARIADIC_MACROS) && !(defined(DEBUGGING) && !defined(PERL_USE_GCC_BRACE_GROUPS)) # ifdef PERL_USE_GCC_BRACE_GROUPS -# define my_vsnprintf(buffer, len, ...) ({ int __len__ = vsnprintf(buffer, len, __VA_ARGS__); if ((len) > 0 && __len__ >= (len)) Perl_croak(aTHX_ "panic: vsnprintf buffer overflow"); __len__; }) +# define my_vsnprintf(buffer, len, ...) ({ int __len__ = vsnprintf(buffer, len, __VA_ARGS__); if ((len) > 0 && (Size_t)__len__ >= (len)) Perl_croak(aTHX_ "panic: vsnprintf buffer overflow"); __len__; }) # define PERL_MY_VSNPRINTF_GUARDED # else # define my_vsnprintf(buffer, len, ...) vsnprintf(buffer, len, __VA_ARGS__) diff --git a/util.c b/util.c index 07dd4d4..cecec9c 100644 --- a/util.c +++ b/util.c @@ -5393,7 +5393,7 @@ Perl_my_snprintf(char *buffer, const Size_t len, const char *format, ...) #endif va_end(ap); /* vsnprintf() shows failure with >= len, vsprintf() with < 0 */ - if (retval < 0 || (len > 0 && retval >= len)) + if (retval < 0 || (len > 0 && (Size_t)retval >= len)) Perl_croak(aTHX_ "panic: my_snprintf buffer overflow"); return retval; } @@ -5430,7 +5430,7 @@ Perl_my_vsnprintf(char *buffer, const Size_t len, const char *format, va_list ap # endif #endif /* #ifdef NEED_VA_COPY */ /* vsnprintf() shows failure with >= len, vsprintf() with < 0 */ - if (retval < 0 || (len > 0 && retval >= len)) + if (retval < 0 || (len > 0 && (Size_t)retval >= len)) Perl_croak(aTHX_ "panic: my_vsnprintf buffer overflow"); return retval; }