[lttng-dev] [PATCH] add_context.c : Document return values, simplify session_name assignment in cmd_add_context()

Thibault, Daniel Daniel.Thibault at drdc-rddc.gc.ca
Tue Jan 31 14:04:38 EST 2012


>From 46d00e14190d536f428c25c0e969dde051845a48 Tue, 31 Jan 2012 14:02:51 -0500
From: Daniel U. Thibault <daniel.thibault at drdc-rddc.gc.ca>
Date: Tue, 31 Jan 2012 14:02:00 -0500
Subject: [PATCH] add_context.c : Document return values, simplify session_name assignment in cmd_add_context()

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

diff --git a/src/bin/lttng/commands/add_context.c b/src/bin/lttng/commands/add_context.c
index ce65024..2f6f11c 100644
--- a/src/bin/lttng/commands/add_context.c
+++ b/src/bin/lttng/commands/add_context.c
@@ -340,7 +340,8 @@
 }
 
 /*
- * Find context numerical value from string.
+ * Find context numerical value from string (which must not be NULL).
+ * Returns -1 if not found.
  */
 static int find_ctx_type_idx(const char *opt)
 {
@@ -360,6 +361,7 @@
 
 /*
  * Add context to channel or event.
+ * Returns a CMD_* result.
  */
 static int add_context(char *session_name)
 {
@@ -445,6 +447,7 @@
 
 /*
  * Add context to channel or event.
+ * Returns one of the CMD_* result values.
  */
 int cmd_add_context(int argc, const char **argv)
 {
@@ -514,14 +517,10 @@
 		}
 	}
 
-	if (!opt_session_name) {
-		session_name = get_session_name();
-		if (session_name == NULL) {
-			ret = CMD_ERROR;
-			goto end;
-		}
-	} else {
-		session_name = opt_session_name;
+	session_name = (opt_session_name ? opt_session_name : get_session_name() );
+	if (session_name == NULL) {
+		ret = CMD_ERROR;
+		goto end;
 	}
 
 	ret = add_context(session_name);
------------------------------

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