diff --git a/libs/client/cl_input.c b/libs/client/cl_input.c index 3ca4b306a..ec2201cd2 100644 --- a/libs/client/cl_input.c +++ b/libs/client/cl_input.c @@ -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); } diff --git a/libs/console/client.c b/libs/console/client.c index 7aa375d0d..0ae47ae0b 100644 --- a/libs/console/client.c +++ b/libs/console/client.c @@ -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; } diff --git a/libs/console/menu.c b/libs/console/menu.c index 619b06c1a..0e02d63e3 100644 --- a/libs/console/menu.c +++ b/libs/console/menu.c @@ -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; } diff --git a/libs/gamecode/pr_debug.c b/libs/gamecode/pr_debug.c index 67f6b981e..3df6ba2a8 100644 --- a/libs/gamecode/pr_debug.c +++ b/libs/gamecode/pr_debug.c @@ -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; } } diff --git a/libs/input/in_binding.c b/libs/input/in_binding.c index acc80601a..74459481c 100644 --- a/libs/input/in_binding.c +++ b/libs/input/in_binding.c @@ -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; } diff --git a/libs/video/targets/in_x11.c b/libs/video/targets/in_x11.c index 3f7685fb1..40bd1e0ef 100644 --- a/libs/video/targets/in_x11.c +++ b/libs/video/targets/in_x11.c @@ -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; } diff --git a/tools/qfcc/source/dot_expr.c b/tools/qfcc/source/dot_expr.c index 52db56ca9..29c5ac319 100644 --- a/tools/qfcc/source/dot_expr.c +++ b/tools/qfcc/source/dot_expr.c @@ -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", diff --git a/tools/qfcc/source/dump_globals.c b/tools/qfcc/source/dump_globals.c index c0ade919b..d95c772cc 100644 --- a/tools/qfcc/source/dump_globals.c +++ b/tools/qfcc/source/dump_globals.c @@ -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) {