Skip to content
This repository
Browse code

Get rid of some compiler warnings

GCC had shitloads of superfluous warnings wherever List.h and Str.h were
included.. get rid of them by using #pragma GCC diagnostic at some places
in List.h and Str.h.
Also add some casts, initialize some variables for other warnings
  • Loading branch information...
commit 3202f0aa0f3764297497e3af749a2a915e6a166e 1 parent aedc76b
Daniel Gibson authored September 16, 2012
4  neo/framework/Unzip.cpp
@@ -467,7 +467,7 @@ static int unzlocal_GetCurrentFileInfoInternal (unzFile file,
467 467
 {
468 468
 	unz_s* s;
469 469
 	unz_file_info file_info;
470  
-	unz_file_info_internal file_info_internal;
  470
+	unz_file_info_internal file_info_internal = {0};
471 471
 	int err=UNZ_OK;
472 472
 	uLong uMagic;
473 473
 	long lSeek=0;
@@ -774,7 +774,7 @@ static int unzlocal_CheckCurrentFileCoherencyHeader (unz_s* s, uInt* piSizeVar,
774 774
 													uInt *psize_local_extrafield)
775 775
 {
776 776
 	uLong uMagic,uData,uFlags = 0;
777  
-	uLong size_filename;
  777
+	uLong size_filename = 0;
778 778
 	uLong size_extra_field;
779 779
 	int err=UNZ_OK;
780 780
 
10  neo/idlib/Str.h
@@ -503,6 +503,10 @@ ID_INLINE idStr::operator const char *( void ) const {
503 503
 	return c_str();
504 504
 }
505 505
 
  506
+#pragma GCC diagnostic push
  507
+// shut up GCC's stupid "warning: assuming signed overflow does not occur when assuming that
  508
+// (X - c) > X is always false [-Wstrict-overflow]"
  509
+#pragma GCC diagnostic ignored "-Wstrict-overflow"
506 510
 ID_INLINE char idStr::operator[]( int index ) const {
507 511
 	assert( ( index >= 0 ) && ( index <= len ) );
508 512
 	return data[ index ];
@@ -512,6 +516,7 @@ ID_INLINE char &idStr::operator[]( int index ) {
512 516
 	assert( ( index >= 0 ) && ( index <= len ) );
513 517
 	return data[ index ];
514 518
 }
  519
+#pragma GCC diagnostic pop
515 520
 
516 521
 ID_INLINE void idStr::operator=( const idStr &text ) {
517 522
 	int l;
@@ -912,12 +917,17 @@ ID_INLINE idStr idStr::Left( int len ) const {
912 917
 	return Mid( 0, len );
913 918
 }
914 919
 
  920
+#pragma GCC diagnostic push
  921
+// shut up GCC's stupid "warning: assuming signed overflow does not occur when assuming that
  922
+// (X - c) > X is always false [-Wstrict-overflow]"
  923
+#pragma GCC diagnostic ignored "-Wstrict-overflow"
915 924
 ID_INLINE idStr idStr::Right( int len ) const {
916 925
 	if ( len >= Length() ) {
917 926
 		return *this;
918 927
 	}
919 928
 	return Mid( Length() - len, len );
920 929
 }
  930
+#pragma GCC diagnostic pop
921 931
 
922 932
 ID_INLINE void idStr::Strip( const char c ) {
923 933
 	StripLeading( c );
11  neo/idlib/containers/List.h
@@ -356,6 +356,10 @@ Allocates memory for the amount of elements requested while keeping the contents
356 356
 Contents are copied using their = operator so that data is correnctly instantiated.
357 357
 ================
358 358
 */
  359
+#pragma GCC diagnostic push
  360
+// shut up GCC's stupid "warning: assuming signed overflow does not occur when assuming that
  361
+// (X - c) > X is always false [-Wstrict-overflow]"
  362
+#pragma GCC diagnostic ignored "-Wstrict-overflow"
359 363
 template< class type >
360 364
 ID_INLINE void idList<type>::Resize( int newsize ) {
361 365
 	type	*temp;
@@ -376,6 +380,7 @@ ID_INLINE void idList<type>::Resize( int newsize ) {
376 380
 
377 381
 	temp	= list;
378 382
 	size	= newsize;
  383
+
379 384
 	if ( size < num ) {
380 385
 		num = size;
381 386
 	}
@@ -391,6 +396,7 @@ ID_INLINE void idList<type>::Resize( int newsize ) {
391 396
 		delete[] temp;
392 397
 	}
393 398
 }
  399
+#pragma GCC diagnostic pop
394 400
 
395 401
 /*
396 402
 ================
@@ -549,6 +555,10 @@ ID_INLINE idList<type> &idList<type>::operator=( const idList<type> &other ) {
549 555
 	return *this;
550 556
 }
551 557
 
  558
+#pragma GCC diagnostic push
  559
+// shut up GCC's stupid "warning: assuming signed overflow does not occur when assuming that
  560
+// (X - c) > X is always false [-Wstrict-overflow]"
  561
+#pragma GCC diagnostic ignored "-Wstrict-overflow"
552 562
 /*
553 563
 ================
554 564
 idList<type>::operator[] const
@@ -580,6 +590,7 @@ ID_INLINE type &idList<type>::operator[]( int index ) {
580 590
 
581 591
 	return list[ index ];
582 592
 }
  593
+#pragma GCC diagnostic pop
583 594
 
584 595
 /*
585 596
 ================
3  neo/renderer/MegaTexture.cpp
@@ -363,7 +363,8 @@ void idTextureLevel::UpdateTile( int localX, int localY, int globalX, int global
363 363
 
364 364
 	if ( idMegaTexture::r_showMegaTextureLabels.GetBool() ) {
365 365
 		// put a color marker in it
366  
-		byte	color[4] = { 255 * localX / TILE_PER_LEVEL, 255 * localY / TILE_PER_LEVEL, 0, 0 };
  366
+		// localX and localY are < TILE_PER_LEVEL => that fits perfectly into a byte.
  367
+		byte	color[4] = { (byte)(255 * localX / TILE_PER_LEVEL), (byte)(255 * localY / TILE_PER_LEVEL), 0, 0 };
367 368
 		for ( int x = 0 ; x < 8 ; x++ ) {
368 369
 			for ( int y = 0 ; y < 8 ; y++ ) {
369 370
 				*(int *)&data[ ( ( y + TILE_SIZE/2 - 4 ) * TILE_SIZE + x + TILE_SIZE/2 - 4 ) * 4 ] = *(int *)color;

0 notes on commit 3202f0a

Please sign in to comment.
Something went wrong with that request. Please try again.