]> Git Repo - qemu.git/commitdiff
blkdebug: fix enum comparison
authorBlue Swirl <[email protected]>
Sat, 18 Sep 2010 05:53:15 +0000 (05:53 +0000)
committerBlue Swirl <[email protected]>
Sat, 18 Sep 2010 05:53:15 +0000 (05:53 +0000)
The signedness of enum types depend on the compiler implementation.
Therefore the check for negative values may or may not be meaningful.

Fix by explicitly casting to a signed integer.

Since the values are also checked earlier against event_names
table, this is an internal error. Change the 'if' to 'assert'.

This also avoids a warning with GCC flag -Wtype-limits.

Signed-off-by: Blue Swirl <[email protected]>
block/blkdebug.c

index 2a63df93234deb358d1f8aaea36bff3f5c122be2..4d6ff0a368f345074056f4bb330a398d32f876d1 100644 (file)
@@ -439,9 +439,7 @@ static void blkdebug_debug_event(BlockDriverState *bs, BlkDebugEvent event)
     struct BlkdebugRule *rule;
     BlkdebugVars old_vars = s->vars;
 
-    if (event < 0 || event >= BLKDBG_EVENT_MAX) {
-        return;
-    }
+    assert((int)event >= 0 && event < BLKDBG_EVENT_MAX);
 
     QLIST_FOREACH(rule, &s->rules[event], next) {
         process_rule(bs, rule, &old_vars);
This page took 0.025271 seconds and 4 git commands to generate.