Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
From: douglas.santos@polymtl.ca (Douglas Santos)
Subject: [ltt-dev] [UST PATCH 1/2] sscanf format string
Date: Mon, 13 Sep 2010 13:31:37 -0400	[thread overview]
Message-ID: <1284399098-20338-1-git-send-email-douglas.santos@polymtl.ca> (raw)

Signed-off-by: Douglas Santos <douglas.santos at polymtl.ca>
---
 libust/tracectl.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/libust/tracectl.c b/libust/tracectl.c
index dd61ebe..24a0231 100644
--- a/libust/tracectl.c
+++ b/libust/tracectl.c
@@ -529,7 +529,7 @@ static unsigned int pow2_higher_or_eq(unsigned int v)
 static int do_cmd_set_subbuf_size(const char *recvbuf, struct ustcomm_source *src)
 {
 	char *channel_slash_size;
-	char ch_name[256]="";
+	char *ch_name;
 	unsigned int size, power;
 	int retval = 0;
 	struct ust_trace *trace;
@@ -540,7 +540,7 @@ static int do_cmd_set_subbuf_size(const char *recvbuf, struct ustcomm_source *sr
 	DBG("set_subbuf_size");
 
 	channel_slash_size = nth_token(recvbuf, 1);
-	sscanf(channel_slash_size, "%255[^/]/%u", ch_name, &size);
+	sscanf(channel_slash_size, "%a[^/]/%u", &ch_name, &size);
 
 	if(ch_name == NULL) {
 		ERR("cannot parse channel");
@@ -585,7 +585,7 @@ static int do_cmd_set_subbuf_size(const char *recvbuf, struct ustcomm_source *sr
 static int do_cmd_set_subbuf_num(const char *recvbuf, struct ustcomm_source *src)
 {
 	char *channel_slash_num;
-	char ch_name[256]="";
+	char *ch_name;
 	unsigned int num;
 	int retval = 0;
 	struct ust_trace *trace;
@@ -596,7 +596,7 @@ static int do_cmd_set_subbuf_num(const char *recvbuf, struct ustcomm_source *src
 	DBG("set_subbuf_num");
 
 	channel_slash_num = nth_token(recvbuf, 1);
-	sscanf(channel_slash_num, "%255[^/]/%u", ch_name, &num);
+	sscanf(channel_slash_num, "%a[^/]/%u", &ch_name, &num);
 
 	if(ch_name == NULL) {
 		ERR("cannot parse channel");
@@ -1042,10 +1042,10 @@ int process_client_cmd(char *recvbuf, struct ustcomm_source *src)
 	}
 	else if(nth_token_is(recvbuf, "enable_marker", 0) == 1) {
 		char *channel_slash_name = nth_token(recvbuf, 1);
-		char channel_name[256]="";
-		char marker_name[256]="";
+		char *channel_name;
+		char *marker_name;
 
-		result = sscanf(channel_slash_name, "%255[^/]/%255s", channel_name, marker_name);
+		result = sscanf(channel_slash_name, "%a[^/]/%as", &channel_name, &marker_name);
 
 		if(channel_name == NULL || marker_name == NULL) {
 			WARN("invalid marker name");
-- 
1.7.0.4




             reply	other threads:[~2010-09-13 17:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-13 17:31 Douglas Santos [this message]
2010-09-13 17:31 ` [ltt-dev] [UST PATCH 2/2] tracectl cleanup Douglas Santos
2010-09-13 18:15   ` Mathieu Desnoyers

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=1284399098-20338-1-git-send-email-douglas.santos@polymtl.ca \
    --to=douglas.santos@polymtl.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