pcmcia: fix sparse integer as NULL pointer warning
Subsystems (2)
drivers/pcmcia/rsrc_nonstatic.c:278:30: warning: Using plain integer as NULL pointer
--- drivers/pcmcia/rsrc_nonstatic.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/pcmcia/rsrc_nonstatic.c +1 -1
@@ -275,7 +275,7 @@ static int readable(struct pcmcia_socket *s, struct resource *res,destroy_cis_cache (s); } s->cis_mem.res =NULL ; -if ((ret !=0 ) || (count ==0 )) +if ((ret !=0 ) || (count ==NULL ))return 0 ;return 1 ; }
Signature · 1 line
1.5.6.4.570.g052e
drivers/pcmcia/rsrc_nonstatic.c static int readable(struct pcmcia_socket *s, struct resource *res, · line 278
Quoted 8 lines · On Wed, 23 Jul 2008 18:34:08 -0700 Harvey Harrison <[email protected]>…
+++
b/drivers/pcmcia/rsrc_nonstatic.cdrivers/pcmcia/rsrc_nonstatic.c +1
-1@@ -275,7 +275,7 @@ static int readable(struct pcmcia_socket *s, struct resource *res,destroy_cis_cache (s); } s->cis_mem.res =NULL ; -if ((ret !=0 ) || (count ==0 )) +if ((ret !=0 ) || (count ==NULL ))
I was wondering if it should be
(*count == 0)
Signature · 3 lines
Cheers, Stephen Rothwell [email protected] http://www.canb.auug.org.au/~sfr/
Quoted 11 lines · Stephen Rothwell
drivers/pcmcia/rsrc_nonstatic.c static int readable(struct pcmcia_socket *s, struct resource *res, · line 278
Quoted 8 lines · On Wed, 23 Jul 2008 18:34:08 -0700 Harvey Harrison <[email protected]>…
+++
b/drivers/pcmcia/rsrc_nonstatic.cdrivers/pcmcia/rsrc_nonstatic.c +1
-1@@ -275,7 +275,7 @@ static int readable(struct pcmcia_socket *s, struct resource *res,destroy_cis_cache (s); } s->cis_mem.res =NULL ; -if ((ret !=0 ) || (count ==0 )) +if ((ret !=0 ) || (count ==NULL ))I was wondering if it should be
Quoted 2 lines
(*count == 0)
Actually, it looks that way as in this case count can never be none.
readable() is only called in one place where it is passed the addresses of two local variables. Looking at pccard_validate_cis(), the number of valid tuples found is returned through the info pointer, or zero if invalid cis is found.
So I'd say *count == 0 is probably right.
Dominik?
Harvey
Dominik Brodowski
maintainerQuoted 17 lines · Harvey Harrison
Quoted 11 lines · Stephen Rothwell
Review static int readable(struct pcmcia_socket *s, struct resource *res, · line 278
Quoted 8 lines · On Wed, 23 Jul 2008 18:34:08 -0700 Harvey Harrison <[email protected]>…
+++
b/drivers/pcmcia/rsrc_nonstatic.c(quoted diff) +1
-1@@ -275,7 +275,7 @@ static int readable(struct pcmcia_socket *s, struct resource *res, destroy_cis_cache(s); } s->cis_mem.res = NULL; - if ((ret != 0) || (count == 0)) + if ((ret != 0) || (count == NULL))I was wondering if it should be
Quoted 2 lines
(*count == 0)Actually, it looks that way as in this case count can never be none.
Quoted 8 lines
readable()is only called in one place where it is passed the addresses of two local variables. Looking atpccard_validate_cis(), the number of valid tuples found is returned through the info pointer, or zero if invalid cis is found.So I'd say *count == 0 is probably right.
Dominik?
Yes, *count == 0 is what we'd need to check here.
Thanks!
Dominik
From: Dominik Brodowski <[email protected]>
Date: Mon, 28 Jul 2008 16:37:10 +0200
Subject: [PATCH 1/1] pcmcia: rsrc_nonstatic: check value, not pointer
Bug found by Harvey Harrison and Stephen Rothwell.
--- drivers/pcmcia/rsrc_nonstatic.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/pcmcia/rsrc_nonstatic.c +1 -1
@@ -275,7 +275,7 @@ static int readable(struct pcmcia_socket *s, struct resource *res,destroy_cis_cache (s); } s->cis_mem.res =NULL ; -if ((ret !=0 ) || (count ==0 )) +if ((ret !=0 ) || (*count ==0 ))return 0 ;return 1 ; }
Signature · 1 line
1.5.4.3