Skip to content

main: Avoid missing braces warnings when compiling with clang

Since -Werror=missing-braces is used, having missing braces warnings aren't allowed. However, the first member of struct sigaction is a union whose first member is a pointer, causing clang to produce warnings when it is initialized to { 0 }.

Instead of initializing to a zero value, we can specify values of members directly in the initializer to avoid warnings.

This fixes build error on FreeBSD:

[76/126] Compiling C object 'src/25a6634@@gnome-shell@exe/main.c.o'.
FAILED: src/25a6634@@gnome-shell@exe/main.c.o 
clang -B/home/lantw44/.local/bin -Isrc/25a6634@@gnome-shell@exe -Isrc -I../../source/gnome-shell/src -I. -I../../source/gnome-shell/ -Isrc/st -I../../source/gnome-shell/src/st -Isrc/st/.. -I../../source/gnome-shell/src/st/.. -Isrc/tray -I../../source/gnome-shell/src/tray -I/home/lantw44/gnome/devinstall/include/gio-unix-2.0 -I/home/lantw44/gnome/devinstall/include/glib-2.0 -I/home/lantw44/gnome/devinstall/lib/glib-2.0/include -I/usr/local/lib/libffi-3.2.1/include -I/usr/local/include/libxml2 -I/home/lantw44/gnome/devinstall/include/gtk-3.0 -I/home/lantw44/gnome/devinstall/include/pango-1.0 -I/usr/local/include/freetype2 -I/usr/local/include/libpng16 -I/usr/local/include/harfbuzz -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -I/home/lantw44/gnome/devinstall/include/harfbuzz -I/home/lantw44/gnome/devinstall/include/fribidi -I/home/lantw44/gnome/devinstall/include/cairo -I/home/lantw44/gnome/devinstall/include/pixman-1 -I/usr/local/include/libdrm -I/home/lantw44/gnome/devinstall/include/gdk-pixbuf-2.0 -I/home/lantw44/gnome/devinstall/include/atk-1.0 -I/home/lantw44/gnome/devinstall/include/at-spi2-atk/2.0 -I/home/lantw44/gnome/devinstall/include/at-spi-2.0 -I/usr/local/include/dbus-1.0 -I/usr/local/lib/dbus-1.0/include -I/home/lantw44/gnome/devinstall/include/gjs-1.0 -I/home/lantw44/gnome/devinstall/include/gobject-introspection-1.0 -I/home/lantw44/gnome/devinstall/include/mozjs-60 -I/home/lantw44/gnome/devinstall/include/mutter-4/clutter -I/home/lantw44/gnome/devinstall/include/json-glib-1.0 -I/home/lantw44/gnome/devinstall/include/mutter-4/cogl -I/usr/local/include/startup-notification-1.0 -I/usr/local/include/polkit-1 -I/home/lantw44/gnome/devinstall/include/gcr-3 -I/home/lantw44/gnome/devinstall/include/gck-1 -I/usr/local/include/p11-kit-1 -I/home/lantw44/gnome/devinstall/include/gstreamer-1.0 -I/home/lantw44/gnome/devinstall/include/mutter-4 -I/home/lantw44/gnome/devinstall/include/gsettings-desktop-schemas -Xclang -fcolor-diagnostics -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O2 -g -fno-strict-aliasing -Wpointer-arith -Wmissing-declarations -Wimplicit-function-declaration -Wformat=2 -Wformat-nonliteral -Wformat-security -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wundef -Wunused -Wcast-align -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-include-dirs -Wignored-qualifiers -Werror=redundant-decls -Werror=implicit -Werror=nonnull -Werror=init-self -Werror=main -Werror=missing-braces -Werror=sequence-point -Werror=return-type -Werror=trigraphs -Werror=array-bounds -Werror=write-strings -Werror=address -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast -Werror=empty-body -Werror=write-strings -DG_ENABLE_DEBUG -fno-omit-frame-pointer -march=corei7 -B/home/lantw44/.local/bin -g3 -Og -gz -fdebug-macro -pthread -include /home/lantw44/gnome/devinstall/include/mozjs-60/js/RequiredDefines.h -D_THREAD_SAFE -DCLUTTER_ENABLE_EXPERIMENTAL_API -DCOGL_ENABLE_EXPERIMENTAL_API '-DVERSION="3.33.3"' '-DLOCALEDIR="/home/lantw44/gnome/devinstall/share/locale"' '-DDATADIR="/home/lantw44/gnome/devinstall/share"' '-DGNOME_SHELL_LIBEXECDIR="/home/lantw44/gnome/devinstall/libexec"' '-DGNOME_SHELL_DATADIR="/home/lantw44/gnome/devinstall/share/gnome-shell"' '-DGNOME_SHELL_PKGLIBDIR="/home/lantw44/gnome/devinstall/lib/gnome-shell"' '-DMUTTER_TYPELIB_DIR="/home/lantw44/gnome/devinstall/lib/mutter-4"' -MD -MQ 'src/25a6634@@gnome-shell@exe/main.c.o' -MF 'src/25a6634@@gnome-shell@exe/main.c.o.d' -o 'src/25a6634@@gnome-shell@exe/main.c.o' -c ../../source/gnome-shell/src/main.c
../../source/gnome-shell/src/main.c:375:27: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
  struct sigaction sa = { 0 };
                          ^
                          {}
../../source/gnome-shell/src/main.c:405:27: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
  struct sigaction sa = { 0 };
                          ^
                          {}
2 errors generated.

Merge request reports

Loading