diff mbox

[15/18] HID-debug: Return an error code only as a constant in hid_debug_events_open()

Message ID 9935147f-3387-a583-b878-cbd90f1bfac0@users.sourceforge.net (mailing list archive)
State New, archived
Headers show

Commit Message

SF Markus Elfring Feb. 7, 2017, 7:58 p.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Feb 2017 20:08:04 +0100

* Return an error code without storing it in an intermediate variable.

* Delete the local variable "err" and the jump label "out" which became
  unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/hid-debug.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
diff mbox

Patch

diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 444c63f0e4be..60984e2906a7 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -1079,22 +1079,18 @@  static int hid_debug_rdesc_open(struct inode *inode, struct file *file)
 
 static int hid_debug_events_open(struct inode *inode, struct file *file)
 {
-	int err = 0;
 	struct hid_debug_list *list;
 	unsigned long flags;
 
 	list = kzalloc(sizeof(*list), GFP_KERNEL);
-	if (!list) {
-		err = -ENOMEM;
-		goto out;
-	}
+	if (!list)
+		return -ENOMEM;
 
 	list->hid_debug_buf = kzalloc(sizeof(char) * HID_DEBUG_BUFSIZE,
 				      GFP_KERNEL);
 	if (!list->hid_debug_buf) {
-		err = -ENOMEM;
 		kfree(list);
-		goto out;
+		return -ENOMEM;
 	}
 	list->hdev = (struct hid_device *) inode->i_private;
 	file->private_data = list;
@@ -1103,9 +1099,7 @@  static int hid_debug_events_open(struct inode *inode, struct file *file)
 	spin_lock_irqsave(&list->hdev->debug_list_lock, flags);
 	list_add_tail(&list->node, &list->hdev->debug_list);
 	spin_unlock_irqrestore(&list->hdev->debug_list_lock, flags);
-
-out:
-	return err;
+	return 0;
 }
 
 static ssize_t hid_debug_events_read(struct file *file, char __user *buffer,