Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openrc-init: replace putenv with setenv #711

Merged
merged 1 commit into from
Jul 23, 2024

Conversation

floppym
Copy link
Contributor

@floppym floppym commented May 28, 2024

Avoids compiler warning about discarded const.

Avoids compiler warning about discarded const.

Signed-off-by: Mike Gilbert <[email protected]>
@navi-desu
Copy link
Member

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

@floppym
Copy link
Contributor Author

floppym commented Jul 23, 2024

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));
      |                    ~~~~~~^~~~~~~~

@navi-desu
Copy link
Member

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.

@navi-desu navi-desu merged commit ca1901e into OpenRC:master Jul 23, 2024
5 checks passed
@navi-desu
Copy link
Member

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants