fixes for C++ warnings/errors

This commit is contained in:
Brian
2007-01-23 11:46:02 -07:00
parent d46093b8d5
commit 18d1fdebeb
16 changed files with 51 additions and 40 deletions

View File

@@ -241,7 +241,7 @@ glXGetCurrentContext(void)
#if defined(GLX_USE_TLS) #if defined(GLX_USE_TLS)
return CurrentContext; return CurrentContext;
#elif defined(THREADS) #elif defined(THREADS)
return _glthread_GetTSD(&ContextTSD); return (GLXContext) _glthread_GetTSD(&ContextTSD);
#else #else
return CurrentContext; return CurrentContext;
#endif #endif

View File

@@ -472,8 +472,8 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
_mesa_free_colortable_data(table); _mesa_free_colortable_data(table);
if (width > 0) { if (width > 0) {
table->TableF = _mesa_malloc(comps * width * sizeof(GLfloat)); table->TableF = (GLfloat *) _mesa_malloc(comps * width * sizeof(GLfloat));
table->TableUB = _mesa_malloc(comps * width * sizeof(GLubyte)); table->TableUB = (GLubyte *) _mesa_malloc(comps * width * sizeof(GLubyte));
if (!table->TableF || !table->TableUB) { if (!table->TableF || !table->TableUB) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glColorTable"); _mesa_error(ctx, GL_OUT_OF_MEMORY, "glColorTable");

View File

@@ -4476,7 +4476,7 @@ save_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
if (count > 0) { if (count > 0) {
unsigned i; GLint i;
const GLfloat * p = params; const GLfloat * p = params;
for (i = 0 ; i < count ; i++) { for (i = 0 ; i < count ; i++) {
@@ -4710,7 +4710,7 @@ save_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
if (count > 0) { if (count > 0) {
unsigned i; GLint i;
const GLfloat * p = params; const GLfloat * p = params;
for (i = 0 ; i < count ; i++) { for (i = 0 ; i < count ; i++) {

View File

@@ -91,7 +91,7 @@ _mesa_dlopen(const char *libname, int flags)
return dlopen(libname, flags); return dlopen(libname, flags);
#endif #endif
#else #else
return (GenericFunc) NULL; return NULL;
#endif /* USE_EXTERNAL_DXTN_LIB */ #endif /* USE_EXTERNAL_DXTN_LIB */
} }

View File

@@ -1184,13 +1184,14 @@ static void cache_item( struct texenvprog_cache *cache,
const struct state_key *key, const struct state_key *key,
void *data ) void *data )
{ {
struct texenvprog_cache_item *c = MALLOC(sizeof(*c)); struct texenvprog_cache_item *c
= (struct texenvprog_cache_item *) MALLOC(sizeof(*c));
c->hash = hash; c->hash = hash;
c->key = _mesa_malloc(sizeof(*key)); c->key = _mesa_malloc(sizeof(*key));
memcpy(c->key, key, sizeof(*key)); memcpy(c->key, key, sizeof(*key));
c->data = data; c->data = (struct gl_fragment_program *) data;
if (cache->n_items > cache->size * 1.5) { if (cache->n_items > cache->size * 1.5) {
if (cache->size < 1000) if (cache->size < 1000)

View File

@@ -699,7 +699,7 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures)
= _mesa_lookup_texture(ctx, textures[i]); = _mesa_lookup_texture(ctx, textures[i]);
if (delObj) { if (delObj) {
GLboolean delete; GLboolean deleted;
_mesa_lock_texture(ctx, delObj); _mesa_lock_texture(ctx, delObj);
@@ -728,14 +728,14 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures)
* XXX all RefCount accesses should be protected by a mutex. * XXX all RefCount accesses should be protected by a mutex.
*/ */
delObj->RefCount--; delObj->RefCount--;
delete = (delObj->RefCount == 0); deleted = (delObj->RefCount == 0);
_mesa_unlock_texture(ctx, delObj); _mesa_unlock_texture(ctx, delObj);
/* We know that refcount went to zero above, so this is /* We know that refcount went to zero above, so this is
* the only pointer left to delObj, so we don't have to * the only pointer left to delObj, so we don't have to
* worry about locking any more: * worry about locking any more:
*/ */
if (delete) { if (deleted) {
ASSERT(delObj->Name != 0); /* Never delete default tex objs */ ASSERT(delObj->Name != 0); /* Never delete default tex objs */
ASSERT(ctx->Driver.DeleteTexture); ASSERT(ctx->Driver.DeleteTexture);
(*ctx->Driver.DeleteTexture)(ctx, delObj); (*ctx->Driver.DeleteTexture)(ctx, delObj);

View File

@@ -312,7 +312,7 @@ _mesa_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
const GLfloat *params) const GLfloat *params)
{ {
GET_CURRENT_CONTEXT(ctx); GET_CURRENT_CONTEXT(ctx);
unsigned i; GLint i;
GLfloat * dest; GLfloat * dest;
ASSERT_OUTSIDE_BEGIN_END(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx);
@@ -464,7 +464,7 @@ _mesa_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
{ {
GET_CURRENT_CONTEXT(ctx); GET_CURRENT_CONTEXT(ctx);
struct gl_program *prog; struct gl_program *prog;
unsigned i; GLint i;
ASSERT_OUTSIDE_BEGIN_END(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx);
FLUSH_VERTICES(ctx, _NEW_PROGRAM); FLUSH_VERTICES(ctx, _NEW_PROGRAM);

View File

@@ -1810,7 +1810,7 @@ _mesa_print_program(const struct gl_program *prog)
void void
_mesa_print_program_parameters(GLcontext *ctx, const struct gl_program *prog) _mesa_print_program_parameters(GLcontext *ctx, const struct gl_program *prog)
{ {
GLint i; GLuint i;
_mesa_printf("NumInstructions=%d\n", prog->NumInstructions); _mesa_printf("NumInstructions=%d\n", prog->NumInstructions);
_mesa_printf("NumTemporaries=%d\n", prog->NumTemporaries); _mesa_printf("NumTemporaries=%d\n", prog->NumTemporaries);

View File

@@ -328,7 +328,7 @@ static GLvoid
ensure_infolog_created(slang_info_log ** infolog) ensure_infolog_created(slang_info_log ** infolog)
{ {
if (*infolog == NULL) { if (*infolog == NULL) {
*infolog = slang_alloc_malloc(sizeof(slang_info_log)); *infolog = (slang_info_log *) slang_alloc_malloc(sizeof(slang_info_log));
if (*infolog == NULL) if (*infolog == NULL)
return; return;
slang_info_log_construct(*infolog); slang_info_log_construct(*infolog);

View File

@@ -860,8 +860,8 @@ fast_copy_pixels(GLcontext *ctx,
} }
/* clipping not supported */ /* clipping not supported */
if (srcX < 0 || srcX + width > srcFb->Width || if (srcX < 0 || srcX + width > (GLint) srcFb->Width ||
srcY < 0 || srcY + height > srcFb->Height || srcY < 0 || srcY + height > (GLint) srcFb->Height ||
dstX < dstFb->_Xmin || dstX + width > dstFb->_Xmax || dstX < dstFb->_Xmin || dstX + width > dstFb->_Xmax ||
dstY < dstFb->_Ymin || dstY + height > dstFb->_Ymax) { dstY < dstFb->_Ymin || dstY + height > dstFb->_Ymax) {
return GL_FALSE; return GL_FALSE;

View File

@@ -1289,7 +1289,7 @@ _swrast_read_depth_span_uint( GLcontext *ctx, struct gl_renderbuffer *rb,
GLint dx = -x; GLint dx = -x;
GLint i; GLint i;
for (i = 0; i < dx; i++) for (i = 0; i < dx; i++)
depth[i] = 0.0; depth[i] = 0;
x = 0; x = 0;
n -= dx; n -= dx;
depth += dx; depth += dx;
@@ -1298,7 +1298,7 @@ _swrast_read_depth_span_uint( GLcontext *ctx, struct gl_renderbuffer *rb,
GLint dx = x + n - (GLint) rb->Width; GLint dx = x + n - (GLint) rb->Width;
GLint i; GLint i;
for (i = 0; i < dx; i++) for (i = 0; i < dx; i++)
depth[n - i - 1] = 0.0; depth[n - i - 1] = 0;
n -= dx; n -= dx;
} }
if (n <= 0) { if (n <= 0) {

View File

@@ -110,8 +110,9 @@ fast_draw_rgba_pixels(GLcontext *ctx, GLint x, GLint y,
*/ */
if (format == GL_RGBA && type == rbType) { if (format == GL_RGBA && type == rbType) {
const GLubyte *src = _mesa_image_address2d(&unpack, pixels, width, const GLubyte *src
height, format, type, 0, 0); = (const GLubyte *) _mesa_image_address2d(&unpack, pixels, width,
height, format, type, 0, 0);
const GLint srcStride = _mesa_image_row_stride(&unpack, width, const GLint srcStride = _mesa_image_row_stride(&unpack, width,
format, type); format, type);
if (simpleZoom) { if (simpleZoom) {
@@ -139,8 +140,9 @@ fast_draw_rgba_pixels(GLcontext *ctx, GLint x, GLint y,
} }
if (format == GL_RGB && type == rbType) { if (format == GL_RGB && type == rbType) {
const GLubyte *src = _mesa_image_address2d(&unpack, pixels, width, const GLubyte *src
height, format, type, 0, 0); = (const GLubyte *) _mesa_image_address2d(&unpack, pixels, width,
height, format, type, 0, 0);
const GLint srcStride = _mesa_image_row_stride(&unpack, width, const GLint srcStride = _mesa_image_row_stride(&unpack, width,
format, type); format, type);
if (simpleZoom) { if (simpleZoom) {
@@ -640,8 +642,10 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
/* if the span is wider than MAX_WIDTH we have to do it in chunks */ /* if the span is wider than MAX_WIDTH we have to do it in chunks */
while (skipPixels < width) { while (skipPixels < width) {
const GLint spanWidth = MIN2(width - skipPixels, MAX_WIDTH); const GLint spanWidth = MIN2(width - skipPixels, MAX_WIDTH);
const GLubyte *source = _mesa_image_address2d(unpack, pixels, const GLubyte *source
width, height, format, type, 0, skipPixels); = (const GLubyte *) _mesa_image_address2d(unpack, pixels,
width, height, format,
type, 0, skipPixels);
GLint row; GLint row;
for (row = 0; row < height; row++) { for (row = 0; row < height; row++) {

View File

@@ -94,8 +94,8 @@ read_depth_pixels( GLcontext *ctx,
/* clipping should have been done already */ /* clipping should have been done already */
ASSERT(x >= 0); ASSERT(x >= 0);
ASSERT(y >= 0); ASSERT(y >= 0);
ASSERT(x + width <= rb->Width); ASSERT(x + width <= (GLint) rb->Width);
ASSERT(y + height <= rb->Height); ASSERT(y + height <= (GLint) rb->Height);
/* width should never be > MAX_WIDTH since we did clipping earlier */ /* width should never be > MAX_WIDTH since we did clipping earlier */
ASSERT(width <= MAX_WIDTH); ASSERT(width <= MAX_WIDTH);
@@ -210,8 +210,8 @@ fast_read_rgba_pixels( GLcontext *ctx,
ASSERT(rb->_BaseFormat == GL_RGBA || rb->_BaseFormat == GL_RGB); ASSERT(rb->_BaseFormat == GL_RGBA || rb->_BaseFormat == GL_RGB);
/* clipping should have already been done */ /* clipping should have already been done */
ASSERT(x + width <= rb->Width); ASSERT(x + width <= (GLint) rb->Width);
ASSERT(y + height <= rb->Height); ASSERT(y + height <= (GLint) rb->Height);
/* check for things we can't handle here */ /* check for things we can't handle here */
if (transferOps || if (transferOps ||
@@ -223,8 +223,9 @@ fast_read_rgba_pixels( GLcontext *ctx,
if (format == GL_RGBA && rb->DataType == type) { if (format == GL_RGBA && rb->DataType == type) {
const GLint dstStride = _mesa_image_row_stride(packing, width, const GLint dstStride = _mesa_image_row_stride(packing, width,
format, type); format, type);
GLubyte *dest = _mesa_image_address2d(packing, pixels, width, height, GLubyte *dest
format, type, 0, 0); = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height,
format, type, 0, 0);
GLint row; GLint row;
ASSERT(rb->GetRow); ASSERT(rb->GetRow);
for (row = 0; row < height; row++) { for (row = 0; row < height; row++) {
@@ -239,8 +240,9 @@ fast_read_rgba_pixels( GLcontext *ctx,
type == GL_UNSIGNED_BYTE) { type == GL_UNSIGNED_BYTE) {
const GLint dstStride = _mesa_image_row_stride(packing, width, const GLint dstStride = _mesa_image_row_stride(packing, width,
format, type); format, type);
GLubyte *dest = _mesa_image_address2d(packing, pixels, width, height, GLubyte *dest
format, type, 0, 0); = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height,
format, type, 0, 0);
GLint row; GLint row;
ASSERT(rb->GetRow); ASSERT(rb->GetRow);
for (row = 0; row < height; row++) { for (row = 0; row < height; row++) {
@@ -396,8 +398,9 @@ read_rgba_pixels( GLcontext *ctx,
= _mesa_image_row_stride(packing, width, format, type); = _mesa_image_row_stride(packing, width, format, type);
GLfloat (*rgba)[4] = swrast->SpanArrays->color.sz4.rgba; GLfloat (*rgba)[4] = swrast->SpanArrays->color.sz4.rgba;
GLint row; GLint row;
GLubyte *dst = _mesa_image_address2d(packing, pixels, width, height, GLubyte *dst
format, type, 0, 0); = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height,
format, type, 0, 0);
for (row = 0; row < height; row++, y++) { for (row = 0; row < height; row++, y++) {

View File

@@ -1814,7 +1814,9 @@ _swrast_get_values(GLcontext *ctx, struct gl_renderbuffer *rb,
GLuint i, inCount = 0, inStart = 0; GLuint i, inCount = 0, inStart = 0;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
if (x[i] >= 0 && y[i] >= 0 && x[i] < rb->Width && y[i] < rb->Height) { if (x[i] >= 0 && y[i] >= 0 &&
x[i] < (GLint) rb->Width &&
y[i] < (GLint) rb->Height) {
/* inside */ /* inside */
if (inCount == 0) if (inCount == 0)
inStart = i; inStart = i;
@@ -1848,10 +1850,10 @@ _swrast_put_row(GLcontext *ctx, struct gl_renderbuffer *rb,
{ {
GLint skip = 0; GLint skip = 0;
if (y < 0 || y >= rb->Height) if (y < 0 || (GLint) y >= rb->Height)
return; /* above or below */ return; /* above or below */
if (x + (GLint) count <= 0 || x >= rb->Width) if (x + (GLint) count <= 0 || x >= (GLint) rb->Width)
return; /* entirely left or right */ return; /* entirely left or right */
if (x + count > rb->Width) { if (x + count > rb->Width) {

View File

@@ -298,7 +298,7 @@ _tnl_DrawRangeElements(GLenum mode,
#ifdef DEBUG #ifdef DEBUG
/* check that array indices really fall inside [start, end] range */ /* check that array indices really fall inside [start, end] range */
{ {
GLuint i; GLint i;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
if (ui_indices[i] < start || ui_indices[i] > end) { if (ui_indices[i] < start || ui_indices[i] > end) {
_mesa_warning(ctx, "Invalid array index in " _mesa_warning(ctx, "Invalid array index in "

View File

@@ -1056,7 +1056,7 @@ static void compile_vertex_program( struct gl_vertex_program *program,
{ {
struct compilation cp; struct compilation cp;
struct tnl_compiled_program *p = CALLOC_STRUCT(tnl_compiled_program); struct tnl_compiled_program *p = CALLOC_STRUCT(tnl_compiled_program);
GLuint i; GLint i;
if (program->TnlData) if (program->TnlData)
free_tnl_data( program ); free_tnl_data( program );
@@ -1290,6 +1290,7 @@ run_arb_vertex_program(GLcontext *ctx, struct tnl_pipeline_stage *stage)
call_func( p, m ); call_func( p, m );
} }
else { else {
GLint j;
for (j = 0; j < p->nr_instructions; j++) { for (j = 0; j < p->nr_instructions; j++) {
union instruction inst = p->instructions[j]; union instruction inst = p->instructions[j];
opcode_func[inst.alu.opcode]( m, inst ); opcode_func[inst.alu.opcode]( m, inst );