]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - libs/splines/q_shared.cpp
Remove -Wno-sign-compare
[xonotic/netradiant.git] / libs / splines / q_shared.cpp
index 8a93df1eaad5753e8f00f1ea4d9c3514fd011bad..1df4dfcd2c5de67676a444b0ddd2c2b9528f0d84 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   Copyright (C) 1999-2007 id Software, Inc. and contributors.
+   Copyright (C) 1999-2006 Id Software, Inc. and contributors.
    For a list of contributors, see the accompanying CONTRIBUTORS file.
 
    This file is part of GtkRadiant.
@@ -546,7 +546,7 @@ char* Q_strrchr( const char* string, int c ){
    Safe strncpy that ensures a trailing zero
    =============
  */
-void Q_strncpyz( char *dest, const char *src, int destsize ) {
+void Q_strncpyz( char *dest, const char *src, std::size_t destsize ) {
        if ( !src ) {
                Com_Error( ERR_FATAL, "Q_strncpyz: NULL src" );
        }
@@ -633,10 +633,8 @@ char *Q_strupr( char *s1 ) {
 
 
 // never goes past bounds or leaves without a terminating 0
-void Q_strcat( char *dest, int size, const char *src ) {
-       int l1;
-
-       l1 = strlen( dest );
+void Q_strcat( char *dest, std::size_t size, const char *src ) {
+       auto l1 = strlen( dest );
        if ( l1 >= size ) {
                Com_Error( ERR_FATAL, "Q_strcat: already overflowed" );
        }
@@ -689,14 +687,17 @@ char *Q_CleanStr( char *string ) {
 }
 
 
-void QDECL Com_sprintf( char *dest, int size, const char *fmt, ... ) {
-       int len;
+void QDECL Com_sprintf( char *dest, std::size_t size, const char *fmt, ... ) {
        va_list argptr;
        char bigbuffer[32000];      // big, but small enough to fit in PPC stack
 
        va_start( argptr,fmt );
-       len = vsprintf( bigbuffer,fmt,argptr );
+       int ret = vsprintf( bigbuffer,fmt,argptr );
        va_end( argptr );
+       if ( ret < 0 ) {
+               Com_Error(ERR_FATAL, "Com_sprintf: vsprintf failed");
+       }
+       auto len = static_cast<size_t>(ret);
        if ( len >= sizeof( bigbuffer ) ) {
                Com_Error( ERR_FATAL, "Com_sprintf: overflowed bigbuffer" );
        }
@@ -716,7 +717,7 @@ void QDECL Com_sprintf( char *dest, int size, const char *fmt, ... ) {
    FIXME: make this buffer size safe someday
    ============
  */
-char    * QDECL va( char *format, ... ) {
+char *QDECL va( const char *format, ... ) {
        va_list argptr;
        static char string[2][32000];       // in case va is called by nested functions
        static int index = 0;
@@ -750,7 +751,7 @@ char    * QDECL va( char *format, ... ) {
    FIXME: overflow check?
    ===============
  */
-char *Info_ValueForKey( const char *s, const char *key ) {
+const char *Info_ValueForKey( const char *s, const char *key ) {
        char pkey[MAX_INFO_KEY];
        static char value[2][MAX_INFO_VALUE];   // use two buffers so compares
                                                // work without stomping on each other