diff mbox

[lttng-modules] Fix: use of uninitialized ret value in lttng_abi_open_metadata_stream

Message ID 1489001551-14259-1-git-send-email-francis.deslauriers@efficios.com
State Accepted, archived
Headers show

Commit Message

Francis Deslauriers March 8, 2017, 7:32 p.m. UTC
Fixes the following compiler warning:

lttng-abi.c: In function ‘lttng_metadata_ioctl’:
lttng-abi.c:971:6: warning: ‘ret’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  int ret;
      ^

Signed-off-by: Francis Deslauriers <francis.deslauriers at efficios.com>
---
 lttng-abi.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Mathieu Desnoyers March 8, 2017, 7:38 p.m. UTC | #1
merged into master, 2.9, 2.8, thanks!

Mathieu

----- On Mar 8, 2017, at 2:32 PM, Francis Deslauriers francis.deslauriers at efficios.com wrote:

> Fixes the following compiler warning:
> 
> lttng-abi.c: In function ‘lttng_metadata_ioctl’:
> lttng-abi.c:971:6: warning: ‘ret’ may be used uninitialized in this function
> [-Wmaybe-uninitialized]
>  int ret;
>      ^
> 
> Signed-off-by: Francis Deslauriers <francis.deslauriers at efficios.com>
> ---
> lttng-abi.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/lttng-abi.c b/lttng-abi.c
> index e193f43..478a591 100644
> --- a/lttng-abi.c
> +++ b/lttng-abi.c
> @@ -998,8 +998,11 @@ int lttng_abi_open_metadata_stream(struct file
> *channel_file)
> 		goto notransport;
> 	}
> 
> -	if (!lttng_kref_get(&session->metadata_cache->refcount))
> +	if (!lttng_kref_get(&session->metadata_cache->refcount)) {
> +		ret = -EOVERFLOW;
> 		goto kref_error;
> +	}
> +
> 	ret = lttng_abi_create_stream_fd(channel_file, stream_priv,
> 			&lttng_metadata_ring_buffer_file_operations);
> 	if (ret < 0)
> --
> 2.7.4
diff mbox

Patch

diff --git a/lttng-abi.c b/lttng-abi.c
index e193f43..478a591 100644
--- a/lttng-abi.c
+++ b/lttng-abi.c
@@ -998,8 +998,11 @@  int lttng_abi_open_metadata_stream(struct file *channel_file)
 		goto notransport;
 	}
 
-	if (!lttng_kref_get(&session->metadata_cache->refcount))
+	if (!lttng_kref_get(&session->metadata_cache->refcount)) {
+		ret = -EOVERFLOW;
 		goto kref_error;
+	}
+
 	ret = lttng_abi_create_stream_fd(channel_file, stream_priv,
 			&lttng_metadata_ring_buffer_file_operations);
 	if (ret < 0)