[lttng-dev] [PATCH] lttng-tools add_context.c : Fixing memory leaks

Thibault, Daniel Daniel.Thibault at drdc-rddc.gc.ca
Mon Jan 30 16:39:50 EST 2012


-----Message d'origine-----
Envoyé : 30 janvier 2012 16:18

> For some reason, this patch does not apply ...
>
> Applying: lttng-tools add_context.c : Fixing memory leaks
> error: patch failed: src/bin/lttng/commands/add_context.c:520
> error: src/bin/lttng/commands/add_context.c: patch does not apply
>
> In the meantime, I've merge the others since there are not using
> lttng/commands/add_context.c
>
> Also, this set of patch had a minor problem having
> "lttng2-lttng-tools-2.0-pre18+-5c73c59/" added to all paths in the diff. Don't
> know why because the previous one were fine...
>
> Please update your git head before resending this one, I've merge your latest
> working patches.

   Concerning the added "lttng2-lttng-tools-2.0-pre18+-5c73c59/" path fragment, that's my bad: I was manually editing that out of last week's patches.

   As for the patch not applying, I guess we're getting out of sync again.  But now that I've been told what the magic words Eclipse expects are (thanks Alexandre!), I should be able to get this back on track.

   Meanwhile I've got one more little patch ready so I might as well send it out: it simplifies the copy_string() calls of lttng_enable_event() and lttng_disable_event().

------------------------------
>From 7d6f525e082259466cd58ef27670a40944445c65 Mon, 30 Jan 2012 16:29:56 -0500
From: Daniel U. Thibault <daniel.thibault at drdc-rddc.gc.ca>
Date: Mon, 30 Jan 2012 16:29:44 -0500
Subject: [PATCH] lttng-ctl : Simplify copy_string() of lttng_enable_event() and lttng_disable_event()

Signed-off-by: Daniel U. Thibault <daniel.thibault at drdc-rddc.gc.ca>

diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c
index 65aa3e3..fa901c7 100644
--- a/src/lib/lttng-ctl/lttng-ctl.c
+++ b/src/lib/lttng-ctl/lttng-ctl.c
@@ -515,13 +515,9 @@
 	}
 
 	/* If no channel name, we put the default name */
-	if (channel_name == NULL) {
-		copy_string(lsm.u.enable.channel_name, DEFAULT_CHANNEL_NAME,
-				sizeof(lsm.u.enable.channel_name));
-	} else {
-		copy_string(lsm.u.enable.channel_name, channel_name,
-				sizeof(lsm.u.enable.channel_name));
-	}
+	copy_string(lsm.u.enable.channel_name,
+			(channel_name ? channel_name : DEFAULT_CHANNEL_NAME),
+			sizeof(lsm.u.enable.channel_name));
 
 	copy_lttng_domain(&lsm.domain, &handle->domain);
 
@@ -553,13 +549,9 @@
 		return -1;
 	}
 
-	if (channel_name) {
-		copy_string(lsm.u.disable.channel_name, channel_name,
-				sizeof(lsm.u.disable.channel_name));
-	} else {
-		copy_string(lsm.u.disable.channel_name, DEFAULT_CHANNEL_NAME,
-				sizeof(lsm.u.disable.channel_name));
-	}
+	copy_string(lsm.u.disable.channel_name,
+			(channel_name ? channel_name : DEFAULT_CHANNEL_NAME),
+			sizeof(lsm.u.disable.channel_name));
 
 	copy_lttng_domain(&lsm.domain, &handle->domain);
------------------------------

Daniel U. Thibault
R & D pour la défense Canada - Valcartier (RDDC Valcartier) / Defence R&D Canada - Valcartier (DRDC Valcartier) Système de systèmes (SdS) / System of Systems (SoS) Solutions informatiques et expérimentations (SIE) / Computing Solutions and Experimentations (CSE)
2459 Boul. Pie XI Nord
Québec, QC  G3J 1X5
CANADA
Vox : (418) 844-4000 x4245
Fax : (418) 844-4538
NAC: 918V QSDJ
Gouvernement du Canada / Government of Canada <http://www.valcartier.drdc-rddc.gc.ca/>



More information about the lttng-dev mailing list