From: Florian Krohm Date: Mon, 29 Dec 2014 20:22:26 +0000 (+0000) Subject: Change a few prototypes to use SizeT. X-Git-Tag: svn/VALGRIND_3_11_0^2~127 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3af1a5d60c03faead614061391bc76e9bd13731e;p=thirdparty%2Fvalgrind.git Change a few prototypes to use SizeT. Also, offsetof returns a SizeT value. git-svn-id: svn://svn.valgrind.org/vex/trunk@3047 --- diff --git a/VEX/priv/main_globals.c b/VEX/priv/main_globals.c index e3d79c6b95..dbe63697df 100644 --- a/VEX/priv/main_globals.c +++ b/VEX/priv/main_globals.c @@ -50,7 +50,7 @@ __attribute__ ((noreturn)) void (*vex_failure_exit) ( void ) = NULL; /* logging output function */ -void (*vex_log_bytes) ( HChar*, Int nbytes ) = NULL; +void (*vex_log_bytes) ( const HChar*, SizeT nbytes ) = NULL; /* debug paranoia level */ Int vex_debuglevel = 0; diff --git a/VEX/priv/main_globals.h b/VEX/priv/main_globals.h index 3b16976341..eb97ec19c3 100644 --- a/VEX/priv/main_globals.h +++ b/VEX/priv/main_globals.h @@ -51,7 +51,7 @@ __attribute__ ((noreturn)) extern void (*vex_failure_exit) ( void ); /* logging output function */ -extern void (*vex_log_bytes) ( HChar*, Int nbytes ); +extern void (*vex_log_bytes) ( const HChar*, SizeT nbytes ); /* debug paranoia level */ extern Int vex_debuglevel; diff --git a/VEX/priv/main_main.c b/VEX/priv/main_main.c index b007fa1c8f..7dc538e293 100644 --- a/VEX/priv/main_main.c +++ b/VEX/priv/main_main.c @@ -111,7 +111,7 @@ void LibVEX_Init ( __attribute__ ((noreturn)) void (*failure_exit) ( void ), /* logging output function */ - void (*log_bytes) ( HChar*, Int nbytes ), + void (*log_bytes) ( const HChar*, SizeT nbytes ), /* debug paranoia level */ Int debuglevel, /* Control ... */ diff --git a/VEX/priv/main_util.c b/VEX/priv/main_util.c index 9edbe35f6b..459ddba0c7 100644 --- a/VEX/priv/main_util.c +++ b/VEX/priv/main_util.c @@ -203,7 +203,7 @@ void vexSetAllocModeTEMP_and_clear ( void ) translation of the current basic block is complete. */ -void* LibVEX_Alloc ( Int nbytes ) +void* LibVEX_Alloc ( SizeT nbytes ) { struct align { char c; @@ -229,7 +229,7 @@ void* LibVEX_Alloc ( Int nbytes ) #else HChar* curr; HChar* next; - Int ALIGN; + SizeT ALIGN; ALIGN = offsetof(struct align,x) - 1; nbytes = (nbytes + ALIGN) & ~ALIGN; curr = private_LibVEX_alloc_curr; @@ -280,9 +280,9 @@ void vpanic ( const HChar* str ) New code for vex_util.c should go above this point. */ #include -Int vex_strlen ( const HChar* str ) +SizeT vex_strlen ( const HChar* str ) { - Int i = 0; + SizeT i = 0; while (str[i] != 0) i++; return i; } @@ -299,9 +299,9 @@ Bool vex_streq ( const HChar* s1, const HChar* s2 ) } } -void vex_bzero ( void* sV, UInt n ) +void vex_bzero ( void* sV, SizeT n ) { - UInt i; + SizeT i; UChar* s = (UChar*)sV; /* No laughing, please. Just don't call this too often. Thank you for your attention. */ @@ -379,7 +379,8 @@ UInt vprintf_wrk ( void(*sink)(HChar), const HChar* saved_format; Bool longlong, ljustify, is_sizet; HChar padchar; - Int fwidth, nout, len1, len2, len3; + Int fwidth, nout, len1, len3; + SizeT len2; HChar intbuf[100]; /* big enough for a 64-bit # in base 2 */ nout = 0; @@ -413,6 +414,7 @@ UInt vprintf_wrk ( void(*sink)(HChar), } if (*format == '*') { fwidth = va_arg(ap, Int); + vassert(fwidth >= 0); format++; } else { while (*format >= '0' && *format <= '9') { diff --git a/VEX/priv/main_util.h b/VEX/priv/main_util.h index 85f13a420d..8904173814 100644 --- a/VEX/priv/main_util.h +++ b/VEX/priv/main_util.h @@ -78,8 +78,8 @@ extern UInt vex_sprintf ( HChar* buf, const HChar *format, ... ); /* String ops */ extern Bool vex_streq ( const HChar* s1, const HChar* s2 ); -extern Int vex_strlen ( const HChar* str ); -extern void vex_bzero ( void* s, UInt n ); +extern SizeT vex_strlen ( const HChar* str ); +extern void vex_bzero ( void* s, SizeT n ); /* Storage management: clear the area, and allocate from it. */ diff --git a/VEX/pub/libvex.h b/VEX/pub/libvex.h index 1f09de5a0d..bf8fad0284 100644 --- a/VEX/pub/libvex.h +++ b/VEX/pub/libvex.h @@ -453,7 +453,7 @@ void LibVEX_default_VexControl ( /*OUT*/ VexControl* vcon ); callback that you have previously specified in a call to LibVEX_Translate. The storage allocated will only stay alive until translation of the current basic block is complete. */ -extern void* LibVEX_Alloc ( Int nbytes ); +extern void* LibVEX_Alloc ( SizeT nbytes ); /* Show Vex allocation statistics. */ extern void LibVEX_ShowAllocStats ( void ); @@ -532,7 +532,7 @@ extern void LibVEX_Init ( void (*failure_exit) ( void ), /* logging output function */ - void (*log_bytes) ( HChar*, Int nbytes ), + void (*log_bytes) ( const HChar*, SizeT nbytes ), /* debug paranoia level */ Int debuglevel, diff --git a/VEX/pub/libvex_basictypes.h b/VEX/pub/libvex_basictypes.h index 09205bb3af..0bef9bb251 100644 --- a/VEX/pub/libvex_basictypes.h +++ b/VEX/pub/libvex_basictypes.h @@ -141,7 +141,7 @@ typedef unsigned long HWord; /* This is so useful it should be visible absolutely everywhere. */ #if !defined(offsetof) -# define offsetof(type,memb) ((Int)(HWord)&((type*)0)->memb) +# define offsetof(type,memb) ((SizeT)(HWord)&((type*)0)->memb) #endif /* Our definition of offsetof is giving the same result as the standard/predefined offsetof. So, we use the same name.