fix compiler warnings, round 4

All development conversation and discussion takes place here

Moderator: Moderator

Post Reply
Message
Author
lifanov
Cornac
Posts: 32
Joined: Sat Jan 14, 2012 12:53 am

fix compiler warnings, round 4

#1 Post by lifanov »

This makes core_lua.c warning-clean (on FreeBSD): -Wincompatible-pointer-types-discards-qualifiers, -Wpointer-sign
Add a couple of casts, and make some #ifdef __Apple__ match __FreeBSD__ as well.

Code: Select all

diff --git a/src/core_lua.c b/src/core_lua.c
index 08fbbdc..24b88c4 100644
--- a/src/core_lua.c
+++ b/src/core_lua.c
@@ -416,7 +416,7 @@ static int lua_key_unicode(lua_State *L)
 
 static int lua_key_set_clipboard(lua_State *L)
 {
-       char *str = luaL_checkstring(L, 1);
+       const char *str = luaL_checkstring(L, 1);
        SDL_SetClipboardText(str);
        return 0;
 }
@@ -1458,7 +1458,7 @@ int init_blank_surface()
                );
        SDL_FillRect(s, NULL, SDL_MapRGBA(s->format, 255, 255, 255, 255));
 
-       glGenTextures(1, &gl_tex_white);
+       glGenTextures(1, (GLuint *)&gl_tex_white);
        tfglBindTexture(GL_TEXTURE_2D, gl_tex_white);
        int fw, fh;
        make_texture_for_surface(s, &fw, &fh, false);
@@ -2870,7 +2870,7 @@ static int sdl_set_gamma(lua_State *L)
 static void png_write_data_fn(png_structp png_ptr, png_bytep data, png_size_t length)
 {
        luaL_Buffer *B = (luaL_Buffer*)png_get_io_ptr(png_ptr);
-       luaL_addlstring(B, data, length);
+       luaL_addlstring(B, (const char *)data, length);
 }
 static void png_output_flush_fn(png_structp png_ptr)
 {
@@ -3561,14 +3561,14 @@ static int lua_zlib_compress(lua_State *L)
        uLongf len;
        const char *data = luaL_checklstring(L, 1, (size_t*)&len);
        uLongf reslen = len * 1.1 + 12;
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(__FreeBSD__)
        unsigned
 #endif
        char *res = malloc(reslen);
        z_stream zi;
 
        zi.next_in = (
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(__FreeBSD__)
        unsigned
 #endif
        char *)data;

Post Reply