diff mbox series

libtracefs: Fix bug in tracefs_instances()

Message ID 20210707130523.67268-1-y.karadz@gmail.com (mailing list archive)
State Accepted
Commit 8aa31bd3909d053c42707ac3e23c404b9fcb1e4f
Headers show
Series libtracefs: Fix bug in tracefs_instances() | expand

Commit Message

Yordan Karadzhov July 7, 2021, 1:05 p.m. UTC
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)
Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 src/tracefs-instance.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Steven Rostedt July 7, 2021, 1:47 p.m. UTC | #1
On Wed,  7 Jul 2021 16:05:23 +0300
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:

> 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)
> Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
> ---
>  src/tracefs-instance.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/tracefs-instance.c b/src/tracefs-instance.c
> index 11fb580..d601db2 100644
> --- a/src/tracefs-instance.c
> +++ b/src/tracefs-instance.c
> @@ -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
diff mbox series

Patch

diff --git a/src/tracefs-instance.c b/src/tracefs-instance.c
index 11fb580..d601db2 100644
--- a/src/tracefs-instance.c
+++ b/src/tracefs-instance.c
@@ -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;
 }