mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice-common
synced 2025-12-29 08:28:08 +00:00
This commit adds a SPICE_UNREACHABLE macro (courtesy of Frediano)
so that gcc does not think that code control can go past
spice_return_{val_,}if_fail(), spice_critical() and spice_error()
This avoids this kind of warnings:
fallthrough.c:
#include "log.h"
int main(int argc, char **argv)
{
switch(argc) {
case 1:
spice_critical("foo");
default:
return 0;
}
}
$ gcc -c $(pkg-config --cflags --libs glib-2.0 spice-protocol)
-I common -Wimplicit-fallthrough=5 ./fallthrough.c
In file included from ./fallthrough.c:1:
./fallthrough.c: In function 'main':
common/log.h:73:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
73 | spice_log(G_LOG_LEVEL_CRITICAL, SPICE_STRLOC, __FUNCTION__, "" format, ## __VA_ARGS__); \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./fallthrough.c:8:25: note: in expansion of macro 'spice_critical'
8 | spice_critical("foo");
| ^~~~~~~~~~~~~~
./fallthrough.c:9:17: note: here
9 | default:
| ^~~~~~~
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
|
||
|---|---|---|
| .. | ||
| recorder@10b178762e | ||
| backtrace.c | ||
| backtrace.h | ||
| canvas_base.c | ||
| canvas_base.h | ||
| canvas_utils.c | ||
| canvas_utils.h | ||
| client_marshallers.h | ||
| demarshallers.h | ||
| draw.h | ||
| lines.c | ||
| lines.h | ||
| log.c | ||
| log.h | ||
| lz_common.h | ||
| lz_compress_tmpl.c | ||
| lz_config.h | ||
| lz_decompress_tmpl.c | ||
| lz.c | ||
| lz.h | ||
| macros.h | ||
| Makefile.am | ||
| marshaller.c | ||
| marshaller.h | ||
| mem.c | ||
| mem.h | ||
| meson.build | ||
| messages.h | ||
| pixman_utils.c | ||
| pixman_utils.h | ||
| quic_config.h | ||
| quic_family_tmpl.c | ||
| quic_tmpl.c | ||
| quic.c | ||
| quic.h | ||
| recorder.h | ||
| rect.h | ||
| region.c | ||
| region.h | ||
| ring.h | ||
| rop3.c | ||
| rop3.h | ||
| snd_codec.c | ||
| snd_codec.h | ||
| ssl_verify.c | ||
| ssl_verify.h | ||
| sw_canvas.c | ||
| sw_canvas.h | ||
| utils.c | ||
| utils.h | ||
| verify.h | ||