diff mbox series

[v2,2/4] Proper initialization of n to 0 for getline to function correctly.

Message ID 20241011031937.92216-3-demeng@redhat.com
State New
Headers show
Series qemu-ga: Fix some potential issues find by coverity | expand

Commit Message

Dehan Meng Oct. 11, 2024, 3:19 a.m. UTC
Signed-off-by: Dehan Meng <demeng@redhat.com>
---
 qga/commands-linux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Daniel P. Berrangé Oct. 14, 2024, 9:57 a.m. UTC | #1
On Fri, Oct 11, 2024 at 11:19:35AM +0800, Dehan Meng wrote:
> Signed-off-by: Dehan Meng <demeng@redhat.com>
> ---
>  qga/commands-linux.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

> 
> diff --git a/qga/commands-linux.c b/qga/commands-linux.c
> index 2c2b5f4ff2..b905f33a57 100644
> --- a/qga/commands-linux.c
> +++ b/qga/commands-linux.c
> @@ -2126,7 +2126,7 @@ GuestNetworkRouteList *qmp_guest_network_get_route(Error **errp)
>      GuestNetworkRouteList *head = NULL, **tail = &head;
>      const char *routeFiles[] = {"/proc/net/route", "/proc/net/ipv6_route"};
>      FILE *fp;
> -    size_t n;
> +    size_t n = 0;
>      char *line = NULL;
>      int firstLine;
>      int is_ipv6;
> -- 
> 2.40.1
> 
> 

With regards,
Daniel
diff mbox series

Patch

diff --git a/qga/commands-linux.c b/qga/commands-linux.c
index 2c2b5f4ff2..b905f33a57 100644
--- a/qga/commands-linux.c
+++ b/qga/commands-linux.c
@@ -2126,7 +2126,7 @@  GuestNetworkRouteList *qmp_guest_network_get_route(Error **errp)
     GuestNetworkRouteList *head = NULL, **tail = &head;
     const char *routeFiles[] = {"/proc/net/route", "/proc/net/ipv6_route"};
     FILE *fp;
-    size_t n;
+    size_t n = 0;
     char *line = NULL;
     int firstLine;
     int is_ipv6;