Changeset 402 for trunk/src/stl


Ignore:
Timestamp:
06/13/15 21:51:27 (10 years ago)
Author:
epyon
Message:
  • cleanups of clang warnings (gotta love them all)
  • only nv-core for now (this will take a while for the whole source)
  • mainly C++ casts instead of C-style casts, but also a few bugs fixed!
Location:
trunk/src/stl
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/stl/assert.cc

    r396 r402  
    3131extern "C" {
    3232        extern void __assert(const char *, const char *, unsigned int, const char *)
    33                 throw() __attribute__ ((__noreturn__));
     33                __attribute__ ((__noreturn__));
    3434}
    3535#       else
    3636extern "C" {
    3737        extern void __assert_fail(const char *, const char *, unsigned int, const char *)
    38                 throw() __attribute__ ((__noreturn__));
     38                __attribute__ ((__noreturn__));
    3939}
    4040#       endif
    41 void nv_internal_assert( const char * assertion, const char * file, unsigned int line, const char * function )
     41__attribute__( ( __noreturn__ ) ) void nv_internal_assert( const char * assertion, const char * file, unsigned int line, const char * function )
    4242{
    4343#       if NV_COMPILER == NV_CLANG
  • trunk/src/stl/hash_table.cc

    r395 r402  
    4747};
    4848
    49 static const nv::uint32 s_primes_size = ( sizeof( s_primes ) / sizeof( *s_primes ) );
     49//static const nv::uint32 s_primes_size = ( sizeof( s_primes ) / sizeof( *s_primes ) );
    5050
    5151namespace nv
    5252{
    53         void* g_hash_table_empty[2] = { nullptr, (void*)uintptr_t( ~0 ) };
     53        void* g_hash_table_empty[2] = { nullptr, reinterpret_cast<void*>( uintptr_t( ~0 ) ) };
    5454}
    5555
  • trunk/src/stl/string.cc

    r395 r402  
    1515using namespace nv;
    1616
    17 static const double s_power_10[] = { 1, 10, 100, 1000, 10000, 100000, 1000000,
    18 10000000, 100000000, 1000000000 };
     17//static const double s_power_10[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 };
    1918
    2019std::string nv::slurp( const std::string& filename )
     
    4140{
    4241        char* s = str;
    43         uint32 abs = ( n < 0 ) ? (uint32)( -n ) : (uint32)( n );
     42        uint32 abs = static_cast< uint32 >( n < 0 ? -n : n );
    4443        do
    4544        {
    46                 *s++ = (char)( '0' + ( abs % 10 ) );
     45                *s++ = static_cast<char>( '0' + ( abs % 10 ) );
    4746                abs /= 10;
    4847        } while ( abs > 0 );
     
    5049        *s = '\0';
    5150        string_reverse( str, s - 1 );
    52         return (nv::size_t)( s - str );
     51        return static_cast<nv::size_t>( s - str );
    5352}
    5453
     
    5655{
    5756        char* s = str;
    58         uint64 abs = ( n < 0 ) ? (uint64)( -n ) : (uint64)( n );
     57        uint64 abs = static_cast< uint64 >( n < 0 ? -n : n );
    5958        do
    6059        {
    61                 *s++ = (char)( '0' + ( abs % 10 ) );
     60                *s++ = static_cast<char>( '0' + ( abs % 10 ) );
    6261                abs /= 10;
    6362        } while ( abs > 0 );
     
    6564        *s = '\0';
    6665        string_reverse( str, s - 1 );
    67         return (nv::size_t)( s - str );
     66        return static_cast<nv::size_t>( s - str );
    6867}
    6968
     
    7372        do
    7473        {
    75                 *s++ = (char)( '0' + ( n % 10 ) );
     74                *s++ = static_cast<char>( '0' + ( n % 10 ) );
    7675                n /= 10;
    7776        } while ( n > 0 );
    7877        *s = '\0';
    7978        string_reverse( str, s - 1 );
    80         return (nv::size_t)( s - str );
     79        return static_cast<nv::size_t>( s - str );
    8180}
    8281
     
    8685        do
    8786        {
    88                 *s++ = (char)( '0' + ( n % 10 ) );
     87                *s++ = static_cast<char>( '0' + ( n % 10 ) );
    8988                n /= 10;
    9089        } while ( n > 0 );
    9190        *s = '\0';
    9291        string_reverse( str, s - 1 );
    93         return (size_t)( s - str );
     92        return static_cast<nv::size_t>( s - str );
    9493}
    9594
     
    101100        int result = snprintf( str, 64, "%.*g", 6, n );
    102101#endif
    103         return result > 0 ? ( nv::size_t )result : 0;
     102        return static_cast<nv::size_t>( result > 0 ? result : 0 );
    104103}
    105104
     
    111110        int result = snprintf( str, 64, "%.*g", 6, n );
    112111#endif
    113         return result > 0 ? ( nv::size_t )result : 0;
     112        return static_cast<nv::size_t>( result > 0 ? result : 0 );
    114113}
    115114
    116 sint32 buffer_to_sint32( const char* str, char** end )
     115sint32 nv::buffer_to_sint32( const char* str, char** end )
    117116{
    118117        const char* s = str;
     
    131130                ++s;
    132131        }
    133         if ( end != nullptr ) *end = (char*)s;
     132        if ( end != nullptr ) *end = const_cast<char*>( s );
    134133        return positive ? result : -result;
    135134}
    136135
    137 sint64 buffer_to_sint64( const char* s, char** end )
     136sint64 nv::buffer_to_sint64( const char* s, char** end )
    138137{
    139138        while ( *s == ' ' ) ++s;
     
    151150                ++s;
    152151        }
    153         if ( end != nullptr ) *end = (char*)s;
     152        if ( end != nullptr ) *end = const_cast<char*>( s );
    154153        return positive ? result : -result;
    155154}
    156155
    157 uint32 buffer_to_uint32( const char* s, char** end )
     156uint32 nv::buffer_to_uint32( const char* s, char** end )
    158157{
    159158        while ( *s == ' ' ) ++s;
     
    161160        while ( *s >= '0' && *s <= '9' )
    162161        {
    163                 result = ( result * 10 ) + (uint32)( *s - '0' );
     162                result = ( result * 10 ) + static_cast<uint32>( *s - '0' );
    164163                ++s;
    165164        }
    166         if ( end != nullptr ) *end = (char*)s;
     165        if ( end != nullptr ) *end = const_cast<char*>( s );
    167166        return result;
    168167}
    169168
    170 uint64 buffer_to_uint64( const char* s, char** end )
     169uint64 nv::buffer_to_uint64( const char* s, char** end )
    171170{
    172171        while ( *s == ' ' ) ++s;
     
    174173        while ( *s >= '0' && *s <= '9' )
    175174        {
    176                 result = ( result * 10 ) + (uint32)( *s - '0' );
     175                result = ( result * 10 ) + static_cast<uint32>( *s - '0' );
    177176                ++s;
    178177        }
    179         if ( end != nullptr ) *end = (char*)s;
     178        if ( end != nullptr ) *end = const_cast<char*>( s );
    180179        return result;
    181180}
    182181
    183 float buffer_to_f32( const char* s, char** end )
     182float nv::buffer_to_f32( const char* s, char** end )
    184183{
    185184        return strtof( s, end );
    186185}
    187186
    188 double buffer_to_f64( const char* s, char** end )
     187double nv::buffer_to_f64( const char* s, char** end )
    189188{
    190189        return strtod( s, end );
Note: See TracChangeset for help on using the changeset viewer.