* [PATCH 3/5] isdn: fix integer as NULL pointer warning
@ 2008-05-22 22:45 Harvey Harrison
2008-05-23 15:08 ` Linus Torvalds
0 siblings, 1 reply; 2+ messages in thread
From: Harvey Harrison @ 2008-05-22 22:45 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Andrew Morton, LKML
drivers/isdn/hysdn/hycapi.c:465:42: warning: Using plain integer as NULL pointer
drivers/isdn/hysdn/hycapi.c:467:44: warning: Using plain integer as NULL pointer
drivers/isdn/hysdn/hycapi.c:469:42: warning: Using plain integer as NULL pointer
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
drivers/isdn/hysdn/hycapi.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/isdn/hysdn/hycapi.c b/drivers/isdn/hysdn/hycapi.c
index d3999a8..53f6ad1 100644
--- a/drivers/isdn/hysdn/hycapi.c
+++ b/drivers/isdn/hysdn/hycapi.c
@@ -462,11 +462,11 @@ static int hycapi_read_proc(char *page, char **start, off_t off,
default: s = "???"; break;
}
len += sprintf(page+len, "%-16s %s\n", "type", s);
- if ((s = cinfo->version[VER_DRIVER]) != 0)
+ if ((s = cinfo->version[VER_DRIVER]) != NULL)
len += sprintf(page+len, "%-16s %s\n", "ver_driver", s);
- if ((s = cinfo->version[VER_CARDTYPE]) != 0)
+ if ((s = cinfo->version[VER_CARDTYPE]) != NULL)
len += sprintf(page+len, "%-16s %s\n", "ver_cardtype", s);
- if ((s = cinfo->version[VER_SERIAL]) != 0)
+ if ((s = cinfo->version[VER_SERIAL]) != NULL)
len += sprintf(page+len, "%-16s %s\n", "ver_serial", s);
len += sprintf(page+len, "%-16s %s\n", "cardname", cinfo->cardname);
--
1.5.5.1.579.g4e43
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH 3/5] isdn: fix integer as NULL pointer warning
2008-05-22 22:45 [PATCH 3/5] isdn: fix integer as NULL pointer warning Harvey Harrison
@ 2008-05-23 15:08 ` Linus Torvalds
0 siblings, 0 replies; 2+ messages in thread
From: Linus Torvalds @ 2008-05-23 15:08 UTC (permalink / raw)
To: Harvey Harrison; +Cc: Andrew Morton, LKML
On Thu, 22 May 2008, Harvey Harrison wrote:
> len += sprintf(page+len, "%-16s %s\n", "type", s);
> - if ((s = cinfo->version[VER_DRIVER]) != 0)
> + if ((s = cinfo->version[VER_DRIVER]) != NULL)
> len += sprintf(page+len, "%-16s %s\n", "ver_driver", s);
For thigns like this (ie testing an assignment), I personally much prefer
s = cinfo->version[VER_DRIVER];
if (s)
len += sprintf(page+len, "%-16s %s\n", "ver_driver", s);
over the uglier and unreadable version.
IOW, testing assignments is good only when:
- you have to do it because of syntax (ie notably in a "while()" loop)
- there's some reason you want it to be a single statement (eg doing a
macro or other thing)
- of the assignment is really simple, and the test is not against NULL or
zero.
The reason for that "the test is not against NULL or zero" is that testing
for NULL and 0 is better done with just a "if (x)", and in an assignment
that just means either (a) a incomprehensible extra parenthesis just to
shut the compiler up or (b) changing the simple test into a stupid test
(ie doing "if (x != NULL)").
(b) is much preferable to (a), but just doing it as two statements is
much preferable to either!
Linus
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-05-23 15:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-22 22:45 [PATCH 3/5] isdn: fix integer as NULL pointer warning Harvey Harrison
2008-05-23 15:08 ` Linus Torvalds
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox