Patchwork [U-Boot,04/12] drivers/net/enc28j60.c: Fix GCC 4.6 warnings

login
register
mail settings
Submitter Anatolij Gustschin
Date Nov. 15, 2011, 11:20 p.m.
Message ID <1321399263-13826-5-git-send-email-agust@denx.de>
Download mbox | patch
Permalink /patch/125890/
State Accepted
Commit da5406655ae4762c36a221b6b0ac6f1c334ae660
Headers show

Comments

Anatolij Gustschin - Nov. 15, 2011, 11:20 p.m.
Fix:
enc28j60.c: In function 'enc_receive':
enc28j60.c:435:5: warning: variable 'eir_reg' set but not used
[-Wunused-but-set-variable]
enc28j60.c: In function 'enc_poll':
enc28j60.c:503:5: warning: variable 'estat_reg' set but not used
[-Wunused-but-set-variable]

Signed-off-by: Anatolij Gustschin <agust@denx.de>
---
 drivers/net/enc28j60.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
Mike Frysinger - Nov. 16, 2011, 3:58 p.m.
On Tuesday 15 November 2011 18:20:55 Anatolij Gustschin wrote:
> -		eir_reg = enc_r8(enc, CTL_REG_EIR);
> +		(void)enc_r8(enc, CTL_REG_EIR);

is that (void) actually necessary ?  last i looked, gcc didn't actually care.  
which means you should drop the (void).
-mike
Wolfgang Denk - Nov. 16, 2011, 8:29 p.m.
Dear Anatolij Gustschin,

In message <1321399263-13826-5-git-send-email-agust@denx.de> you wrote:
> Fix:
> enc28j60.c: In function 'enc_receive':
> enc28j60.c:435:5: warning: variable 'eir_reg' set but not used
> [-Wunused-but-set-variable]
> enc28j60.c: In function 'enc_poll':
> enc28j60.c:503:5: warning: variable 'estat_reg' set but not used
> [-Wunused-but-set-variable]
> 
> Signed-off-by: Anatolij Gustschin <agust@denx.de>
> ---
>  drivers/net/enc28j60.c |    8 +++-----
>  1 files changed, 3 insertions(+), 5 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk
Wolfgang Denk - Nov. 16, 2011, 8:30 p.m.
Dear Mike Frysinger,

In message <201111161058.57150.vapier@gentoo.org> you wrote:
>
> On Tuesday 15 November 2011 18:20:55 Anatolij Gustschin wrote:
> > -		eir_reg = enc_r8(enc, CTL_REG_EIR);
> > +		(void)enc_r8(enc, CTL_REG_EIR);
>
> is that (void) actually necessary ?  last i looked, gcc didn't actually care.  
> which means you should drop the (void).

It's not really necessary, but always a good indication to the reader
that we intentionally ignore the return code.

Best regards,

Wolfgang Denk

Patch

diff --git a/drivers/net/enc28j60.c b/drivers/net/enc28j60.c
index d55cacd..e2011ae 100644
--- a/drivers/net/enc28j60.c
+++ b/drivers/net/enc28j60.c
@@ -432,7 +432,6 @@  static void enc_receive(enc_dev_t *enc)
 	u16 pkt_len;
 	u16 copy_len;
 	u16 status;
-	u8 eir_reg;
 	u8 pkt_cnt = 0;
 	u16 rxbuf_rdpt;
 	u8 hbuf[6];
@@ -476,7 +475,7 @@  static void enc_receive(enc_dev_t *enc)
 		/* read pktcnt */
 		pkt_cnt = enc_r8(enc, CTL_REG_EPKTCNT);
 		if (copy_len == 0) {
-			eir_reg = enc_r8(enc, CTL_REG_EIR);
+			(void)enc_r8(enc, CTL_REG_EIR);
 			enc_reset_rx(enc);
 			printf("%s: receive copy_len=0\n", enc->dev->name);
 			continue;
@@ -489,7 +488,7 @@  static void enc_receive(enc_dev_t *enc)
 		NetReceive(packet, pkt_len);
 		if (enc_claim_bus(enc))
 			return;
-		eir_reg = enc_r8(enc, CTL_REG_EIR);
+		(void)enc_r8(enc, CTL_REG_EIR);
 	} while (pkt_cnt);
 	/* Use EPKTCNT not EIR.PKTIF flag, see errata pt. 6 */
 }
@@ -500,14 +499,13 @@  static void enc_receive(enc_dev_t *enc)
 static void enc_poll(enc_dev_t *enc)
 {
 	u8 eir_reg;
-	u8 estat_reg;
 	u8 pkt_cnt;
 
 #ifdef CONFIG_USE_IRQ
 	/* clear global interrupt enable bit in enc28j60 */
 	enc_bclr(enc, CTL_REG_EIE, ENC_EIE_INTIE);
 #endif
-	estat_reg = enc_r8(enc, CTL_REG_ESTAT);
+	(void)enc_r8(enc, CTL_REG_ESTAT);
 	eir_reg = enc_r8(enc, CTL_REG_EIR);
 	if (eir_reg & ENC_EIR_TXIF) {
 		/* clear TXIF bit in EIR */