Make it compile with -Wall and -pedantic

This commit is contained in:
Dale Weiler 2012-11-23 02:23:22 +00:00
parent af2324e922
commit b5507b3127
5 changed files with 22 additions and 17 deletions

View file

@ -3,12 +3,11 @@ PREFIX := /usr/local
BINDIR := $(PREFIX)/bin
CC ?= clang
CFLAGS += -Wall -I.
CFLAGS += -Wall -I. -Wall -pedantic
#turn on tons of warnings if clang is present
ifeq ($(CC), clang)
CFLAGS += \
-Weverything \
-Wno-missing-prototypes \
-Wno-padded \
-Wno-format-nonliteral \
-Wno-disabled-macro-expansion \

2
con.c
View file

@ -281,7 +281,7 @@ int con_change(const char *out, const char *err) {
con_enablecolor();
} else if (!(console.handle_err = fopen(err, "w"))) return 0;
// no buffering
/* no buffering */
setvbuf(console.handle_out, NULL, _IONBF, 0);
setvbuf(console.handle_err, NULL, _IONBF, 0);

View file

@ -134,8 +134,9 @@ static void pptoken_delete(pptoken *self)
static ppmacro *ppmacro_new(lex_ctx ctx, const char *name)
{
(void)ctx;
ppmacro *macro = (ppmacro*)mem_a(sizeof(ppmacro));
(void)ctx;
memset(macro, 0, sizeof(*macro));
macro->name = util_strdup(name);
return macro;

View file

@ -2485,10 +2485,11 @@ static ast_expression *array_setter_node(parser_t *parser, ast_value *array, ast
lex_ctx ctx = ast_ctx(array);
if (from+1 == afterend) {
// set this value
/* set this value */
ast_block *block;
ast_return *ret;
ast_array_index *subscript;
ast_store *st;
int assignop = type_store_instr[value->expression.vtype];
if (value->expression.vtype == TYPE_FIELD && value->expression.next->expression.vtype == TYPE_VECTOR)
@ -2498,7 +2499,7 @@ static ast_expression *array_setter_node(parser_t *parser, ast_value *array, ast
if (!subscript)
return NULL;
ast_store *st = ast_store_new(ctx, assignop, (ast_expression*)subscript, (ast_expression*)value);
st = ast_store_new(ctx, assignop, (ast_expression*)subscript, (ast_expression*)value);
if (!st) {
ast_delete(subscript);
return NULL;
@ -2543,11 +2544,12 @@ static ast_expression *array_field_setter_node(
lex_ctx ctx = ast_ctx(array);
if (from+1 == afterend) {
// set this value
/* set this value */
ast_block *block;
ast_return *ret;
ast_entfield *entfield;
ast_array_index *subscript;
ast_store *st;
int assignop = type_storep_instr[value->expression.vtype];
if (value->expression.vtype == TYPE_FIELD && value->expression.next->expression.vtype == TYPE_VECTOR)
@ -2566,7 +2568,7 @@ static ast_expression *array_field_setter_node(
return NULL;
}
ast_store *st = ast_store_new(ctx, assignop, (ast_expression*)entfield, (ast_expression*)value);
st = ast_store_new(ctx, assignop, (ast_expression*)entfield, (ast_expression*)value);
if (!st) {
ast_delete(entfield);
return NULL;

21
util.c
View file

@ -498,11 +498,23 @@ size_t util_strtononcmd(const char *in, char *out, size_t outsz) {
*out = *in + 'a' - 'A';
else
*out = *in;
*out = (isalpha(*in) && isupper(*in)) ? *in + 'a' - 'A' : *in;
}
*out = 0;
return sz-1;
}
bool util_filexists(const char *file) {
FILE *fp = fopen(file, "rb");
if (!fp) return false;
/* it exists */
fclose(fp);
return true;
}
FILE *util_fopen(const char *filename, const char *mode)
{
#ifdef WIN32
@ -515,15 +527,6 @@ FILE *util_fopen(const char *filename, const char *mode)
#endif
}
bool util_filexists(const char *file) {
FILE *fp = fopen(file, "rb");
if (!fp) return false;
/* it exists */
fclose(fp);
return true;
}
void _util_vec_grow(void **a, size_t i, size_t s) {
size_t m = *a ? 2*_vec_beg(*a)+i : i+1;
void *p = mem_r((*a ? _vec_raw(*a) : NULL), s * m + sizeof(size_t)*2);