[Cluster-devel] [PATCH 08/41] cman_tool: don't use envp from main
Steven Whitehouse
swhiteho at redhat.com
Wed Nov 23 10:28:40 UTC 2011
Hi,
On Wed, 2011-11-23 at 11:15 +0100, Fabio M. Di Nitto wrote:
> according to wikipedia it is a microsoft extensions. Use __environ
> directly from unistd.h
>
> Spotted by Coverity Scan
>
> Signed-off-by: Fabio M. Di Nitto <fdinitto at redhat.com>
> ---
> :100644 100644 60091c9... 6c5744e... M cman/cman_tool/cman_tool.h
> :100644 100644 872528b... b92090c... M cman/cman_tool/join.c
> :100644 100644 a336c42... 6d8a1eb... M cman/cman_tool/main.c
> cman/cman_tool/cman_tool.h | 3 +--
> cman/cman_tool/join.c | 13 +++++++------
> cman/cman_tool/main.c | 10 +++++-----
> 3 files changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/cman/cman_tool/cman_tool.h b/cman/cman_tool/cman_tool.h
> index 60091c9..6c5744e 100644
> --- a/cman/cman_tool/cman_tool.h
> +++ b/cman/cman_tool/cman_tool.h
> @@ -19,7 +19,6 @@
> #include <fcntl.h>
> #include <netdb.h>
> #include <limits.h>
> -#include <unistd.h>
>
> extern char *prog_name;
>
> @@ -105,6 +104,6 @@ struct commandline
> };
> typedef struct commandline commandline_t;
>
> -int join(commandline_t *comline, char *envp[]);
> +int join(commandline_t *comline);
>
> #endif /* __CMAN_TOOL_DOT_H__ */
> diff --git a/cman/cman_tool/join.c b/cman/cman_tool/join.c
> index 872528b..b92090c 100644
> --- a/cman/cman_tool/join.c
> +++ b/cman/cman_tool/join.c
> @@ -1,4 +1,5 @@
> #include <errno.h>
> +#include <unistd.h>
> #include <sys/wait.h>
> #include <stdint.h>
> #include <signal.h>
> @@ -119,7 +120,7 @@ static int check_corosync_status(pid_t pid)
> return status;
> }
>
> -int join(commandline_t *comline, char *main_envp[])
> +int join(commandline_t *comline)
> {
> int i, err;
> int envptr = 0;
> @@ -205,9 +206,9 @@ int join(commandline_t *comline, char *main_envp[])
>
> /* Copy any COROSYNC_* env variables to the new daemon */
> i=0;
> - while (i < MAX_ARGS && main_envp[i]) {
> - if (strncmp(main_envp[i], "COROSYNC_", 9) == 0)
> - envp[envptr++] = main_envp[i];
> + while (i < MAX_ARGS && __environ[i]) {
> + if (strncmp(__environ[i], "COROSYNC_", 9) == 0)
> + envp[envptr++] = __environ[i];
> i++;
> }
Why not just use getenv() ?
Steve.
More information about the Cluster-devel
mailing list