diff mbox

[net-next,1/2] igb: Fix warning ‘pin’ may be used uninitialized

Message ID 20150305192459.22228.86492.stgit@ahduyck-vm-fedora20
State Awaiting Upstream, archived
Delegated to: David Miller
Headers show

Commit Message

Alexander Duyck March 5, 2015, 7:24 p.m. UTC
When building the kernel using the gcc 4.8.3 compiler included in Fedora 20
I was repeatedly seeing the warning:

 drivers/net/ethernet/intel/igb/igb_ptp.c: In function ‘igb_ptp_feature_enable_i210’:
 drivers/net/ethernet/intel/igb/igb_ptp.c:395:21: warning: ‘pin’ may be used uninitialized in this function
 [-Wmaybe-uninitialized]
   tssdp &= ~ts_sdp_en[pin];
                     ^
 drivers/net/ethernet/intel/igb/igb_ptp.c:471:6: note: ‘pin’ was declared here
   int pin;
       ^

To resolve it I am assigning the pin a value of -1 when it is instantiated.

Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com>
---
 drivers/net/ethernet/intel/igb/igb_ptp.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Kirsher, Jeffrey T March 5, 2015, 7:27 p.m. UTC | #1
On Thu, 2015-03-05 at 11:24 -0800, Alexander Duyck wrote:
> When building the kernel using the gcc 4.8.3 compiler included in
> Fedora 20
> I was repeatedly seeing the warning:
> 
>  drivers/net/ethernet/intel/igb/igb_ptp.c: In function
> ‘igb_ptp_feature_enable_i210’:
>  drivers/net/ethernet/intel/igb/igb_ptp.c:395:21: warning: ‘pin’ may
> be used uninitialized in this function
>  [-Wmaybe-uninitialized]
>    tssdp &= ~ts_sdp_en[pin];
>                      ^
>  drivers/net/ethernet/intel/igb/igb_ptp.c:471:6: note: ‘pin’ was
> declared here
>    int pin;
>        ^
> 
> To resolve it I am assigning the pin a value of -1 when it is
> instantiated.
> 
> Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com>
> ---
>  drivers/net/ethernet/intel/igb/igb_ptp.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks Alex, I have added your patch to my queue.
diff mbox

Patch

diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c
index d20fc8e..525e5c4 100644
--- a/drivers/net/ethernet/intel/igb/igb_ptp.c
+++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
@@ -468,7 +468,7 @@  static int igb_ptp_feature_enable_i210(struct ptp_clock_info *ptp,
 	u32 tsauxc, tsim, tsauxc_mask, tsim_mask, trgttiml, trgttimh;
 	unsigned long flags;
 	struct timespec ts;
-	int pin;
+	int pin = -1;
 	s64 ns;
 
 	switch (rq->type) {