Skip to contentSkip to conversation

HID: roccat: silence an uninitialized variable warning

PATCH Applied Dan Carpenter 2 participants 2 messages Apr 2, 2016 – Apr 4, 2016

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

PATCH 1/1 HID: roccat: silence an uninitialized variable warning

My static checker complains because we use "dev_id" before we check for errors so it could be uninitialized. Fix this by moving the error handling forward a couple lines.

drivers/hid/hid-roccat.c +2 -3
index 65c4ccfc..76d06cf 100644
@@ -421,14 +421,13 @@ static int __init roccat_init(void)
 
 	retval = alloc_chrdev_region(&dev_id, ROCCAT_FIRST_MINOR,
 			ROCCAT_MAX_DEVICES, "roccat");
-
-	roccat_major = MAJOR(dev_id);
-
 	if (retval < 0) {
 		pr_warn("can't get major number\n");
 		goto error;
 	}
 
+	roccat_major = MAJOR(dev_id);
+
 	cdev_init(&roccat_cdev, &roccat_ops);
 	retval = cdev_add(&roccat_cdev, dev_id, ROCCAT_MAX_DEVICES);
 
maintainer Applied
#1 lore raw
Quoted 5 lines · Dan Carpenter

My static checker complains because we use "dev_id" before we check for errors so it could be uninitialized. Fix this by moving the error handling forward a couple lines.

Applied, thanks.

Signature · 2 lines
Jiri Kosina
SUSE Labs