Skip to contentSkip to conversation

staging: iio: industrialio-core: Fix compiler warning

PATCH In review Maxin B. John 2 participants 3 messages Aug 22, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: iio: industrialio-core: Fix compiler warning

drivers/staging/iio/industrialio-core.c: In function 'iio_device_add_event_sysfs':
drivers/staging/iio/industrialio-core.c:914: warning: 'mask' may be used uninitialized in this function

---

drivers/staging/iio/industrialio-core.c +3 -1
index 19819e7..83b5953 100644
@@ -911,7 +911,7 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info,
 				      struct iio_chan_spec const *chan)
 {
 
-	int ret = 0, i, mask;
+	int ret = 0, i, mask = 0;
 	char *postfix;
 	if (!chan->event_mask)
 		return 0;
@@ -944,6 +944,8 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info,
 			break;
 		default:
 			printk(KERN_INFO "currently unhandled type of event\n");
+			ret = -EINVAL;
+			goto error_ret;
 		}
 		ret = __iio_add_chan_devattr(postfix,
 					     NULL,
#1 lore raw
Quoted 4 lines · Maxin B. John

drivers/staging/iio/industrialio-core.c: In function 'iio_device_add_event_sysfs':
drivers/staging/iio/industrialio-core.c:914: warning: 'mask' may be used uninitialized in this function

Thanks for the patch. It's actually a driver bug if this occurs. We could have had a WARN_ON to let userspace know about the bug and indeed taken the error route you suggest but
the relevant code has actually undergone a rewrite anyway so the bit you are fixing doesn't exist any more anyway.

See http://git.kernel.org/?p=linux/kernel/git/jic23/iio-blue.git;a=summary
For our current dev tree (eats babies and includes all sorts of stuff that hasn't been reviewed yet - so beware).

Quoted 24 lines

---

drivers/staging/iio/industrialio-core.c +3 -1
index 19819e7..83b5953 100644
@@ -911,7 +911,7 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info,
 				      struct iio_chan_spec const *chan)
 {
 
-	int ret = 0, i, mask;
+	int ret = 0, i, mask = 0;
 	char *postfix;
 	if (!chan->event_mask)
 		return 0;
@@ -944,6 +944,8 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info,
 			break;
 		default:
 			printk(KERN_INFO "currently unhandled type of event\n");
+			ret = -EINVAL;
+			goto error_ret;
 		}
 		ret = __iio_add_chan_devattr(postfix,
 					     NULL,
#2 lore raw
Quoted 10 lines · Jonathan Cameron
Quoted 4 lines · Maxin B. John

drivers/staging/iio/industrialio-core.c: In function 'iio_device_add_event_sysfs':
drivers/staging/iio/industrialio-core.c:914: warning: 'mask' may be used uninitialized in this function

Thanks for the patch. =A0It's actually a driver bug if this occurs. We could have had a WARN_ON to let userspace know about the bug and indeed taken the error route you suggest but
the relevant code has actually undergone a rewrite anyway so the bit you are fixing doesn't exist any more anyway.

Yes, That makes more sense.

Quoted 1 line

See http://git.kernel.org/?p=3Dlinux/kernel/git/jic23/iio-blue.git;a=3Dsu=

mmary

Quoted 2 lines

For our current dev tree (eats babies and includes all sorts of stuff that hasn't been reviewed yet - so beware).

Thanks for sharing this (scary) info :)

Best Regards,
Maxin