[libvirt] [PATCH] lxc_controller: Don't leak @name

The @name variable is VIR_STRDUP()-ed into, but never freed. In fact, there's no need to duplicate a command line argument since all places where @name is used expect const char. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/lxc/lxc_controller.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index c013147..1b43bd2 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -2249,7 +2249,7 @@ int main(int argc, char *argv[]) { pid_t pid; int rc = -1; - char *name = NULL; + const char *name = NULL; size_t nveths = 0; char **veths = NULL; int handshakeFd = -1; @@ -2300,8 +2300,7 @@ int main(int argc, char *argv[]) break; case 'n': - if (VIR_STRDUP(name, optarg) < 0) - goto cleanup; + name = optarg; break; case 'v': -- 1.8.5.1

The argument is --handshakefd not --handshake. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/lxc/lxc_controller.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 1b43bd2..a2ae599 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -2365,7 +2365,7 @@ int main(int argc, char *argv[]) } if (handshakeFd < 0) { - fprintf(stderr, "%s: missing --handshake argument for container PTY\n", + fprintf(stderr, "%s: missing --handshakefd argument for container PTY\n", argv[0]); goto cleanup; } -- 1.8.5.1

On 01/07/2014 07:56 AM, Michal Privoznik wrote:
The argument is --handshakefd not --handshake.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/lxc/lxc_controller.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ACK.
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 1b43bd2..a2ae599 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -2365,7 +2365,7 @@ int main(int argc, char *argv[]) }
if (handshakeFd < 0) { - fprintf(stderr, "%s: missing --handshake argument for container PTY\n", + fprintf(stderr, "%s: missing --handshakefd argument for container PTY\n",
Not in this patch, but we should probably add _() marking to all the error messages in main() after the point of our textdomain() call earlier, so that a user typing the command line will get a localized error message. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 01/07/2014 07:56 AM, Michal Privoznik wrote:
The @name variable is VIR_STRDUP()-ed into, but never freed. In fact, there's no need to duplicate a command line argument since all places where @name is used expect const char.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/lxc/lxc_controller.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Michal Privoznik