From 780133f9ae7fada462714b47e79d26075bbd9abe Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Fri, 28 Oct 2011 21:29:50 -0700 Subject: Convert DetermineClientCmd to use strdup instead of malloc+strncpy *cmdname is initialized to NULL earlier in the function, so it's okay to overwrite it with NULL if strdup fails, don't need that extra check. Signed-off-by: Alan Coopersmith Reviewed-by: Jeremy Huddleston --- os/client.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/os/client.c b/os/client.c index b5349778b..4aec097e1 100644 --- a/os/client.c +++ b/os/client.c @@ -149,13 +149,7 @@ void DetermineClientCmd(pid_t pid, const char **cmdname, const char **cmdargs) cmdsize = strlen(path) + 1; if (cmdname) { - char *name = malloc(cmdsize); - if (name) - { - strncpy(name, path, cmdsize); - name[cmdsize - 1] = '\0'; - *cmdname = name; - } + *cmdname = strdup(path); } /* Construct the arguments for client process. */ -- cgit v1.2.3