Prefer compiler warnings to assertions for unhandled switch cases
Using 'default:' cases can hide logical errors which would lead to i3 crashes for users. With this change the compiler will print a warning when a case is not handled. For example, if I add a new value in the Font.type enum: ../../i3/libi3/font.c: In function ‘draw_text’: ../../i3/libi3/font.c:378:5: warning: enumeration value ‘NEWFONT’ not handled in switch [-Wswitch] switch (savedFont->type) { ^~~~~~
This commit is contained in:
@ -268,10 +268,6 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
|
||||
case CT_DOCKAREA:
|
||||
ystr("dockarea");
|
||||
break;
|
||||
default:
|
||||
DLOG("About to dump unknown container type=%d. This is a bug.\n", con->type);
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
|
||||
/* provided for backwards compatibility only. */
|
||||
|
Reference in New Issue
Block a user