From: Sooyoung Ha Date: Sun, 1 Nov 2015 10:49:53 +0000 (+0900) Subject: debug: fix a bug about reading debugch name X-Git-Tag: TizenStudio_2.0_p2.3.2~182 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c780ef730c7383e9f3de167893f53f650da07558;p=sdk%2Femulator%2Fqemu.git debug: fix a bug about reading debugch name The legacy code designed that DEBUGCH file always has a newline character end of it, code tried to remove(means changed it to null char) the last char. But surely, DEBUGCH file might not have the newline, it could cause the unexpected behavior. So I add the newline check code. Change-Id: Id5eb667adcdeef7fa3920069afc1e936100107ce Signed-off-by: Sooyoung Ha --- diff --git a/tizen/src/util/new_debug_ch.c b/tizen/src/util/new_debug_ch.c index acb21a0..073a4b0 100644 --- a/tizen/src/util/new_debug_ch.c +++ b/tizen/src/util/new_debug_ch.c @@ -139,6 +139,8 @@ static void parse_options(const char *str) char *opt, *next, *options; unsigned int i; + fprintf(stdout, "Enabled debug channels: [%s]\n", str); + if (!(options = g_strdup(str))) { return; } @@ -237,6 +239,7 @@ static void debug_init(void) debug = getenv("DEBUGCH"); } else { if ((tmp = (char *)malloc(1024 + 1)) == NULL){ + fprintf(stderr, "failed to malloc()\n"); nb_debug_options = -1; fclose(fp); return; @@ -252,9 +255,17 @@ static void debug_init(void) nb_debug_options = -1; return; } + /* + * Announcement + * This code designed that calls fgets() only once. + * So if you want to use DEBUGCH file for debuging, + * you should make it to single line, comma separated, no blank space. + */ const char* str = fgets(tmp, 1024, fp); if (str) { - tmp[strlen(tmp) - 1] = 0; + if (tmp[strlen(tmp) - 1] == '\n') { + tmp[strlen(tmp) - 1] = '\0'; + } debug = tmp; } @@ -265,6 +276,7 @@ static void debug_init(void) if (!g_strcmp0(debug, "help")) { debug_usage(); } + fprintf(stdout, "DEBUGCH has enabled.\n"); parse_options(debug); }