diff mbox

[1/2,-next] hid-lg4ff: silence sparse complaint

Message ID 20110818134226.GA21927@shale.localdomain (mailing list archive)
State New, archived
Delegated to: Jiri Kosina
Headers show

Commit Message

Dan Carpenter Aug. 18, 2011, 1:42 p.m. UTC
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>

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Dan Carpenter Aug. 18, 2011, 4:21 p.m. UTC | #1
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

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jiri Kosina Aug. 23, 2011, 8:43 a.m. UTC | #2
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.
diff mbox

Patch

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);