Fixed bug 1646 - Warnings from clang with -Weverything
authorSam Lantinga <slouken@libsdl.org>
Tue, 15 Nov 2016 01:30:08 -0800
changeset 10616d17dd08640a4
parent 10615 f85f1e6d857c
child 10617 346c02ff71b6
Fixed bug 1646 - Warnings from clang with -Weverything
include/begin_code.h
src/SDL_assert.c
src/test/SDL_test_fuzzer.c
src/test/SDL_test_harness.c
src/test/SDL_test_log.c
src/video/SDL_blit_N.c
src/video/x11/SDL_x11opengles.h
     1.1 --- a/include/begin_code.h	Tue Nov 15 01:24:58 2016 -0800
     1.2 +++ b/include/begin_code.h	Tue Nov 15 01:30:08 2016 -0800
     1.3 @@ -134,6 +134,16 @@
     1.4  #endif
     1.5  #endif /* SDL_FORCE_INLINE not defined */
     1.6  
     1.7 +#ifndef SDL_NORETURN
     1.8 +#if defined(__GNUC__)
     1.9 +#define SDL_NORETURN __attribute__((noreturn))
    1.10 +#elif defined(_MSC_VER)
    1.11 +#define SDL_NORETURN __declspec(noreturn)
    1.12 +#else
    1.13 +#define SDL_NORETURN
    1.14 +#endif
    1.15 +#endif /* SDL_NORETURN not defined */
    1.16 +
    1.17  /* Apparently this is needed by several Windows compilers */
    1.18  #if !defined(__MACH__)
    1.19  #ifndef NULL
     2.1 --- a/src/SDL_assert.c	Tue Nov 15 01:24:58 2016 -0800
     2.2 +++ b/src/SDL_assert.c	Tue Nov 15 01:30:08 2016 -0800
     2.3 @@ -111,7 +111,8 @@
     2.4      }
     2.5  }
     2.6  
     2.7 -static void SDL_ExitProcess(int exitcode)
     2.8 +
     2.9 +static SDL_NORETURN void SDL_ExitProcess(int exitcode)
    2.10  {
    2.11  #ifdef __WIN32__
    2.12      ExitProcess(exitcode);
    2.13 @@ -120,7 +121,8 @@
    2.14  #endif
    2.15  }
    2.16  
    2.17 -static void SDL_AbortAssertion(void)
    2.18 +
    2.19 +static SDL_NORETURN void SDL_AbortAssertion(void)
    2.20  {
    2.21      SDL_Quit();
    2.22      SDL_ExitProcess(42);
     3.1 --- a/src/test/SDL_test_fuzzer.c	Tue Nov 15 01:24:58 2016 -0800
     3.2 +++ b/src/test/SDL_test_fuzzer.c	Tue Nov 15 01:30:08 2016 -0800
     3.3 @@ -443,7 +443,7 @@
     3.4  float
     3.5  SDLTest_RandomUnitFloat()
     3.6  {
     3.7 -    return (float) SDLTest_RandomUint32() / UINT_MAX;
     3.8 +    return SDLTest_RandomUint32() / (float) UINT_MAX;
     3.9  }
    3.10  
    3.11  float
     4.1 --- a/src/test/SDL_test_harness.c	Tue Nov 15 01:24:58 2016 -0800
     4.2 +++ b/src/test/SDL_test_harness.c	Tue Nov 15 01:30:08 2016 -0800
     4.3 @@ -206,7 +206,7 @@
     4.4  /**
     4.5  * \brief Timeout handler. Aborts test run and exits harness process.
     4.6  */
     4.7 -static void
     4.8 +static SDL_NORETURN void
     4.9  SDLTest_BailOut()
    4.10  {
    4.11      SDLTest_LogError("TestCaseTimeout timer expired. Aborting test run.");
     5.1 --- a/src/test/SDL_test_log.c	Tue Nov 15 01:24:58 2016 -0800
     5.2 +++ b/src/test/SDL_test_log.c	Tue Nov 15 01:30:08 2016 -0800
     5.3 @@ -26,7 +26,9 @@
     5.4  */
     5.5  
     5.6  /* quiet windows compiler warnings */
     5.7 -#define _CRT_SECURE_NO_WARNINGS
     5.8 +#if defined(_MSC_VER)
     5.9 +# define _CRT_SECURE_NO_WARNINGS
    5.10 +#endif
    5.11  
    5.12  #include "SDL_config.h"
    5.13  
     6.1 --- a/src/video/SDL_blit_N.c	Tue Nov 15 01:24:58 2016 -0800
     6.2 +++ b/src/video/SDL_blit_N.c	Tue Nov 15 01:30:08 2016 -0800
     6.3 @@ -1113,6 +1113,7 @@
     6.4                                  (((*src)&0x0000F800)>>6)| \
     6.5                                  (((*src)&0x000000F8)>>3)); \
     6.6  }
     6.7 +#ifndef USE_DUFFS_LOOP
     6.8  #define RGB888_RGB555_TWO(dst, src) { \
     6.9      *(Uint32 *)(dst) = (((((src[HI])&0x00F80000)>>9)| \
    6.10                           (((src[HI])&0x0000F800)>>6)| \
    6.11 @@ -1121,6 +1122,7 @@
    6.12                           (((src[LO])&0x0000F800)>>6)| \
    6.13                           (((src[LO])&0x000000F8)>>3); \
    6.14  }
    6.15 +#endif
    6.16  static void
    6.17  Blit_RGB888_RGB555(SDL_BlitInfo * info)
    6.18  {
    6.19 @@ -1237,6 +1239,7 @@
    6.20                                  (((*src)&0x0000FC00)>>5)| \
    6.21                                  (((*src)&0x000000F8)>>3)); \
    6.22  }
    6.23 +#ifndef USE_DUFFS_LOOP
    6.24  #define RGB888_RGB565_TWO(dst, src) { \
    6.25      *(Uint32 *)(dst) = (((((src[HI])&0x00F80000)>>8)| \
    6.26                           (((src[HI])&0x0000FC00)>>5)| \
    6.27 @@ -1245,6 +1248,7 @@
    6.28                           (((src[LO])&0x0000FC00)>>5)| \
    6.29                           (((src[LO])&0x000000F8)>>3); \
    6.30  }
    6.31 +#endif
    6.32  static void
    6.33  Blit_RGB888_RGB565(SDL_BlitInfo * info)
    6.34  {
    6.35 @@ -2459,6 +2463,9 @@
    6.36  }
    6.37  
    6.38  /* Normal N to N optimized blitters */
    6.39 +#define NO_ALPHA   1
    6.40 +#define SET_ALPHA  2
    6.41 +#define COPY_ALPHA 4
    6.42  struct blit_table
    6.43  {
    6.44      Uint32 srcR, srcG, srcB;
    6.45 @@ -2466,8 +2473,7 @@
    6.46      Uint32 dstR, dstG, dstB;
    6.47      Uint32 blit_features;
    6.48      SDL_BlitFunc blitfunc;
    6.49 -    enum
    6.50 -    { NO_ALPHA = 1, SET_ALPHA = 2, COPY_ALPHA = 4 } alpha;
    6.51 +    Uint32 alpha; // bitwise NO_ALPHA, SET_ALPHA, COPY_ALPHA
    6.52  };
    6.53  static const struct blit_table normal_blit_1[] = {
    6.54      /* Default for 8-bit RGB source, never optimized */
     7.1 --- a/src/video/x11/SDL_x11opengles.h	Tue Nov 15 01:24:58 2016 -0800
     7.2 +++ b/src/video/x11/SDL_x11opengles.h	Tue Nov 15 01:30:08 2016 -0800
     7.3 @@ -30,6 +30,9 @@
     7.4  
     7.5  typedef struct SDL_PrivateGLESData
     7.6  {
     7.7 +  /* 1401 If the struct-declaration-list contains no named members, the behavior is undefined. */
     7.8 +  /* warning: empty struct has size 0 in C, size 1 in C++ [-Wc++-compat] */
     7.9 +  int dummy; 
    7.10  } SDL_PrivateGLESData;
    7.11  
    7.12  /* OpenGLES functions */