Closed floppym closed 2 months ago
i'm not getting any warnings here while building openrc-init, anything changed i wonder?
tho merging this might still be desirable as setenv is nicer than putenv
Here's the warning I get with GCC 14.
[12/15] ccache cc -Isrc/openrc-init/openrc-init.p -Isrc/openrc-init -I../src/openrc-init -Isrc/shared -I../src/shared -Isrc/libeinfo -I../src/libeinfo -Isrc/librc -I../src/librc -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -std=c99 -O0 -g -DRC_DEBUG -D_DEFAULT_SOURCE -Wcast-align -Wcast-qual -Wdeclaration-after-statement -Wformat=2 -Winline -Wmissing-declarations -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wsequence-point -Wshadow -Wwrite-strings -Werror=implicit-int -Werror=implicit-function-declaration -Werror=int-conversion -DHAVE_MALLOC_EXTENDED_ATTRIBUTE -DHAVE_CLOSE_RANGE -DHAVE_STRLCPY -DHAVE_SELINUX -MD -MQ src/openrc-init/openrc-init.p/openrc-init.c.o -MF src/openrc-init/openrc-init.p/openrc-init.c.o.d -o src/openrc-init/openrc-init.p/openrc-init.c.o -c ../src/openrc-init/openrc-init.c
../src/openrc-init/openrc-init.c: In function ‘main’:
../src/openrc-init/openrc-init.c:245:40: warning: passing argument 1 of ‘putenv’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
245 | putenv("SELINUX_INIT=YES");
| ^~~~~~~~~~~~~~~~~~
In file included from ../src/openrc-init/openrc-init.c:26:
/usr/include/stdlib.h:786:26: note: expected ‘char *’ but argument is of type ‘const char *’
786 | extern int putenv (char *__string) __THROW __nonnull ((1));
| ~~~~~~^~~~~~~~
i see, the function signature for putenv really is non-const, unsure why gcc-13 didn't warn here, but either way, we should fix this.
thanks!
Avoids compiler warning about discarded const.