formatting and compiler warnings

pull/167/head
Dibyendu Majumdar 6 years ago
parent 831120e143
commit 7a055dc0c2

@ -157,6 +157,7 @@ static struct OMRType *sym_basetype_type(struct dmr_C *C, struct function *fn,
struct symbol *sym,
struct symbol *sym_node)
{
(void) sym_node;
if (dmrC_is_float_type(C->S, sym)) {
switch (sym->bit_size) {
case 32:
@ -248,9 +249,11 @@ static struct OMRType *sym_array_type(struct dmr_C *C, struct function *fn,
struct symbol *sym_node)
{
struct symbol *base_type;
(void) C;
base_type = sym->ctype.base_type;
/* empty struct is undefined [6.7.2.1(8)] */
unsigned int array_bit_size = sym->bit_size;
int array_bit_size = sym->bit_size;
if (array_bit_size == 0 || array_bit_size == -1) {
if (sym_node != NULL)
array_bit_size = sym_node->bit_size;

@ -201,7 +201,8 @@ int dmrC_test_allocator() {
if (alloc.total_bytes !=
(sizeof(struct allocation_blob) + sizeof(struct foo) * 2) * 2)
return 1;
struct allocator alloc2 = { 0 };
struct allocator alloc2;
memset(&alloc2, 0, sizeof alloc2);
struct allocation_blob *saved = alloc.blobs_;
dmrC_allocator_transfer(&alloc, &alloc2);
if (alloc.blobs_ != NULL)

@ -84,6 +84,8 @@ static int evaluate_choose(struct dmr_C *C, struct expression *expr)
static int expand_expect(struct dmr_C *C, struct expression *expr, int cost)
{
struct expression *arg = dmrC_first_expression(expr->args);
(void)C;
(void)cost;
if (arg)
*expr = *arg;
@ -98,6 +100,7 @@ static int expand_warning(struct dmr_C *C, struct expression *expr, int cost)
{
struct expression *arg;
struct expression_list *arglist = expr->args;
(void)cost;
FOR_EACH_PTR (arglist, arg) {
/*
@ -138,6 +141,7 @@ out:
/* The arguments are constant if the cost of all of them is zero */
static int expand_constant_p(struct dmr_C *C, struct expression *expr, int cost)
{
(void) C;
expr->type = EXPR_VALUE;
expr->value = !cost;
expr->taint = 0;
@ -147,6 +151,7 @@ static int expand_constant_p(struct dmr_C *C, struct expression *expr, int cost)
/* The arguments are safe, if their cost is less than SIDE_EFFECTS */
static int expand_safe_p(struct dmr_C *C, struct expression *expr, int cost)
{
(void) C;
expr->type = EXPR_VALUE;
expr->value = (cost < SIDE_EFFECTS);
expr->taint = 0;
@ -226,7 +231,7 @@ static struct sym_init {
{ "__builtin_bswap16", NULL, MOD_TOPLEVEL, &bswap_op },
{ "__builtin_bswap32", NULL, MOD_TOPLEVEL, &bswap_op },
{ "__builtin_bswap64", NULL, MOD_TOPLEVEL, &bswap_op },
{ NULL, NULL, 0 }
{ NULL, NULL, 0, NULL }
};
void dmrC_init_builtins(struct dmr_C *C, int stream)

@ -194,11 +194,12 @@ left:
static int same_cast_type(struct dmr_C *C, struct symbol *orig, struct symbol *news)
{
(void)C;
return orig->bit_size == news->bit_size &&
orig->bit_offset == news->bit_offset;
}
static struct symbol *base_type(struct dmr_C *C, struct symbol *node, unsigned long *modp, unsigned long *asp)
static struct symbol *base_type(struct symbol *node, unsigned long *modp, unsigned long *asp)
{
unsigned long mod, as;
@ -222,8 +223,8 @@ static int is_same_type(struct dmr_C *C, struct expression *expr, struct symbol
struct symbol *old = expr->ctype;
unsigned long oldmod, newmod, oldas, newas;
old = base_type(C, old, &oldmod, &oldas);
news = base_type(C, news, &newmod, &newas);
old = base_type(old, &oldmod, &oldas);
news = base_type(news, &newmod, &newas);
/* Same base type, same address space? */
if (old == news && oldas == newas) {
@ -411,8 +412,9 @@ static struct symbol *bad_expr_type(struct dmr_C *C, struct expression *expr)
return expr->ctype = &C->S->bad_ctype;
}
static int restricted_value(struct dmr_C *C, struct expression *v, struct symbol *type)
static int restricted_value(struct expression *v, struct symbol *type)
{
(void)type;
if (v->type != EXPR_VALUE)
return 1;
if (v->value != 0)
@ -420,7 +422,7 @@ static int restricted_value(struct dmr_C *C, struct expression *v, struct symbol
return 0;
}
static int restricted_binop(struct dmr_C *C, int op, struct symbol *type)
static int restricted_binop(int op)
{
switch (op) {
case '&':
@ -453,7 +455,7 @@ static int restricted_unop(struct dmr_C *C, int op, struct symbol **type)
}
/* type should be SYM_FOULED */
static inline struct symbol *unfoul(struct dmr_C *C, struct symbol *type)
static inline struct symbol *unfoul(struct symbol *type)
{
return type->ctype.base_type;
}
@ -471,24 +473,24 @@ static struct symbol *restricted_binop_type(struct dmr_C *C, int op,
if (ltype == rtype) {
ctype = ltype;
} else if (lclass & TYPE_FOULED) {
if (unfoul(C, ltype) == rtype)
if (unfoul(ltype) == rtype)
ctype = ltype;
} else if (rclass & TYPE_FOULED) {
if (unfoul(C, rtype) == ltype)
if (unfoul(rtype) == ltype)
ctype = rtype;
}
} else {
if (!restricted_value(C, right, ltype))
if (!restricted_value(right, ltype))
ctype = ltype;
}
} else if (!restricted_value(C, left, rtype))
} else if (!restricted_value(left, rtype))
ctype = rtype;
if (ctype) {
switch (restricted_binop(C, op, ctype)) {
switch (restricted_binop(op)) {
case 1:
if ((lclass ^ rclass) & TYPE_FOULED)
ctype = unfoul(C, ctype);
ctype = unfoul(ctype);
break;
case 3:
if (!(lclass & rclass & TYPE_FOULED))
@ -508,7 +510,7 @@ static inline void unrestrict(struct dmr_C *C, struct expression *expr,
{
if (klass & TYPE_RESTRICT) {
if (klass & TYPE_FOULED)
*ctype = unfoul(C, *ctype);
*ctype = unfoul(*ctype);
dmrC_warning(C, expr->pos, "%s degrades to integer",
dmrC_show_typename(C, *ctype));
*ctype = (*ctype)->ctype.base_type; /* get to arithmetic type */
@ -1279,16 +1281,16 @@ static int evaluate_assign_op(struct dmr_C *C, struct expression *expr)
return 0;
}
if (tclass & TYPE_RESTRICT) {
if (!restricted_binop(C, op, t)) {
if (!restricted_binop(op)) {
dmrC_warning(C, expr->pos, "bad assignment (%s) to %s",
dmrC_show_special(C, op), dmrC_show_typename(C, t));
expr->right = cast_to(C, expr->right, target);
return 0;
}
/* allowed assignments unfoul */
if (sclass & TYPE_FOULED && unfoul(C, s) == t)
if (sclass & TYPE_FOULED && unfoul(s) == t)
goto Cast;
if (!restricted_value(C, expr->right, t))
if (!restricted_value(expr->right, t))
return 1;
} else if (!(sclass & TYPE_RESTRICT))
goto usual;
@ -1354,9 +1356,9 @@ static int check_assignment_types(struct dmr_C *C, struct symbol *target, struct
if (tclass & sclass & TYPE_NUM) {
if (tclass & TYPE_RESTRICT) {
/* allowed assignments unfoul */
if (sclass & TYPE_FOULED && unfoul(C, s) == t)
if (sclass & TYPE_FOULED && unfoul(s) == t)
goto Cast;
if (!restricted_value(C, *rp, target))
if (!restricted_value(*rp, target))
return 1;
if (s == t)
return 1;
@ -2832,10 +2834,10 @@ static struct symbol *evaluate_cast(struct dmr_C *C, struct expression *expr)
/* allowed cast unfouls */
if (class2 & TYPE_FOULED)
t2 = unfoul(C, t2);
t2 = unfoul(t2);
if (t1 != t2) {
if ((class1 & TYPE_RESTRICT) && restricted_value(C, target, t1))
if ((class1 & TYPE_RESTRICT) && restricted_value(target, t1))
dmrC_warning(C, expr->pos, "cast to %s",
dmrC_show_typename(C, t1));
if (class2 & TYPE_RESTRICT) {

@ -74,6 +74,7 @@ static long long get_longlong(struct dmr_C *C, struct expression *expr)
long long mask = 1ULL << (expr->ctype->bit_size - 1);
long long value = expr->value;
long long ormask, andmask;
(void)C;
if (!(value & mask))
no_expand = 1;
@ -187,7 +188,7 @@ static int simplify_int_binop(struct dmr_C *C, struct expression *expr, struct s
return 0;
r = right->value;
if (expr->op == SPECIAL_LEFTSHIFT || expr->op == SPECIAL_RIGHTSHIFT) {
if (r >= ctype->bit_size) {
if ((int)r >= ctype->bit_size) {
if (conservative)
return 0;
r = check_shift_count(C, expr, ctype, r);
@ -302,6 +303,7 @@ static int simplify_cmp_binop(struct dmr_C *C, struct expression *expr, struct s
unsigned long long l, r, mask;
signed long long sl, sr;
(void) C;
if (left->type != EXPR_VALUE || right->type != EXPR_VALUE)
return 0;
l = left->value; r = right->value;

@ -634,7 +634,7 @@ static struct token *unary_expression(struct dmr_C *C, struct token *token, stru
{ C->S->__sizeof_ptr___ident, EXPR_PTRSIZEOF },
};
int i;
for (i = 0; i < ARRAY_SIZE(type_information); i++) {
for (i = 0; i < (int)ARRAY_SIZE(type_information); i++) {
if (ident == type_information[i].id)
return type_info_expression(C, token, tree, type_information[i].type);
}
@ -902,7 +902,7 @@ struct token *dmrC_assignment_expression(struct dmr_C *C, struct token *token, s
SPECIAL_SHR_ASSIGN, SPECIAL_AND_ASSIGN,
SPECIAL_OR_ASSIGN, SPECIAL_XOR_ASSIGN };
int i, op = token->special;
for (i = 0; i < ARRAY_SIZE(assignments); i++)
for (i = 0; i < (int)ARRAY_SIZE(assignments); i++)
if (assignments[i] == op) {
struct expression * expr = dmrC_alloc_expression(C, token->pos, EXPR_ASSIGNMENT);
expr->left = *tree;

@ -304,7 +304,7 @@ static struct expression_list *copy_asm_constraints(struct dmr_C *C, struct expr
return out;
}
static void set_replace(struct dmr_C *C, struct symbol *old, struct symbol *news)
static void set_replace(struct symbol *old, struct symbol *news)
{
news->replace = old;
old->replace = news;
@ -493,7 +493,7 @@ static struct symbol *create_copy_symbol(struct dmr_C *C, struct symbol *orig)
*sym = *orig;
sym->bb_target = NULL;
sym->pseudo = NULL;
set_replace(C, orig, sym);
set_replace(orig, sym);
orig = sym;
}
return orig;
@ -546,7 +546,7 @@ int dmrC_inline_function(struct dmr_C *C, struct expression *expr, struct symbol
a->ctype.base_type = arg->ctype;
if (name) {
*a = *name;
set_replace(C, name, a);
set_replace(name, a);
dmrC_add_symbol(C, &fn_symbol_list, a);
}
a->initializer = arg;

@ -225,6 +225,7 @@ void dmrC_die(struct dmr_C *C, const char *fmt, ...)
va_list args;
static char buffer[512];
(void)C;
va_start(args, fmt);
vsnprintf(buffer, sizeof(buffer), fmt, args);
va_end(args);
@ -665,7 +666,7 @@ static char **handle_switch_d(struct dmr_C *C, char *arg, char **next)
static void handle_onoff_switch_finalize(const struct warning warnings[], int n)
{
unsigned i;
int i;
for (i = 0; i < n; i++) {
if (*warnings[i].flag == WARNING_FORCE_OFF)
@ -789,6 +790,7 @@ static char **handle_switch_f(struct dmr_C *C, char *arg, char **next)
static char **handle_switch_G(struct dmr_C *C, char *arg, char **next)
{
(void) C;
if (!strcmp(arg, "G") && *next)
return next + 1; // "-G 0"
else

@ -79,6 +79,7 @@ static struct multijmp *alloc_multijmp(struct dmr_C *C, struct basic_block *targ
return multijmp;
}
#if 0
static inline int regno(pseudo_t n)
{
int retval = -1;
@ -86,6 +87,7 @@ static inline int regno(pseudo_t n)
retval = n->nr;
return retval;
}
#endif
const char *dmrC_show_pseudo(struct dmr_C *C, pseudo_t pseudo)
{
@ -276,7 +278,7 @@ const char *dmrC_show_instruction(struct dmr_C *C, struct instruction *insn)
if (!insn->bb)
buf += sprintf(buf, "# ");
if (opcode < ARRAY_SIZE(opcodes)) {
if (opcode < (int)ARRAY_SIZE(opcodes)) {
const char *op = opcodes[opcode];
if (!op)
buf += sprintf(buf, "opcode:%d", opcode);

@ -65,32 +65,32 @@ static void track_instruction_usage(struct dmr_C *C, struct basic_block *bb, str
break;
/* Binary */
case OP_ADD:
case OP_SUB:
case OP_MULU:
case OP_MULS:
case OP_DIVU:
case OP_DIVS:
case OP_MODU:
case OP_MODS:
case OP_SHL:
case OP_LSR:
case OP_ASR:
case OP_AND:
case OP_OR:
case OP_XOR:
case OP_AND_BOOL:
case OP_OR_BOOL:
case OP_SET_EQ:
case OP_SET_NE:
case OP_SET_LE:
case OP_SET_GE:
case OP_SET_LT:
case OP_SET_GT:
case OP_SET_B:
case OP_SET_A:
case OP_SET_BE:
case OP_SET_AE:
case OP_ADD:
case OP_SUB:
case OP_MULU:
case OP_MULS:
case OP_DIVU:
case OP_DIVS:
case OP_MODU:
case OP_MODS:
case OP_SHL:
case OP_LSR:
case OP_ASR:
case OP_AND:
case OP_OR:
case OP_XOR:
case OP_AND_BOOL:
case OP_OR_BOOL:
case OP_SET_EQ:
case OP_SET_NE:
case OP_SET_LE:
case OP_SET_GE:
case OP_SET_LT:
case OP_SET_GT:
case OP_SET_B:
case OP_SET_A:
case OP_SET_BE:
case OP_SET_AE:
USES(src1); USES(src2); DEFINES(target);
break;
@ -323,10 +323,15 @@ static void track_bb_phi_uses(struct dmr_C *C, struct basic_block *bb)
static void death_def(struct dmr_C *C, struct basic_block *bb, pseudo_t pseudo)
{
(void) C;
(void) bb;
(void) pseudo;
}
static void death_use(struct dmr_C *C, struct basic_block *bb, pseudo_t pseudo)
{
(void) C;
(void) bb;
if (trackable_pseudo(pseudo) && !dmrC_pseudo_in_list(*C->L->live_list, pseudo)) {
dmrC_add_pseudo(C, &C->L->dead_list, pseudo);
dmrC_add_pseudo(C, C->L->live_list, pseudo);

@ -570,7 +570,7 @@ void dmrC_init_parser(struct dmr_C *C, int stream)
C->P = (struct parse_state_t *) calloc(1, sizeof(struct parse_state_t));
int i;
for (i = 0; i < ARRAY_SIZE(keyword_table); i++) {
for (i = 0; i < (int)ARRAY_SIZE(keyword_table); i++) {
struct init_keyword *ptr = keyword_table + i;
struct symbol *sym = dmrC_create_symbol(C->S, stream, ptr->name, SYM_KEYWORD, ptr->ns);
sym->ident->keyword = 1;
@ -581,7 +581,7 @@ void dmrC_init_parser(struct dmr_C *C, int stream)
sym->op = ptr->op;
}
for (i = 0; i < ARRAY_SIZE(ignored_attributes); i++) {
for (i = 0; i < (int)ARRAY_SIZE(ignored_attributes); i++) {
const char * name = ignored_attributes[i];
struct symbol *sym = dmrC_create_symbol(C->S, stream, name, SYM_KEYWORD,
NS_KEYWORD);

@ -111,6 +111,7 @@ static void replace_with_integer(struct dmr_C *C, struct token *token, unsigned
static struct symbol *lookup_macro(struct dmr_C *C, struct ident *ident)
{
(void) C;
struct symbol *sym = dmrC_lookup_symbol(ident, (enum namespace_type) (NS_MACRO | NS_UNDEF));
if (sym && sym->ns != NS_MACRO)
sym = NULL;
@ -177,6 +178,7 @@ static int expand_one_symbol(struct dmr_C *C, struct token **list)
static inline struct token *scan_next(struct dmr_C *C, struct token **where)
{
struct token *token = *where;
(void) C;
if (dmrC_token_type(token) != TOKEN_UNTAINT)
return token;
do {
@ -518,10 +520,10 @@ static int merge(struct dmr_C *C, struct token *left, struct token *right)
left->string = right->string;
return 1;
case TOKEN_WIDE_CHAR_EMBEDDED_0:
case TOKEN_WIDE_CHAR_EMBEDDED_1:
case TOKEN_WIDE_CHAR_EMBEDDED_2:
case TOKEN_WIDE_CHAR_EMBEDDED_3:
case TOKEN_WIDE_CHAR_EMBEDDED_0:
case TOKEN_WIDE_CHAR_EMBEDDED_1:
case TOKEN_WIDE_CHAR_EMBEDDED_2:
case TOKEN_WIDE_CHAR_EMBEDDED_3:
dmrC_token_type(left) = res;
left->pos.noexpand = 0;
memcpy(left->embedded, right->embedded, 4);
@ -567,6 +569,7 @@ static struct token **copy(struct dmr_C *C, struct token **where, struct token *
static int handle_kludge(struct dmr_C *C, struct token **p, struct arg *args)
{
struct token *t = (*p)->next->next;
(void) C;
while (1) {
struct arg *v = &args[t->argnum];
if (dmrC_token_type(t->next) != TOKEN_CONCAT) {
@ -864,7 +867,8 @@ static int try_include(struct dmr_C *C, const char *path, const char *filename,
static int do_include_path(struct dmr_C *C, const char **pptr, struct token **list, struct token *token, const char *filename, int flen)
{
const char *path;
(void) token;
while ((path = *pptr++) != NULL) {
if (!try_include(C, path, filename, flen, list, pptr))
continue;
@ -933,7 +937,7 @@ static int handle_include_path(struct dmr_C *C, struct stream *stream, struct to
return 0;
out:
dmrC_error_die(C, token->pos, "unable to open '%s'", filename);
return 0;
return 0;
}
static int handle_include(struct dmr_C *C, struct stream *stream, struct token **list, struct token *token)
@ -955,6 +959,7 @@ static int token_different(struct dmr_C *C, struct token *t1, struct token *t2)
{
int different;
(void) C;
if (dmrC_token_type(t1) != dmrC_token_type(t2))
return 1;
@ -979,14 +984,14 @@ static int token_different(struct dmr_C *C, struct token *t1, struct token *t2)
case TOKEN_STR_ARGUMENT:
different = t1->argnum != t2->argnum;
break;
case TOKEN_CHAR_EMBEDDED_0:
case TOKEN_CHAR_EMBEDDED_1:
case TOKEN_CHAR_EMBEDDED_2:
case TOKEN_CHAR_EMBEDDED_3:
case TOKEN_WIDE_CHAR_EMBEDDED_0:
case TOKEN_WIDE_CHAR_EMBEDDED_1:
case TOKEN_WIDE_CHAR_EMBEDDED_2:
case TOKEN_WIDE_CHAR_EMBEDDED_3:
case TOKEN_CHAR_EMBEDDED_0:
case TOKEN_CHAR_EMBEDDED_1:
case TOKEN_CHAR_EMBEDDED_2:
case TOKEN_CHAR_EMBEDDED_3:
case TOKEN_WIDE_CHAR_EMBEDDED_0:
case TOKEN_WIDE_CHAR_EMBEDDED_1:
case TOKEN_WIDE_CHAR_EMBEDDED_2:
case TOKEN_WIDE_CHAR_EMBEDDED_3:
different = memcmp(t1->embedded, t2->embedded, 4);
break;
case TOKEN_CHAR:

@ -26,9 +26,6 @@
#include <stddef.h>
#include <assert.h>
// FIXME should be in ravi_State
static int id = 0;
#define LUA_CORE
#include "lauxlib.h"
@ -200,11 +197,11 @@ void raviV_dumpIR(struct lua_State *L, struct Proto *p) {
membuff_init(&buf, 4096);
char fname[30];
snprintf(fname, sizeof fname, "jit", G->ravi_state->id++);
snprintf(fname, sizeof fname, "%s", "jit_function");
ravi_compile_options_t options = { 0 };
options.codegen_type = RAVI_CODEGEN_ALL;
if (raviJ_codegen(L, p, &options, fname, &buf)) {
printf(buf.buf);
printf("%s", buf.buf);
}
membuff_free(&buf);
}

@ -228,11 +228,13 @@ json_value * json_parse_ex (json_settings * settings,
json_char error [json_error_max];
const json_char * end;
json_value * top, * root, * alloc = 0;
json_state state = { 0 };
json_state state;
long flags;
long num_digits = 0, num_e = 0;
json_int_t num_fraction = 0;
memset(&state, 0, sizeof state);
/* Skip UTF-8 BOM
*/
if (length >= 3 && ((unsigned char) json [0]) == 0xEF
@ -893,7 +895,7 @@ json_value * json_parse_ex (json_settings * settings,
};
}
if ( (++ top->parent->u.array.length) > state.uint_max)
if ( (unsigned)(++ top->parent->u.array.length) > state.uint_max)
goto e_overflow;
top = top->parent;
@ -950,7 +952,8 @@ e_failed:
json_value * json_parse (const json_char * json, size_t length)
{
json_settings settings = { 0 };
json_settings settings;
memset(&settings, 0, sizeof settings);
return json_parse_ex (&settings, json, length, 0);
}

@ -548,6 +548,7 @@ static int search_for_name(const char *name, const char **filter) {
return 0;
}
#if 0
static const char *var_type_as_string(int vtype) {
switch (vtype) {
case VAR_TYPE_LOCALS:
@ -564,6 +565,7 @@ static const char *var_type_as_string(int vtype) {
return "invalid";
}
}
#endif
/*
* Get a table's values into the response

Loading…
Cancel
Save