staging: comedi: serial2002: quiet NULL pointer sparse noise
PATCH 1/1 staging: comedi: serial2002: quiet NULL pointer sparse noise
Quiet a number of sparse warnings in this file:
warning: Using plain integer as NULL pointer
---
drivers/staging/comedi/drivers/serial2002.c +6 -6
@@ -643,7 +643,7 @@ err_alloc_configs:if (result) {if (devpriv->tty) { -filp_close (devpriv->tty,0 ); +filp_close (devpriv->tty,NULL ); devpriv->tty =NULL ; } }
@@ -653,8 +653,8 @@ err_alloc_configs:static void serial_2002_close (struct comedi_device *dev) { -if (!IS_ERR (devpriv->tty) && (devpriv->tty !=0 )) -filp_close (devpriv->tty,0 ); +if (!IS_ERR (devpriv->tty) && devpriv->tty) +filp_close (devpriv->tty,NULL ); } static int serial2002_di_rinsn(struct comedi_device *dev,
@@ -819,7 +819,7 @@ static int serial2002_attach(struct comedi_device *dev, s->subdev_flags =SDF_READABLE |SDF_GROUND ; s->n_chan =0 ; s->maxdata =1 ; - s->range_table =0 ; + s->range_table =NULL ; s->insn_read = &serial2002_ai_rinsn;/* analog output subdevice */
@@ -828,7 +828,7 @@ static int serial2002_attach(struct comedi_device *dev, s->subdev_flags =SDF_WRITEABLE ; s->n_chan =0 ; s->maxdata =1 ; - s->range_table =0 ; + s->range_table =NULL ; s->insn_write = &serial2002_ao_winsn; s->insn_read = &serial2002_ao_rinsn;
@@ -838,7 +838,7 @@ static int serial2002_attach(struct comedi_device *dev, s->subdev_flags =SDF_READABLE |SDF_LSAMPL ; s->n_chan =0 ; s->maxdata =1 ; - s->range_table =0 ; + s->range_table =NULL ; s->insn_read = &serial2002_ei_rinsn;return 1 ;
Quoted 3 lines · H Hartley Sweeten
Quiet a number of sparse warnings in this file:
warning: Using plain integer as NULL pointer
I wonder why sparse warns about that for a literal, unadorned 0? I suppose NULL is more explicit, but a plain 0 means the same as NULL in a pointer context (unlike a zero from some random expression).
Signature · 2 lines
-=( Ian Abbott @ MEV Ltd. E-mail: <[email protected]> )=- -=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-
Quoted 9 lines · Ian Abbott
Quoted 3 lines · H Hartley Sweeten
Quiet a number of sparse warnings in this file:
warning: Using plain integer as NULL pointer
I wonder why sparse warns about that for a literal, unadorned 0? I suppose NULL is more explicit, but a plain 0 means the same as NULL in a pointer context (unlike a zero from some random expression).
http://lwn.net/Articles/93574/
regards,
dan carpenter
Quoted 11 lines · Dan Carpenter
Quoted 8 lines · Ian Abbott
Quoted 3 lines · H Hartley Sweeten
Quiet a number of sparse warnings in this file:
warning: Using plain integer as NULL pointer
I wonder why sparse warns about that for a literal, unadorned 0? I suppose NULL is more explicit, but a plain 0 means the same as NULL in a pointer context (unlike a zero from some random expression).
Thanks for the link. I understand the intent to make null pointer constants easier to recognize. Still, the text of the sparse warning message "Using plain integer as NULL pointer" is technically incorrect since 0 is not an integer (plain or otherwise) in a pointer context, it's a null pointer constant.
I wonder if it also issues that warning for a struct initializer such as {0} where the first member of the struct is a pointer, or would it expect you to use {NULL} which is more confusing when the struct contains a mixture of pointer and non-pointer members?
Signature · 2 lines
-=( Ian Abbott @ MEV Ltd. E-mail: <[email protected]> )=- -=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-
Quoted 5 lines · Ian Abbott
I wonder if it also issues that warning for a struct initializer such as {0} where the first member of the struct is a pointer, or would it expect you to use {NULL} which is more confusing when the struct contains a mixture of pointer and non-pointer members?
It does warn about that. The fix is to just say:
struct foo bar = {};regards,
dan carpenter