Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
From: Daniel.Thibault@drdc-rddc.gc.ca (Thibault, Daniel)
Subject: [lttng-dev] [PATCH] add_context.c : Document return values, simplify session_name assignment in cmd_add_context()
Date: Tue, 31 Jan 2012 14:04:38 -0500	[thread overview]
Message-ID: <3CA1A65C03C1A34C81BBC6272782E696808A7D@valcartierex01.valcartier.drdc-rddc.gc.ca> (raw)
In-Reply-To: <mailman.1.1328029202.19563.lttng-dev@lists.lttng.org>

From 46d00e14190d536f428c25c0e969dde051845a48 Tue, 31 Jan 2012 14:02:51 -0500
From: Daniel U. Thibault <daniel.thibault@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/>



  parent reply	other threads:[~2012-01-31 19:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.1.1328029202.19563.lttng-dev@lists.lttng.org>
2012-01-31 17:31 ` [lttng-dev] [PATCH] Harmonise lttng.h and lttng-ctl.c documentation Thibault, Daniel
2012-01-31 19:04 ` Thibault, Daniel [this message]
2012-01-31 19:32 ` [lttng-dev] [PATCH] create.c : Fix memory leak Thibault, Daniel
2012-01-31 20:15 ` [lttng-dev] [PATCH] disable_channels.c improvements and fixes Thibault, Daniel
2012-01-31 21:41 ` [lttng-dev] [PATCH] disable_channels.c and enable_channels.c Thibault, Daniel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3CA1A65C03C1A34C81BBC6272782E696808A7D@valcartierex01.valcartier.drdc-rddc.gc.ca \
    --to=daniel.thibault@drdc-rddc.gc.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox