[Pkg-gnupg-commit] [gnupg2] 156/292: common: Use strconcat in gnupg_setenv.
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Mon Nov 21 06:31:37 UTC 2016
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch master
in repository gnupg2.
commit 7983f8758703071710c11bf2a255efcd71836b65
Author: Werner Koch <wk at gnupg.org>
Date: Tue Oct 25 08:59:44 2016 +0200
common: Use strconcat in gnupg_setenv.
* common/sysutils.c (gnupg_setenv): Replace malloc+stpcpy by
strconcat. Indent cpp conditionals.
(gnupg_unsetenv): Indent cpp conditionals.
Signed-off-by: Werner Koch <wk at gnupg.org>
---
common/sysutils.c | 44 ++++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/common/sysutils.c b/common/sysutils.c
index 85eb203..ab2012c 100644
--- a/common/sysutils.c
+++ b/common/sysutils.c
@@ -754,8 +754,8 @@ gnupg_setenv (const char *name, const char *value, int overwrite)
(void)value;
(void)overwrite;
return 0;
-#else
-#if defined(HAVE_W32_SYSTEM)
+#else /*!W32CE*/
+# ifdef HAVE_W32_SYSTEM
/* Windows maintains (at least) two sets of environment variables.
One set can be accessed by GetEnvironmentVariable and
SetEnvironmentVariable. This set is inherited by the children.
@@ -773,11 +773,11 @@ gnupg_setenv (const char *name, const char *value, int overwrite)
return -1;
}
}
-#endif
+# endif /*W32*/
-#if defined(HAVE_SETENV)
+# ifdef HAVE_SETENV
return setenv (name, value, overwrite);
-#else
+# else /*!HAVE_SETENV*/
if (! getenv (name) || overwrite)
{
char *buf;
@@ -788,18 +788,17 @@ gnupg_setenv (const char *name, const char *value, int overwrite)
gpg_err_set_errno (EINVAL);
return -1;
}
- buf = xtrymalloc (strlen (name) + 1 + strlen (value) + 1);
+ buf = strconcat (name, "=", value, NULL);
if (!buf)
return -1;
- strcpy (stpcpy (stpcpy (buf, name), "="), value);
-#if __GNUC__
-# warning no setenv - using putenv but leaking memory.
-#endif
+# if __GNUC__
+# warning no setenv - using putenv but leaking memory.
+# endif
return putenv (buf);
}
return 0;
-#endif
-#endif
+# endif /*!HAVE_SETENV*/
+#endif /*!W32CE*/
}
@@ -809,8 +808,8 @@ gnupg_unsetenv (const char *name)
#ifdef HAVE_W32CE_SYSTEM
(void)name;
return 0;
-#else
-#if defined(HAVE_W32_SYSTEM)
+#else /*!W32CE*/
+# ifdef HAVE_W32_SYSTEM
/* Windows maintains (at least) two sets of environment variables.
One set can be accessed by GetEnvironmentVariable and
SetEnvironmentVariable. This set is inherited by the children.
@@ -822,10 +821,11 @@ gnupg_unsetenv (const char *name)
gpg_err_set_errno (EINVAL); /* (Might also be ENOMEM.) */
return -1;
}
-#endif
-#if defined(HAVE_UNSETENV)
+# endif /*W32*/
+
+# ifdef HAVE_UNSETENV
return unsetenv (name);
-#else
+# else /*!HAVE_UNSETENV*/
{
char *buf;
@@ -837,13 +837,13 @@ gnupg_unsetenv (const char *name)
buf = xtrystrdup (name);
if (!buf)
return -1;
-#if __GNUC__
-# warning no unsetenv - trying putenv but leaking memory.
-#endif
+# if __GNUC__
+# warning no unsetenv - trying putenv but leaking memory.
+# endif
return putenv (buf);
}
-#endif
-#endif
+# endif /*!HAVE_UNSETENV*/
+#endif /*!W32CE*/
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git
More information about the Pkg-gnupg-commit
mailing list