bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/2] device/net_io.c: add comments and initialize hash_entp


From: Marin Ramesa
Subject: Re: [PATCH 1/2] device/net_io.c: add comments and initialize hash_entp
Date: Mon, 02 Dec 2013 11:55:14 +0100

On 02.12.2013 10:37:08, Justus Winter wrote:
> The other day you were fixing this kind of code, now you're
> introducing it. Maybe there's a better way to silence this warning,
> maybe some attribute.

Maybe initialize to some kind of a template, like this:

From 0b850181995519071d3064c45dbbc31b762bd75a Mon Sep 17 00:00:00 2001
From: Marin Ramesa <mpr@hi.t-com.hr>
Date: Mon, 2 Dec 2013 11:39:33 +0100
Subject: [PATCH] device/net_io.c: initialize hash_entp

---
 device/net_io.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/device/net_io.c b/device/net_io.c
index 1958840..b76ce9a 100644
--- a/device/net_io.c
+++ b/device/net_io.c
@@ -1166,6 +1166,20 @@ net_set_filter(ifp, rcv_port, priority, filter, 
filter_count)
     io_return_t                        rval;
     boolean_t                  in, out;
 
+    /* Initialize hash_entp to quiet GCC warning about uninitialized 
+     * variable. hash_entp is only used when match != 0; in that
+     * case it is properly initialized by kmem_cache_alloc().
+     */
+    net_hash_entry_t template = (net_hash_entry_t)0;
+    int counter;
+    template->chain.next = NULL;
+    template->chain.prev = NULL;
+    ipc_port_init(template->rcv_port, (ipc_space_t)0, (mach_port_t)0);
+    template->rcv_qlimit = 0;
+    for (counter = 0; i < N_NET_HASH_KEYS; i++)
+       template->keys[counter] = 0;
+    hash_entp = template;
+
     /*
      * Check the filter syntax.
      */
-- 
1.8.1.4


reply via email to

[Prev in Thread] Current Thread [Next in Thread]