All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: comedi: serial2002: quiet NULL pointer sparse noise
@ 2012-06-08  0:14 H Hartley Sweeten
  2012-06-08  6:46 ` Ian Abbott
  0 siblings, 1 reply; 5+ messages in thread
From: H Hartley Sweeten @ 2012-06-08  0:14 UTC (permalink / raw)
  To: Linux Kernel; +Cc: devel, abbotti, fmhess, gregkh

Quiet a number of sparse warnings in this file:

warning: Using plain integer as NULL pointer

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Mori Hess <fmhess@users.sourceforge.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---

diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c
index 9200310..c25808c 100644
--- a/drivers/staging/comedi/drivers/serial2002.c
+++ b/drivers/staging/comedi/drivers/serial2002.c
@@ -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;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] staging: comedi: serial2002: quiet NULL pointer sparse noise
  2012-06-08  0:14 [PATCH] staging: comedi: serial2002: quiet NULL pointer sparse noise H Hartley Sweeten
@ 2012-06-08  6:46 ` Ian Abbott
  2012-06-08  6:51   ` Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Ian Abbott @ 2012-06-08  6:46 UTC (permalink / raw)
  To: H Hartley Sweeten
  Cc: Linux Kernel, devel@driverdev.osuosl.org, Ian Abbott,
	fmhess@users.sourceforge.net, gregkh@linuxfoundation.org

On 08/06/12 01:14, H Hartley Sweeten wrote:
> 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).

-- 
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@mev.co.uk>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] staging: comedi: serial2002: quiet NULL pointer sparse noise
  2012-06-08  6:46 ` Ian Abbott
@ 2012-06-08  6:51   ` Dan Carpenter
  2012-06-08  9:07     ` Ian Abbott
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2012-06-08  6:51 UTC (permalink / raw)
  To: Ian Abbott
  Cc: H Hartley Sweeten, devel@driverdev.osuosl.org,
	fmhess@users.sourceforge.net, Ian Abbott, Linux Kernel,
	gregkh@linuxfoundation.org

On Fri, Jun 08, 2012 at 07:46:19AM +0100, Ian Abbott wrote:
> On 08/06/12 01:14, H Hartley Sweeten wrote:
> >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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] staging: comedi: serial2002: quiet NULL pointer sparse noise
  2012-06-08  6:51   ` Dan Carpenter
@ 2012-06-08  9:07     ` Ian Abbott
  2012-06-08  9:48       ` Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Ian Abbott @ 2012-06-08  9:07 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Ian Abbott, H Hartley Sweeten, devel@driverdev.osuosl.org,
	fmhess@users.sourceforge.net, Linux Kernel,
	gregkh@linuxfoundation.org

On 2012/06/08 07:51 AM, Dan Carpenter wrote:
> On Fri, Jun 08, 2012 at 07:46:19AM +0100, Ian Abbott wrote:
>> On 08/06/12 01:14, H Hartley Sweeten wrote:
>>> 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/

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?

-- 
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@mev.co.uk>             )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587              )=-

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] staging: comedi: serial2002: quiet NULL pointer sparse noise
  2012-06-08  9:07     ` Ian Abbott
@ 2012-06-08  9:48       ` Dan Carpenter
  0 siblings, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2012-06-08  9:48 UTC (permalink / raw)
  To: Ian Abbott
  Cc: devel@driverdev.osuosl.org, fmhess@users.sourceforge.net,
	Ian Abbott, gregkh@linuxfoundation.org, Linux Kernel,
	H Hartley Sweeten

On Fri, Jun 08, 2012 at 10:07:30AM +0100, Ian Abbott wrote:
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-06-08  9:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-08  0:14 [PATCH] staging: comedi: serial2002: quiet NULL pointer sparse noise H Hartley Sweeten
2012-06-08  6:46 ` Ian Abbott
2012-06-08  6:51   ` Dan Carpenter
2012-06-08  9:07     ` Ian Abbott
2012-06-08  9:48       ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.