From a760ccf6d8a1f94d505b4c211ff4c30bc1d325a8 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 3 Dec 2004 15:24:34 +0000 Subject: [PATCH] silence a variety of warnings found with g++ 3.4.2 --- src/mesa/drivers/x11/xm_span.c | 12 ++++++------ src/mesa/glapi/gl_procs.py | 6 +++--- src/mesa/glapi/glapi.c | 16 ++++++++-------- src/mesa/glapi/glprocs.h | 6 +++--- src/mesa/main/blend.c | 6 ++++-- src/mesa/main/buffers.c | 10 +++++----- src/mesa/main/context.c | 2 +- src/mesa/main/image.c | 4 ++-- src/mesa/main/texcompress_fxt1.c | 18 ++++++++++-------- src/mesa/main/texstore.c | 8 ++++---- src/mesa/tnl/t_vertex_c.c | 2 +- 11 files changed, 47 insertions(+), 43 deletions(-) diff --git a/src/mesa/drivers/x11/xm_span.c b/src/mesa/drivers/x11/xm_span.c index 6e4bcb18a05..3ebca32bcfe 100644 --- a/src/mesa/drivers/x11/xm_span.c +++ b/src/mesa/drivers/x11/xm_span.c @@ -3471,8 +3471,8 @@ clip_for_xgetimage(XMesaContext xmesa, GLuint *n, GLint *x, GLint *y) XMesaBuffer source = xmesa->xm_buffer; Window rootWin = RootWindow(xmesa->display, 0); Window child; - int screenWidth = WidthOfScreen(DefaultScreenOfDisplay(xmesa->display)); - int dx, dy; + GLint screenWidth = WidthOfScreen(DefaultScreenOfDisplay(xmesa->display)); + GLint dx, dy; XTranslateCoordinates(xmesa->display, source->buffer, rootWin, *x, *y, &dx, &dy, &child); if (dx >= screenWidth) { @@ -3481,17 +3481,17 @@ clip_for_xgetimage(XMesaContext xmesa, GLuint *n, GLint *x, GLint *y) } if (dx < 0) { /* clipped on left */ - int clip = -dx; - if (clip >= *n) + GLint clip = -dx; + if (clip >= (GLint) *n) return -1; /* totally clipped on left */ *x += clip; *n -= clip; dx = 0; return clip; } - if (dx + *n > screenWidth) { + if ((GLint) (dx + *n) > screenWidth) { /* clipped on right */ - int clip = dx + *n - screenWidth; + GLint clip = dx + *n - screenWidth; *n -= clip; } return 0; diff --git a/src/mesa/glapi/gl_procs.py b/src/mesa/glapi/gl_procs.py index b8a6253eff4..f9ce8e2da1b 100644 --- a/src/mesa/glapi/gl_procs.py +++ b/src/mesa/glapi/gl_procs.py @@ -50,11 +50,11 @@ class PrintGlProcs(gl_XML.FilterGLAPISpecBase): print ' */' print '' print 'typedef struct {' - print ' int Name_offset;' + print ' GLint Name_offset;' print '#ifdef NEED_FUNCTION_POINTER' print ' _glapi_proc Address;' print '#endif' - print ' unsigned int Offset;' + print ' GLuint Offset;' print '} glprocs_table_t;' print '' print '#ifdef NEED_FUNCTION_POINTER' @@ -132,7 +132,7 @@ class PrintGlProcs(gl_XML.FilterGLAPISpecBase): base_offset += len(self.functions[k].name) + 3 - print ' NAME_FUNC_OFFSET( -1, NULL, -1 )' + print ' NAME_FUNC_OFFSET( -1, NULL, 0 )' print '};' return diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c index 621c15a33ba..f395d1879a5 100644 --- a/src/mesa/glapi/glapi.c +++ b/src/mesa/glapi/glapi.c @@ -115,7 +115,7 @@ warn(void) #define TABLE_ENTRY(name) (_glapi_proc) NoOp##name -static int NoOpUnused(void) +static GLint NoOpUnused(void) { if (warn()) { warning_func(NULL, "GL User Error: calling extension function without a current context\n"); @@ -172,7 +172,7 @@ static _glthread_TSD ContextTSD; /**< Per-thread context pointer */ #define TABLE_ENTRY(name) (_glapi_proc) gl##name -static int glUnused(void) +static GLint glUnused(void) { return 0; } @@ -467,9 +467,9 @@ _glapi_get_override_dispatch(int layer) static const glprocs_table_t * find_entry( const char * n ) { - unsigned i; + GLuint i; - for ( i = 0 ; static_functions[i].Name_offset >= 0 ; i++ ) { + for (i = 0; static_functions[i].Name_offset >= 0; i++) { const char * test_name; test_name = gl_string_table + static_functions[i].Name_offset; @@ -549,9 +549,9 @@ get_static_proc_address(const char *funcName) static const char * get_static_proc_name( GLuint offset ) { - unsigned i; + GLuint i; - for ( i = 0 ; static_functions[i].Name_offset >= 0 ; i++ ) { + for (i = 0; static_functions[i].Name_offset >= 0; i++) { if (static_functions[i].Offset == offset) { return gl_string_table + static_functions[i].Name_offset; } @@ -1014,7 +1014,7 @@ _glapi_check_table(const struct _glapi_table *table) GLuint offset = (pointParameterivFunc - (char *) table) / sizeof(void *); assert(pointParameterivOffset == _gloffset_PointParameterivNV); assert(pointParameterivOffset == offset); - assert(_glapi_get_proc_address("glPointParameterivNV") == &glPointParameterivNV); + assert(_glapi_get_proc_address("glPointParameterivNV") == (_glapi_proc) &glPointParameterivNV); } { GLuint setFenceOffset = _glapi_get_proc_offset("glSetFenceNV"); @@ -1022,7 +1022,7 @@ _glapi_check_table(const struct _glapi_table *table) GLuint offset = (setFenceFunc - (char *) table) / sizeof(void *); assert(setFenceOffset == _gloffset_SetFenceNV); assert(setFenceOffset == offset); - assert(_glapi_get_proc_address("glSetFenceNV") == &glSetFenceNV); + assert(_glapi_get_proc_address("glSetFenceNV") == (_glapi_proc) &glSetFenceNV); } #else (void) table; diff --git a/src/mesa/glapi/glprocs.h b/src/mesa/glapi/glprocs.h index 02cf81abcd7..9e510d2695e 100644 --- a/src/mesa/glapi/glprocs.h +++ b/src/mesa/glapi/glprocs.h @@ -31,11 +31,11 @@ */ typedef struct { - int Name_offset; + GLint Name_offset; #ifdef NEED_FUNCTION_POINTER _glapi_proc Address; #endif - unsigned int Offset; + GLuint Offset; } glprocs_table_t; #ifdef NEED_FUNCTION_POINTER @@ -1969,7 +1969,7 @@ static const glprocs_table_t static_functions[] = { NAME_FUNC_OFFSET( 17136, glBlendFuncSeparateINGR, _gloffset_BlendFuncSeparateEXT ), NAME_FUNC_OFFSET( 17160, glPointParameterfSGIS, _gloffset_PointParameterfEXT ), NAME_FUNC_OFFSET( 17182, glPointParameterfvSGIS, _gloffset_PointParameterfvEXT ), - NAME_FUNC_OFFSET( -1, NULL, -1 ) + NAME_FUNC_OFFSET( -1, NULL, 0 ) }; #undef NAME_FUNC_OFFSET diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c index 0257528581b..8fadef61b48 100644 --- a/src/mesa/main/blend.c +++ b/src/mesa/main/blend.c @@ -219,7 +219,7 @@ static GLboolean _mesa_validate_blend_equation( GLcontext *ctx, GLenum mode, GLboolean is_separate ) { - switch (mode) { + switch (mode) { case GL_FUNC_ADD: break; case GL_MIN: @@ -286,6 +286,7 @@ _mesa_BlendEquation( GLenum mode ) (*ctx->Driver.BlendEquationSeparate)( ctx, mode, mode ); } + void GLAPIENTRY _mesa_BlendEquationSeparateEXT( GLenum modeRGB, GLenum modeA ) { @@ -527,6 +528,7 @@ _mesa_ColorMask( GLboolean red, GLboolean green, ctx->Driver.ColorMask( ctx, red, green, blue, alpha ); } + /**********************************************************************/ /** \name Initialization */ /*@{*/ @@ -542,7 +544,7 @@ _mesa_ColorMask( GLboolean red, GLboolean green, void _mesa_init_color( GLcontext * ctx ) { /* Color buffer group */ - ctx->Color.IndexMask = 0xffffffff; + ctx->Color.IndexMask = ~0u; ctx->Color.ColorMask[0] = 0xff; ctx->Color.ColorMask[1] = 0xff; ctx->Color.ColorMask[2] = 0xff; diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index 35e03d7eb5c..3415a2b9b58 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -173,7 +173,7 @@ static GLuint supported_buffer_bitmask(const GLcontext *ctx) { GLuint mask = DD_FRONT_LEFT_BIT; /* always have this */ - GLuint i; + GLint i; if (ctx->Visual.stereoMode) { mask |= DD_FRONT_RIGHT_BIT; @@ -305,7 +305,7 @@ _mesa_DrawBuffer( GLenum mode ) * Do error checking and compute the _DrawDestMask bitfield. */ destMask = draw_buffer_enum_to_bitmask(mode); - if (destMask == ~0) { + if (destMask == ~0u) { _mesa_error(ctx, GL_INVALID_ENUM, "glDrawBuffer(mode)"); return; } @@ -342,7 +342,7 @@ _mesa_DrawBuffersARB(GLsizei n, const GLenum *buffers) GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - if (n < 1 || n > ctx->Const.MaxDrawBuffers) { + if (n < 1 || n > (GLsizei) ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glDrawBuffersARB(n)" ); return; } @@ -351,7 +351,7 @@ _mesa_DrawBuffersARB(GLsizei n, const GLenum *buffers) usedBufferMask = 0; for (i = 0; i < n; i++) { GLuint destMask = draw_buffer_enum_to_bitmask(buffers[i]); - if (destMask == ~0) { + if (destMask == ~0u ) { _mesa_error(ctx, GL_INVALID_ENUM, "glDrawBuffersARB(buffer)"); return; } @@ -406,7 +406,7 @@ _mesa_ReadBuffer( GLenum mode ) _mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(mode)); srcMask = read_buffer_enum_to_bitmask(mode); - if (srcMask == ~0) { + if (srcMask == ~0u) { _mesa_error(ctx, GL_INVALID_ENUM, "glReadBuffer(mode)"); return; } diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 2423b68ddc7..3116cb95a1f 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1424,7 +1424,7 @@ alloc_dispatch_table(void) (struct _glapi_table *) _mesa_malloc(numEntries * sizeof(_glapi_proc)); if (table) { _glapi_proc *entry = (_glapi_proc *) table; - GLuint i; + GLint i; for (i = 0; i < numEntries; i++) { entry[i] = (_glapi_proc) generic_nop; } diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 5e65bf6f8ec..12f8352c2d2 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -4177,7 +4177,7 @@ _mesa_clip_readpixels(const GLcontext *ctx, *srcX = 0; } /* right clipping */ - if (*srcX + *width > buffer->Width) + if (*srcX + *width > (GLsizei) buffer->Width) *width -= (*srcX + *width - buffer->Width); if (*width <= 0) @@ -4190,7 +4190,7 @@ _mesa_clip_readpixels(const GLcontext *ctx, *srcY = 0; } /* top clipping */ - if (*srcY + *height > buffer->Height) + if (*srcY + *height > (GLsizei) buffer->Height) *height -= (*srcY + *height - buffer->Height); if (*height <= 0) diff --git a/src/mesa/main/texcompress_fxt1.c b/src/mesa/main/texcompress_fxt1.c index b3707fcffcc..29392514076 100644 --- a/src/mesa/main/texcompress_fxt1.c +++ b/src/mesa/main/texcompress_fxt1.c @@ -287,7 +287,7 @@ const struct gl_texture_format _mesa_texformat_rgba_fxt1 = { #define ISTBLACK(v) (*((unsigned long *)(v)) == 0) -#ifdef __GNUC__ +#if defined(__GNUC__) && !defined(__cplusplus) #define FX64_NATIVE 1 @@ -1007,7 +1007,7 @@ fxt1_quantize_MIXED1 (unsigned long *cc, /* left microtile */ if (maxColL == -1) { /* all transparent black */ - cc[0] = -1; + cc[0] = ~0ul; for (i = 0; i < n_comp; i++) { vec[0][i] = 0; vec[1][i] = 0; @@ -1041,7 +1041,7 @@ fxt1_quantize_MIXED1 (unsigned long *cc, /* right microtile */ if (maxColR == -1) { /* all transparent black */ - cc[1] = -1; + cc[1] = ~0ul; for (i = 0; i < n_comp; i++) { vec[2][i] = 0; vec[3][i] = 0; @@ -1328,7 +1328,7 @@ fxt1_quantize (unsigned long *cc, const unsigned char *lines[], int comps) if (trualpha) { fxt1_quantize_ALPHA1(cc, input); } else if (l == 0) { - cc[0] = cc[1] = cc[2] = -1; + cc[0] = cc[1] = cc[2] = ~0ul; cc[3] = 0; } else if (l < N_TEXELS) { fxt1_quantize_MIXED1(cc, input); @@ -1349,23 +1349,25 @@ fxt1_encode (unsigned int width, unsigned int height, int comps, { unsigned int x, y; const unsigned char *data; - unsigned long *encoded = dest; + unsigned long *encoded = (unsigned long *) dest; unsigned char *newSource = NULL; /* Replicate image if width is not M8 or height is not M4 */ if ((width & 7) | (height & 3)) { int newWidth = (width + 7) & ~7; int newHeight = (height + 3) & ~3; - newSource = malloc(comps * newWidth * newHeight * sizeof(unsigned char *)); + newSource = (unsigned char *) + _mesa_malloc(comps * newWidth * newHeight * sizeof(unsigned char *)); _mesa_upscale_teximage2d(width, height, newWidth, newHeight, - comps, source, srcRowStride, newSource); + comps, (const GLchan *) source, + srcRowStride, newSource); source = newSource; width = newWidth; height = newHeight; srcRowStride = comps * newWidth; } - data = source; + data = (const unsigned char *) source; destRowStride = (destRowStride - width * 2) / 4; for (y = 0; y < height; y += 4) { unsigned int offs = 0 + (y + 0) * srcRowStride; diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index ef0a14e5788..dd1fcef0596 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -1832,8 +1832,8 @@ validate_pbo_teximage(GLcontext *ctx, GLuint dimensions, return NULL; } - buf = ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - GL_READ_ONLY_ARB, unpack->BufferObj); + buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, + GL_READ_ONLY_ARB, unpack->BufferObj); if (!buf) { _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(PBO is mapped"); return NULL; @@ -1869,8 +1869,8 @@ validate_pbo_compressed_teximage(GLcontext *ctx, return NULL; } - buf = ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - GL_READ_ONLY_ARB, packing->BufferObj); + buf = (GLubyte*) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, + GL_READ_ONLY_ARB, packing->BufferObj); if (!buf) { _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(PBO is mapped"); return NULL; diff --git a/src/mesa/tnl/t_vertex_c.c b/src/mesa/tnl/t_vertex_c.c index 51090260372..a901aed14c5 100644 --- a/src/mesa/tnl/t_vertex_c.c +++ b/src/mesa/tnl/t_vertex_c.c @@ -255,5 +255,5 @@ void _tnl_init_c_codegen( struct tnl_clipspace_codegen *p ) make_empty_list(&p->codegen_list); p->buf_size = 2048; - p->buf = MALLOC(p->buf_size); + p->buf = (char *) MALLOC(p->buf_size); } -- 2.11.0