Skip to content
Permalink
Browse files
Some static analysis fixes from Clang 4.0.
  • Loading branch information
icculus committed Aug 3, 2012
1 parent 353d7df commit 7a0dc963d1bab95ca21ecd54fe54f86d649fd85a
Showing with 42 additions and 23 deletions.
  1. +2 −2 misc/lemon.c
  2. +23 −14 mojoshader.c
  3. +2 −1 mojoshader_common.c
  4. +12 −4 mojoshader_compiler.c
  5. +3 −2 mojoshader_opengl.c
@@ -2821,7 +2821,7 @@ PRIVATE FILE *file_open(
*/
if(( *mode=='w' ) && (strcmp(suffix, ".out") != 0)){
const char **ptr = (const char **)
realloc(made_files, sizeof (const char **) * (made_files_count + 1));
realloc(made_files, sizeof (const char *) * (made_files_count + 1));
const char *fname = Strsafe(lemp->outname);
if ((ptr == NULL) || (fname == NULL)) {
free(ptr);
@@ -3460,7 +3460,7 @@ void print_stack_union(
int *plineno, /* Pointer to the line number */
int mhflag /* True if generating makeheaders output */
){
int lineno = *plineno; /* The line number of the output */
int lineno = 0; /* The line number of the output */
char **types; /* A hash table of datatypes */
int arraysize; /* Size of the "types" array */
int maxdtlength; /* Maximum length of any ".datatype" field. */
@@ -7008,11 +7008,14 @@ static void state_DEF(Context *ctx)
else
{
ConstantsList *item = alloc_constant_listitem(ctx);
item->constant.index = regnum;
item->constant.type = MOJOSHADER_UNIFORM_FLOAT;
memcpy(item->constant.value.f, ctx->dwords,
sizeof (item->constant.value.f));
set_defined_register(ctx, regtype, regnum);
if (item != NULL)
{
item->constant.index = regnum;
item->constant.type = MOJOSHADER_UNIFORM_FLOAT;
memcpy(item->constant.value.f, ctx->dwords,
sizeof (item->constant.value.f));
set_defined_register(ctx, regtype, regnum);
} // if
} // else
} // state_DEF

@@ -7030,12 +7033,15 @@ static void state_DEFI(Context *ctx)
else
{
ConstantsList *item = alloc_constant_listitem(ctx);
item->constant.index = regnum;
item->constant.type = MOJOSHADER_UNIFORM_INT;
memcpy(item->constant.value.i, ctx->dwords,
sizeof (item->constant.value.i));
if (item != NULL)
{
item->constant.index = regnum;
item->constant.type = MOJOSHADER_UNIFORM_INT;
memcpy(item->constant.value.i, ctx->dwords,
sizeof (item->constant.value.i));

set_defined_register(ctx, regtype, regnum);
set_defined_register(ctx, regtype, regnum);
} // if
} // else
} // state_DEFI

@@ -7053,10 +7059,13 @@ static void state_DEFB(Context *ctx)
else
{
ConstantsList *item = alloc_constant_listitem(ctx);
item->constant.index = regnum;
item->constant.type = MOJOSHADER_UNIFORM_BOOL;
item->constant.value.b = ctx->dwords[0] ? 1 : 0;
set_defined_register(ctx, regtype, regnum);
if (item != NULL)
{
item->constant.index = regnum;
item->constant.type = MOJOSHADER_UNIFORM_BOOL;
item->constant.value.b = ctx->dwords[0] ? 1 : 0;
set_defined_register(ctx, regtype, regnum);
} // if
} // else
} // state_DEFB

@@ -259,7 +259,8 @@ StringMap *stringmap_create(const int copy, MOJOSHADER_malloc m,
HashTable_NukeFn nuke = copy ? stringmap_nuke : stringmap_nuke_noop;
StringMap *smap;
smap = hash_create(0,hash_hash_string,hash_keymatch_string,nuke,0,m,f,d);
smap->data = smap;
if (smap != NULL)
smap->data = smap;
return smap;
} // stringmap_create

@@ -2325,6 +2325,9 @@ static int datatype_elems(Context *ctx, const MOJOSHADER_astDataType *dt)
static const MOJOSHADER_astDataType *datatype_base(Context *ctx, const MOJOSHADER_astDataType *dt)
{
dt = reduce_datatype(ctx, dt);
if (dt == NULL)
return dt;

switch (dt->type)
{
case MOJOSHADER_AST_DATATYPE_VECTOR:
@@ -4600,6 +4603,7 @@ static MOJOSHADER_irExpression *new_ir_binop(Context *ctx,
MOJOSHADER_irExpression *left,
MOJOSHADER_irExpression *right)
{
if ((!left) || (!right)) return NULL;
NEW_IR_EXPR(retval, MOJOSHADER_irBinOp, MOJOSHADER_IR_BINOP, left->info.type, left->info.elements);
assert(left->info.type == right->info.type);
assert(left->info.elements == right->info.elements);
@@ -4613,6 +4617,7 @@ static MOJOSHADER_irExpression *new_ir_eseq(Context *ctx,
MOJOSHADER_irStatement *stmt,
MOJOSHADER_irExpression *expr)
{
if (!expr) return NULL;
NEW_IR_EXPR(retval, MOJOSHADER_irESeq, MOJOSHADER_IR_ESEQ, expr->info.type, expr->info.elements);
retval->stmt = stmt;
retval->expr = expr;
@@ -4779,8 +4784,8 @@ static MOJOSHADER_irStatement *new_ir_move(Context *ctx,
const int writemask)
{
NEW_IR_NODE(retval, MOJOSHADER_irMove, MOJOSHADER_IR_MOVE);
assert(dst->info.type == src->info.type);
assert(dst->info.elements == src->info.elements);
assert(dst && src && (dst->info.type == src->info.type));
assert(dst && src && (dst->info.elements == src->info.elements));
retval->dst = dst;
retval->src = src;
retval->writemask = writemask;
@@ -4832,8 +4837,8 @@ static MOJOSHADER_irExpression *build_ir_compare(Context *ctx,
const int join = generate_ir_label(ctx);
const int tmp = generate_ir_temp(ctx);

assert(tval->info.type == fval->info.type);
assert(tval->info.elements == fval->info.elements);
assert(tval && fval && (tval->info.type == fval->info.type));
assert(tval && fval && (tval->info.elements == fval->info.elements));

const MOJOSHADER_astDataTypeType dt = tval->info.type;
const int elements = tval->info.elements;
@@ -5320,6 +5325,9 @@ static MOJOSHADER_irExpression *build_ir_derefstruct(Context *ctx, const MOJOSHA
MOJOSHADER_irExpression *expr = build_ir_expr(ctx, ast->identifier);
MOJOSHADER_irExpression *finalexpr = expr;

if (expr == NULL)
return NULL;

assert(!ast->isswizzle);

while (finalexpr->ir.type == MOJOSHADER_IR_ESEQ)
@@ -2453,7 +2453,8 @@ void MOJOSHADER_glProgramReady(void)
// !!! FIXME: set constants that overlap the array.
} // for

if (program->texbem_count)
assert((!program->texbem_count) || (program->fragment));
if ((program->texbem_count) && (program->fragment))
{
const MOJOSHADER_parseData *pd = program->fragment->parseData;
const int samp_count = pd->sampler_count;
@@ -2481,7 +2482,7 @@ void MOJOSHADER_glProgramReady(void)
} // for

assert(texbem_count == program->texbem_count);
} // for
} // if

program->generation = ctx->generation;

0 comments on commit 7a0dc96

Please sign in to comment.