[lttng-dev] [PATCH lttng-tools 20/24] Android : %m[^] not supported in fscanf

Charles Briere c.briere at samsung.com
Mon Oct 27 16:49:30 EDT 2014


From: Charles Briere <c.briere at samsung.com>

Replacing %m[^] and char* by %[^] and char[LTTNG_SYMBOL_NAME_LEN]

Signed-off-by: Charles Briere <c.briere at samsung.com>
---
 src/bin/lttng-sessiond/kernel.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c
index 2aeef26..3e1eff3 100644
--- a/src/bin/lttng-sessiond/kernel.c
+++ b/src/bin/lttng-sessiond/kernel.c
@@ -613,7 +613,7 @@ error:
 ssize_t kernel_list_events(int tracer_fd, struct lttng_event **events)
 {
 	int fd, ret;
-	char *event;
+	char event[LTTNG_SYMBOL_NAME_LEN];
 	size_t nbmem, count = 0;
 	FILE *fp;
 	struct lttng_event *elist;
@@ -644,7 +644,7 @@ ssize_t kernel_list_events(int tracer_fd, struct lttng_event **events)
 		goto end;
 	}
 
-	while (fscanf(fp, "event { name = %m[^;]; };\n", &event) == 1) {
+	while (fscanf(fp,"event { name = %[^;]; };\n", &event) == 1) {
 		if (count >= nbmem) {
 			struct lttng_event *new_elist;
 			size_t new_nbmem;
@@ -655,7 +655,6 @@ ssize_t kernel_list_events(int tracer_fd, struct lttng_event **events)
 			new_elist = realloc(elist, new_nbmem * sizeof(struct lttng_event));
 			if (new_elist == NULL) {
 				PERROR("realloc list events");
-				free(event);
 				free(elist);
 				count = -ENOMEM;
 				goto end;
@@ -670,7 +669,6 @@ ssize_t kernel_list_events(int tracer_fd, struct lttng_event **events)
 		elist[count].name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
 		elist[count].enabled = -1;
 		count++;
-		free(event);
 	}
 
 	*events = elist;
-- 
2.1.2



More information about the lttng-dev mailing list