[OpenWrt-Devel] -Werror=format-nonliteral and musl
Rosen Penev
rosenp at gmail.com
Sat Mar 16 18:24:37 EDT 2019
On Sat, Mar 16, 2019 at 2:51 PM W. Michael Petullo <mike at flyn.org> wrote:
>
> While trying to update the gst1-plugins-base package, I came across a
> compiler error:
>
> CC libgsttag_1.0_la-gstxmptag.lo
> In file included from gstxmptag.c:42:0:
> /home/mike/Source/openwrt-build-flyn.org/openwrt-herald/staging_dir/toolchain-x86_64_gcc-7.4.0_musl/include/fortify/stdio.h: In function 'snprintf':
> /home/mike/Source/openwrt-build-flyn.org/openwrt-herald/staging_dir/toolchain-x86_64_gcc-7.4.0_musl/include/fortify/stdio.h:101:2: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]
> return __orig_snprintf(__s, __n, __f, __builtin_va_arg_pack());
> ^~~~~~
> /home/mike/Source/openwrt-build-flyn.org/openwrt-herald/staging_dir/toolchain-x86_64_gcc-7.4.0_musl/include/fortify/stdio.h: In function 'sprintf':
> /home/mike/Source/openwrt-build-flyn.org/openwrt-herald/staging_dir/toolchain-x86_64_gcc-7.4.0_musl/include/fortify/stdio.h:110:3: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]
> __r = __orig_snprintf(__s, __b, __f, __builtin_va_arg_pack());
> ^~~
> /home/mike/Source/openwrt-build-flyn.org/openwrt-herald/staging_dir/toolchain-x86_64_gcc-7.4.0_musl/include/fortify/stdio.h:114:3: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]
> __r = __orig_sprintf(__s, __f, __builtin_va_arg_pack());
> ^~~
> cc1: all warnings being treated as errors
> make[9]: *** [Makefile:856: libgsttag_1.0_la-gstxmptag.lo] Error 1
>
> It seems this follows from the use of -Werror=format-nonliteral. The
> definition in musl's stdio.h is as follows:
>
> _FORTIFY_FN(snprintf) int snprintf(char *__s, size_t __n, const char *__f, ...)
> {
> size_t __b = __builtin_object_size(__s, 0);
>
> if (__n > __b)
> __builtin_trap();
> return __orig_snprintf(__s, __n, __f, __builtin_va_arg_pack());
> }
>
> Other packages address this locally by setting TARGET_CFLAGS to include
> -Wno-format-nonliteral. See for example the commit "package/elfutils:
> add CFLAG -Wno-format-nonliteral."
>
> Is there a more global way to address this?
The issue is probably missing __attribute__((format(printf, x, x))) in
function declarations in fortify-headers. I can whip up a patch if
you'd like.
>
> --
> Mike
>
> :wq
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list