On 9/1/26 09:18, Markus Armbruster wrote:
Philippe Mathieu-Daudé <[email protected]> writes:
On 9/1/26 07:58, Pierrick Bouvier wrote:
[...]
See my previous answer on v1, -Wswitch is used:
Reading the thread above, the only mention I find is the 3rd commit that
precisely change definition because -Wswitch is enabled with clang.
And it's not only a clang thing, gcc has it in Wall also [1].
Yes I read that, I'd really like we use -Wswitch but IIUC we can not,
so with that in mind I don't understand your request. Is that for the
hypothetical case we can use -Wswitch in the future? Sorry I'm not
trying to be picky here, I just fail to see the problem you raised :(
We *are* using -Wswitch.
Oh... I guess I meant -Wswitch-enum then (which forces to handle the
-- meaningless in that case -- QAPI foo__MAX enum values).
Anyway time to stop bikeshedding and call it a day (originally I just
wanted to remove the duplicated qemu_arch_available symbol :) ).
To see that, delete the default: case in to_json()'s outer switch (patch
appended), and compile:
../qobject/qjson.c: In function ‘to_json’:
../qobject/qjson.c:154:5: warning: enumeration value ‘QTYPE_NONE’ not
handled in switch [-Wswitch]
154 | switch (qobject_type(obj)) {
| ^~~~~~
../qobject/qjson.c:154:5: warning: enumeration value ‘QTYPE__MAX’ not
handled in switch [-Wswitch]
We run gcc -Wall, which implies -Wswitch.
[...]
diff --git a/qobject/qjson.c b/qobject/qjson.c
index c858dafb5e..6287c93c67 100644
--- a/qobject/qjson.c
+++ b/qobject/qjson.c
@@ -213,8 +213,6 @@ static void to_json(JSONWriter *writer, const char *name,
json_writer_bool(writer, name, qbool_get_bool(val));
break;
}
- default:
- abort();
}
}