mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
Clean up some enum sanity checks
It seems clang defaults to unsigned for enums. Interestingly, gcc was ok with the checks being either way. I guess gcc treats enums that *can* be unsigned as DWIM.
This commit is contained in:
parent
db01650dac
commit
63e5655f68
8 changed files with 11 additions and 12 deletions
|
@ -453,7 +453,7 @@ cl_event_handler (const IE_event_t *ie_event, void *unused)
|
|||
[ie_gain_focus] = cl_focus_event,
|
||||
[ie_lose_focus] = cl_focus_event,
|
||||
};
|
||||
if (ie_event->type < 0 || ie_event->type >= ie_event_count
|
||||
if ((unsigned) ie_event->type >= ie_event_count
|
||||
|| !handlers[ie_event->type]) {
|
||||
return IN_Binding_HandleEvent (ie_event);
|
||||
}
|
||||
|
|
|
@ -821,7 +821,7 @@ con_event_handler (const IE_event_t *ie_event, void *data)
|
|||
[ie_key] = con_key_event,
|
||||
[ie_mouse] = con_mouse_event,
|
||||
};
|
||||
if (ie_event->type < 0 || ie_event->type >= ie_event_count
|
||||
if ((unsigned) ie_event->type >= ie_event_count
|
||||
|| !handlers[ie_event->type]) {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -824,7 +824,7 @@ Menu_EventHandler (const IE_event_t *ie_event)
|
|||
[ie_key] = menu_key_event,
|
||||
[ie_mouse] = menu_mouse_event,
|
||||
};
|
||||
if (ie_event->type < 0 || ie_event->type >= ie_event_count
|
||||
if ((unsigned) ie_event->type >= ie_event_count
|
||||
|| !handlers[ie_event->type]) {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -564,7 +564,7 @@ PR_DebugSetSym (progs_t *pr, pr_debug_header_t *debug)
|
|||
type_ptr += type->size) {
|
||||
type = &G_STRUCT (pr, qfot_type_t, type_encodings + type_ptr);
|
||||
if (type->meta == ty_basic
|
||||
&& type->type >= 0 && type->type < ev_type_count) {
|
||||
&& (unsigned) type->type < ev_type_count) {
|
||||
res->type_encodings[type->type] = type;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -250,7 +250,7 @@ in_binding_event_handler (const IE_event_t *ie_event, void *unused)
|
|||
[ie_add_device] = in_binding_add_device,
|
||||
[ie_remove_device] = in_binding_remove_device,
|
||||
};
|
||||
if (ie_event->type < 0 || ie_event->type >= ie_event_count
|
||||
if ((unsigned) ie_event->type >= ie_event_count
|
||||
|| !handlers[ie_event->type]) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -265,7 +265,7 @@ IN_Binding_HandleEvent (const IE_event_t *ie_event)
|
|||
[ie_axis] = in_binding_axis,
|
||||
[ie_button] = in_binding_button,
|
||||
};
|
||||
if (ie_event->type < 0 || ie_event->type >= ie_event_count
|
||||
if ((unsigned) ie_event->type >= ie_event_count
|
||||
|| !handlers[ie_event->type]) {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1495,7 +1495,7 @@ x11_event_handler (const IE_event_t *ie_event, void *unused)
|
|||
static void (*handlers[ie_event_count]) (const IE_event_t *ie_event) = {
|
||||
[ie_app_window] = x11_app_window,
|
||||
};
|
||||
if (ie_event->type < 0 || ie_event->type >= ie_event_count
|
||||
if ((unsigned) ie_event->type >= ie_event_count
|
||||
|| !handlers[ie_event->type]) {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -711,7 +711,7 @@ _print_expr (dstring_t *dstr, expr_t *e, int level, int id, expr_t *next)
|
|||
|
||||
if ((int) e->type < 0 || e->type >= ex_count || !print_funcs[e->type]) {
|
||||
const char *type = va (0, "%d", e->type);
|
||||
if (e->type >= 0 && e->type < ex_count) {
|
||||
if ((unsigned) e->type < ex_count) {
|
||||
type = expr_names[e->type];
|
||||
}
|
||||
dasprintf (dstr, "%*se_%p [label=\"(bad expr type: %s)\\n%d\"];\n",
|
||||
|
|
|
@ -543,20 +543,19 @@ dump_qfo_types (qfo_t *qfo, int base_address)
|
|||
qfo->spaces[qfo_type_space].data_size);
|
||||
continue;
|
||||
}
|
||||
if (type->meta < 0 || type->meta >= NUM_META)
|
||||
if ((unsigned) type->meta >= NUM_META)
|
||||
meta = va (0, "invalid meta: %d", type->meta);
|
||||
else
|
||||
meta = ty_meta_names[type->meta];
|
||||
printf ("%-5x %-9s %-20s", type_ptr + base_address, meta,
|
||||
QFO_TYPESTR (qfo, type_ptr));
|
||||
if (type->meta < 0 || type->meta >= NUM_META) {
|
||||
if ((unsigned) type->meta >= NUM_META) {
|
||||
puts ("");
|
||||
break;
|
||||
}
|
||||
switch ((ty_meta_e) type->meta) {
|
||||
case ty_basic:
|
||||
printf (" %-10s", (type->type < 0
|
||||
|| type->type >= ev_type_count)
|
||||
printf (" %-10s", ((unsigned) type->type >= ev_type_count)
|
||||
? "invalid type"
|
||||
: pr_type_name[type->type]);
|
||||
if (type->type == ev_func) {
|
||||
|
|
Loading…
Reference in a new issue