Skip to contentSkip to conversation

libtracefs: Fix bug in tracefs_instances()

PATCH In review Yordan Karadzhov (VMware) 2 participants 2 messages Jul 7, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libtracefs: Fix bug in tracefs_instances()

The empty string is now made of two elements, because of the hidden first element that stores its size.

Fixes 056a177 (libtracefs: Restructure how string lists work)
---
 src/tracefs-instance.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/tracefs-instance.c +1 -1
index 11fb580..d601db2 100644
@@ -694,7 +694,7 @@ char **tracefs_instances(const char *regex)
 	} else {
 		/* No matches should produce an empty list */
 		if (!list.list)
-			list.list = calloc(1, sizeof(*list.list));
+			list.list = trace_list_create_empty();
 	}
 	return list.list;
 }
Signature · 1 line
2.27.0
#1 lore raw
Quoted 14 lines · On Wed, 7 Jul 2021 16:05:23 +0300 "Yordan Karadzhov (VMware)"…

The empty string is now made of two elements, because of the hidden first element that stores its size.

Fixes 056a177 (libtracefs: Restructure how string lists work)
---
 src/tracefs-instance.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/tracefs-instance.c +0 -0
index 11fb580..d601db2 100644

src/tracefs-instance.c char **tracefs_instances(const char *regex) · line 700

Quoted 8 lines
src/tracefs-instance.c +1 -1
@@ -694,7 +694,7 @@ char **tracefs_instances(const char *regex)
 	} else {
 		/* No matches should produce an empty list */
 		if (!list.list)
-			list.list = calloc(1, sizeof(*list.list));
+			list.list = trace_list_create_empty();
 	}
 	return list.list;
 }

Thanks! I guess I missed one :-p

-- Steve