[email protected] skribis:
> From: Olivier Dion <[email protected]>
>
> This is an amendment to 84bf84032208e21d20ad13f3033d4fca3a512014.
>
> The warning was only emitted for calling `environ', even if only reading
> and no mutation occurred.
>
> However, it is correct to read the environment in a
> multi-threaded process. It is however unsafe to mutate it.
>
> The same logic also applies to `putenv'.
>
> * libguile/posix.c
> (maybe_warn_about_environ_mutation): New private procedure ...
> (scm_environ): ... called here when mutating the environment ...
> (scm_putenv): ... and here.
>
> Signed-off-by: Olivier Dion <[email protected]>
Applied with the changes below, thanks!
Ludo'.
diff --git a/NEWS b/NEWS
index d5729a913..bad69ef03 100644
--- a/NEWS
+++ b/NEWS
@@ -88,6 +88,8 @@ every line in a file.
in turn, would trigger warnings from 'primitive-fork' and 'environ'
suggesting they are being called in a multi-threaded context, when in
fact user code did not create any thread.
+** Calling 'environ' without arguments in a multi-threaded program is OK
+ This used to trigger a warning, unduly.
Changes in 3.0.10 (since 3.0.9)
diff --git a/libguile/posix.c b/libguile/posix.c
index d111b8942..dde77b8ee 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -1705,7 +1705,8 @@ SCM_DEFINE (scm_uname, "uname", 0, 0, 0,
#undef FUNC_NAME
#endif /* HAVE_UNAME */
-static void maybe_warn_about_environ_mutation (void)
+static void
+maybe_warn_about_environ_mutation (void)
{
/* Mutating `environ' directly in a multi-threaded program is
undefined behavior. */
@@ -1733,7 +1734,7 @@ SCM_DEFINE (scm_environ, "environ", 0, 1, 0,
else
{
/* Mutating the environment in a multi-threaded program is hazardous. */
- maybe_warn_about_environ_mutation();
+ maybe_warn_about_environ_mutation ();
/* Arrange to not use GC-allocated storage for what goes into
'environ' as libc might reallocate it behind our back. */
@@ -1955,7 +1956,7 @@ SCM_DEFINE (scm_putenv, "putenv", 1, 0, 0,
char *c_str = scm_to_locale_string (str);
/* Mutating the environment in a multi-threaded program is hazardous. */
- maybe_warn_about_environ_mutation();
+ maybe_warn_about_environ_mutation ();
/* Leave C_STR in the environment. */