All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch 1/2 -next] hid-lg4ff: silence sparse complaint
@ 2011-08-18 13:42 ` Dan Carpenter
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2011-08-18 13:42 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: open list:HID CORE LAYER, kernel-janitors

Sparse complains that:
drivers/hid/hid-lg4ff.c:288:44: warning: Using plain integer as NULL pointer
drivers/hid/hid-lg4ff.c:311:44: warning: Using plain integer as NULL pointer

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
index dc38c2d..2d8762d 100644
--- a/drivers/hid/hid-lg4ff.c
+++ b/drivers/hid/hid-lg4ff.c
@@ -285,7 +285,7 @@ static void hid_lg4ff_switch_native(struct hid_device *hid, const struct lg4ff_n
 /* Read current range and display it in terminal */
 static ssize_t lg4ff_range_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
-	struct lg4ff_device_entry *entry = 0;
+	struct lg4ff_device_entry *uninitialized_var(entry);
 	struct list_head *h;
 	struct hid_device *hid = to_hid_device(dev);
 	size_t count;
@@ -308,7 +308,7 @@ static ssize_t lg4ff_range_show(struct device *dev, struct device_attribute *att
  * according to the type of the wheel */
 static ssize_t lg4ff_range_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 {
-	struct lg4ff_device_entry *entry = 0;
+	struct lg4ff_device_entry *uninitialized_var(entry);
 	struct list_head *h;
 	struct hid_device *hid = to_hid_device(dev);
 	__u16 range = simple_strtoul(buf, NULL, 10);

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

* [patch 1/2 -next] hid-lg4ff: silence sparse complaint
@ 2011-08-18 13:42 ` Dan Carpenter
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2011-08-18 13:42 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: open list:HID CORE LAYER, kernel-janitors

Sparse complains that:
drivers/hid/hid-lg4ff.c:288:44: warning: Using plain integer as NULL pointer
drivers/hid/hid-lg4ff.c:311:44: warning: Using plain integer as NULL pointer

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
index dc38c2d..2d8762d 100644
--- a/drivers/hid/hid-lg4ff.c
+++ b/drivers/hid/hid-lg4ff.c
@@ -285,7 +285,7 @@ static void hid_lg4ff_switch_native(struct hid_device *hid, const struct lg4ff_n
 /* Read current range and display it in terminal */
 static ssize_t lg4ff_range_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
-	struct lg4ff_device_entry *entry = 0;
+	struct lg4ff_device_entry *uninitialized_var(entry);
 	struct list_head *h;
 	struct hid_device *hid = to_hid_device(dev);
 	size_t count;
@@ -308,7 +308,7 @@ static ssize_t lg4ff_range_show(struct device *dev, struct device_attribute *att
  * according to the type of the wheel */
 static ssize_t lg4ff_range_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 {
-	struct lg4ff_device_entry *entry = 0;
+	struct lg4ff_device_entry *uninitialized_var(entry);
 	struct list_head *h;
 	struct hid_device *hid = to_hid_device(dev);
 	__u16 range = simple_strtoul(buf, NULL, 10);

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

* Re: [patch 1/2 -next] hid-lg4ff: silence sparse complaint
       [not found] ` <CAMvewQJ=6-3LgDwAEgJ6TaQSBWiSC5ZTb-14V60ZN0Lh2TYbAQ@mail.gmail.com>
@ 2011-08-18 16:21     ` Dan Carpenter
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2011-08-18 16:21 UTC (permalink / raw)
  To: Zic Rim; +Cc: Jiri Kosina, open list:HID CORE LAYER, kernel-janitors

On Thu, Aug 18, 2011 at 07:50:45PM +0530, Zic Rim wrote:
> > device_attribute *attr, char *buf)
> >  {
> > -       struct lg4ff_device_entry *entry = 0;
> > +       struct lg4ff_device_entry *uninitialized_var(entry);
> >
> 
> I think this is better      struct lg4ff_device_entry *entry = NULL ;
> 

We only have the initialization to silence a gcc warning.  My way is
more explicit.  If we set entry = NULL then other static analysis
tools complain about a potential NULL dereference.

regards,
dan carpenter


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

* Re: [patch 1/2 -next] hid-lg4ff: silence sparse complaint
@ 2011-08-18 16:21     ` Dan Carpenter
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2011-08-18 16:21 UTC (permalink / raw)
  To: Zic Rim; +Cc: Jiri Kosina, open list:HID CORE LAYER, kernel-janitors

On Thu, Aug 18, 2011 at 07:50:45PM +0530, Zic Rim wrote:
> > device_attribute *attr, char *buf)
> >  {
> > -       struct lg4ff_device_entry *entry = 0;
> > +       struct lg4ff_device_entry *uninitialized_var(entry);
> >
> 
> I think this is better      struct lg4ff_device_entry *entry = NULL ;
> 

We only have the initialization to silence a gcc warning.  My way is
more explicit.  If we set entry = NULL then other static analysis
tools complain about a potential NULL dereference.

regards,
dan carpenter


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

* Re: [patch 1/2 -next] hid-lg4ff: silence sparse complaint
  2011-08-18 13:42 ` Dan Carpenter
@ 2011-08-23  8:43   ` Jiri Kosina
  -1 siblings, 0 replies; 6+ messages in thread
From: Jiri Kosina @ 2011-08-23  8:43 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: open list:HID CORE LAYER, kernel-janitors

On Thu, 18 Aug 2011, Dan Carpenter wrote:

> Sparse complains that:
> drivers/hid/hid-lg4ff.c:288:44: warning: Using plain integer as NULL pointer
> drivers/hid/hid-lg4ff.c:311:44: warning: Using plain integer as NULL pointer
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> 
> diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
> index dc38c2d..2d8762d 100644
> --- a/drivers/hid/hid-lg4ff.c
> +++ b/drivers/hid/hid-lg4ff.c
> @@ -285,7 +285,7 @@ static void hid_lg4ff_switch_native(struct hid_device *hid, const struct lg4ff_n
>  /* Read current range and display it in terminal */
>  static ssize_t lg4ff_range_show(struct device *dev, struct device_attribute *attr, char *buf)
>  {
> -	struct lg4ff_device_entry *entry = 0;
> +	struct lg4ff_device_entry *uninitialized_var(entry);
>  	struct list_head *h;
>  	struct hid_device *hid = to_hid_device(dev);
>  	size_t count;
> @@ -308,7 +308,7 @@ static ssize_t lg4ff_range_show(struct device *dev, struct device_attribute *att
>   * according to the type of the wheel */
>  static ssize_t lg4ff_range_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
>  {
> -	struct lg4ff_device_entry *entry = 0;
> +	struct lg4ff_device_entry *uninitialized_var(entry);
>  	struct list_head *h;
>  	struct hid_device *hid = to_hid_device(dev);
>  	__u16 range = simple_strtoul(buf, NULL, 10);

Applied.

-- 
Jiri Kosina
SUSE Labs

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

* Re: [patch 1/2 -next] hid-lg4ff: silence sparse complaint
@ 2011-08-23  8:43   ` Jiri Kosina
  0 siblings, 0 replies; 6+ messages in thread
From: Jiri Kosina @ 2011-08-23  8:43 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: open list:HID CORE LAYER, kernel-janitors

On Thu, 18 Aug 2011, Dan Carpenter wrote:

> Sparse complains that:
> drivers/hid/hid-lg4ff.c:288:44: warning: Using plain integer as NULL pointer
> drivers/hid/hid-lg4ff.c:311:44: warning: Using plain integer as NULL pointer
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> 
> diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
> index dc38c2d..2d8762d 100644
> --- a/drivers/hid/hid-lg4ff.c
> +++ b/drivers/hid/hid-lg4ff.c
> @@ -285,7 +285,7 @@ static void hid_lg4ff_switch_native(struct hid_device *hid, const struct lg4ff_n
>  /* Read current range and display it in terminal */
>  static ssize_t lg4ff_range_show(struct device *dev, struct device_attribute *attr, char *buf)
>  {
> -	struct lg4ff_device_entry *entry = 0;
> +	struct lg4ff_device_entry *uninitialized_var(entry);
>  	struct list_head *h;
>  	struct hid_device *hid = to_hid_device(dev);
>  	size_t count;
> @@ -308,7 +308,7 @@ static ssize_t lg4ff_range_show(struct device *dev, struct device_attribute *att
>   * according to the type of the wheel */
>  static ssize_t lg4ff_range_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
>  {
> -	struct lg4ff_device_entry *entry = 0;
> +	struct lg4ff_device_entry *uninitialized_var(entry);
>  	struct list_head *h;
>  	struct hid_device *hid = to_hid_device(dev);
>  	__u16 range = simple_strtoul(buf, NULL, 10);

Applied.

-- 
Jiri Kosina
SUSE Labs

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

end of thread, other threads:[~2011-08-23  8:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-18 13:42 [patch 1/2 -next] hid-lg4ff: silence sparse complaint Dan Carpenter
2011-08-18 13:42 ` Dan Carpenter
     [not found] ` <CAMvewQJ=6-3LgDwAEgJ6TaQSBWiSC5ZTb-14V60ZN0Lh2TYbAQ@mail.gmail.com>
2011-08-18 16:21   ` Dan Carpenter
2011-08-18 16:21     ` Dan Carpenter
2011-08-23  8:43 ` Jiri Kosina
2011-08-23  8:43   ` Jiri Kosina

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.