From d1ed4193a7c094085c7b19c8f30c1e95bfdca122 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 27 May 2016 13:54:16 -0400 Subject: [PATCH] Fixed up a few Visual Studio warnings, compiling as C++, etc. --- mojoshader.c | 24 +++++++++++++----------- mojoshader_common.c | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/mojoshader.c b/mojoshader.c index 8c34eea9..a9438feb 100644 --- a/mojoshader.c +++ b/mojoshader.c @@ -10457,7 +10457,7 @@ static int parse_ctab_typeinfo(Context *ctx, const uint8 *start, memset(info->members, '\0', len); } // else - int i; + unsigned int i; const uint32 *member = (const uint32 *) (start + typeptr[6]); for (i = 0; i < info->member_count; i++) { @@ -11171,7 +11171,7 @@ static void free_variable_list(MOJOSHADER_free f, void *d, VariableList *item) static void free_sym_typeinfo(MOJOSHADER_free f, void *d, MOJOSHADER_symbolTypeInfo *typeinfo) { - int i; + unsigned int i; for (i = 0; i < typeinfo->member_count; i++) { f((void *) typeinfo->members[i].name, d); @@ -12052,6 +12052,14 @@ const MOJOSHADER_preshader *MOJOSHADER_parsePreshader(const unsigned char *buf, // !!! FIXME: This is copypasta ripped from parse_preshader -flibit int i; + // All sections of a preshader are packed into separate comment tokens, + // inside the containing comment token block. Find them all before + // we start, so we don't care about the order they appear in the file. + PreshaderBlockInfo ctab = { 0, 0, 0 }; + PreshaderBlockInfo prsi = { 0, 0, 0 }; + PreshaderBlockInfo fxlc = { 0, 0, 0 }; + PreshaderBlockInfo clit = { 0, 0, 0 }; + const uint32 *tokens = (const uint32 *) buf; uint32 tokcount = _len / 4; @@ -12077,14 +12085,6 @@ const MOJOSHADER_preshader *MOJOSHADER_parsePreshader(const unsigned char *buf, tokens++; tokcount++; - // All sections of a preshader are packed into separate comment tokens, - // inside the containing comment token block. Find them all before - // we start, so we don't care about the order they appear in the file. - PreshaderBlockInfo ctab = { 0, 0, 0 }; - PreshaderBlockInfo prsi = { 0, 0, 0 }; - PreshaderBlockInfo fxlc = { 0, 0, 0 }; - PreshaderBlockInfo clit = { 0, 0, 0 }; - while (tokcount > 0) { uint32 subtokcount = 0; @@ -12401,13 +12401,15 @@ void MOJOSHADER_freePreshader(const MOJOSHADER_preshader *preshader, MOJOSHADER_free f, void *d) { - int i, j; + unsigned int i, j; if (preshader != NULL) { f((void *) preshader->literals, d); for (i = 0; i < preshader->instruction_count; i++) + { for (j = 0; j < preshader->instructions[i].operand_count; j++) f((void *) preshader->instructions[i].operands[j].array_registers, d); + } // for f((void *) preshader->instructions, d); f((void *) preshader->registers, d); free_symbols(f, d, preshader->symbols, preshader->symbol_count); diff --git a/mojoshader_common.c b/mojoshader_common.c index 446d3897..d44c8bfe 100644 --- a/mojoshader_common.c +++ b/mojoshader_common.c @@ -104,7 +104,7 @@ int hash_iter(const HashTable *table, const void *key, int hash_iter_keys(const HashTable *table, const void **_key, void **iter) { HashItem *item = (HashItem *) *iter; - int idx = 0; + uint32 idx = 0; if (item != NULL) {