On 09.01.2011 22:43, Alan Stern wrote:
static struct field *get_field(void)
{
struct my_mod *mod = NULL;
return&mod->f;
That's another case: offset of 'f' is not 0, unlike the offset of 'request'.
What happens if somebody in the future adds another member to the
musb_request structure in front of the .request member?
That's not likely...
Felipe's change is simply good programming practice (although the patch
description could be improved).
Well, I'm not arguing with that.
Now, if change the check:
--- t.c.orig 2011-01-09 19:06:31.581642000 +0200
+++ t.c 2011-01-09 19:05:41.733642000 +0200
@@ -26,7 +26,7 @@ static int __init mod_init(void)
{
struct field *f = get_field();
- if (f == NULL)
+ if (f)
pr_info("===> f (%p) is NULL\n", f);
else
pr_info("===> f (%p) is not NULL\n", f);
Everything the pointer is considered NULL:
$ dmesg
[1385484.405684] ===> f (0000000c) is NULL
Hm, interesting...
Not as interesting as it may appear. The test is backward, so the fact
that the program printed out "is NULL" means the computer thinks f
really is not NULL.
Indeed, I didn't notice that. Should have been *if* (!f). :-)
Alan Stern
WBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html