Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1683907

[PATCH 1/2] usb: gadget: compress return logic into one line

From "Gustavo A. R. Silva" <garsilva@embeddedor.com>
Newsgroups linux.kernel
Subject [PATCH 1/2] usb: gadget: compress return logic into one line
Date 2017-07-10 04:40 +0200
Message-ID <u1wM9-7yf-3@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


Simplify return logic to avoid unnecessary variable declaration
and assignment.

This issue was detected using Coccinelle and the following
semantic patch:

@@
local idexpression ret;
expression e;
@@

-ret =
+return
     e;
-return ret;

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
 drivers/usb/gadget/config.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c
index 17a6077..23bfa7d 100644
--- a/drivers/usb/gadget/config.c
+++ b/drivers/usb/gadget/config.c
@@ -207,7 +207,6 @@ EXPORT_SYMBOL_GPL(usb_free_all_descriptors);
 struct usb_descriptor_header *usb_otg_descriptor_alloc(
 				struct usb_gadget *gadget)
 {
-	struct usb_descriptor_header *otg_desc;
 	unsigned length = 0;
 
 	if (gadget->otg_caps && (gadget->otg_caps->otg_rev >= 0x0200))
@@ -215,8 +214,7 @@ struct usb_descriptor_header *usb_otg_descriptor_alloc(
 	else
 		length = sizeof(struct usb_otg_descriptor);
 
-	otg_desc = kzalloc(length, GFP_KERNEL);
-	return otg_desc;
+	return kzalloc(length, GFP_KERNEL);
 }
 EXPORT_SYMBOL_GPL(usb_otg_descriptor_alloc);
 
-- 
2.5.0

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH 1/2] usb: gadget: compress return logic into one line "Gustavo A. R. Silva" <garsilva@embeddedor.com> - 2017-07-10 04:40 +0200

csiph-web