linuxmint / muffin

The window management library for the Cinnamon desktop (libmuffin) and its sample WM binary (muffin)
GNU General Public License v2.0
196 stars 93 forks source link

clutter/clutter/clutter-main.c:2723:46: error: format string is not a string literal [-Werror,-Wformat-nonliteral] #703

Closed SparkyBluefang closed 1 week ago

SparkyBluefang commented 1 week ago

Distribution

Gentoo

Package version

6.2.0

Graphics hardware in use

No response

Frequency

Always

Bug description

Downstream build failure reported on clang builds using -Werror=format-nonliteral, going all the way back to mutter 5.4.0 and still reproducible on 6.2.0.

https://bugs.gentoo.org/832474

Full 5.4.0 build log muffin-5.2.0-build.log

Excerpt from 6.2.0 build log

FAILED: clutter/clutter/libmuffin-clutter-0.so.0.0.0.p/clutter-main.c.o 
clang -Iclutter/clutter/libmuffin-clutter-0.so.0.0.0.p -Iclutter/clutter -I../muffin-6.2.0/clutter/clutter -Iclutter -I../muffin-6.2.0/clutter -Icogl -I../muffin-6.2.0/cogl -Icogl/cogl -I../muffin-6.2.0/cogl/cogl -I/usr/include/atk-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/lib64/libffi/include -I/usr/include/cairo -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include/pixman-1 -I/usr/include/gio-unix-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/json-glib-1.0 -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/graphene-1.0 -I/usr/lib64/graphene-1.0/include -fvisibility=hidden -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -D_GNU_SOURCE -pipe -march=native -fstack-protector-all -O2 -fdiagnostics-color=always -frecord-gcc-switches -Wformat -Werror=format-security -Werror=format-nonliteral -fPIC -mfpmath=sse -msse -msse2 -pthread '-DCLUTTER_SYSCONFDIR="/etc"' -DCLUTTER_COMPILATION=1 -DCOGL_DISABLE_DEPRECATION_WARNINGS '-DG_LOG_DOMAIN="Clutter"' -MD -MQ clutter/clutter/libmuffin-clutter-0.so.0.0.0.p/clutter-main.c.o -MF clutter/clutter/libmuffin-clutter-0.so.0.0.0.p/clutter-main.c.o.d -o clutter/clutter/libmuffin-clutter-0.so.0.0.0.p/clutter-main.c.o -c ../muffin-6.2.0/clutter/clutter/clutter-main.c
../muffin-6.2.0/clutter/clutter/clutter-main.c:2683:46: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
 2683 |   g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, fmt, var_args);
      |                                              ^~~
../muffin-6.2.0/clutter/clutter/clutter-main.c:2723:46: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
 2723 |   g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, fmt, args);
      |                                              ^~~
2 errors generated.

I don't have a clang system, so I can't reproduce or provide a complete modern build log. I also don't know if this is reproducible with mutter, but I don't see any Gentoo or Gnome bug reports.

Steps to reproduce

Build with clang and -Werror=format-nonliteral

Expected behavior

Build completes successfully.

Additional information

No response

eli-schwartz commented 1 week ago

The context here is https://clang.llvm.org/docs/AttributeReference.html#format and note that clang handles format functions a bit differently. It checks to see whether your function matches up with the function your function calls.

SparkyBluefang commented 1 week ago

Also, to be clear, in light of the previous build flag issue I filed, and the kerfuffle it triggered:

-Werror=format-nonliteral is not a Gentoo default, nor is it planned to be, and would only come from an end-user customizing their build configurations.

eli-schwartz commented 1 week ago

More particularly, it can happen if the user compiles with CC=clang and meson setup -Dbuildtype=release -Dwerror=true.

The werror=true is important because while the muffin meson.build adds format-nonliteral as a default warning it is just that: a warning.

leigh123linux commented 1 week ago

Closed as not planned.