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


Groups > linux.kernel > #1466979 > unrolled thread

[PATCH 0/7] USB-iowarrior: Fine-tuning for some function implementations

Started bySF Markus Elfring <elfring@users.sourceforge.net>
First post2016-08-21 16:00 +0200
Last post2016-08-21 16:10 +0200
Articles 6 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 0/7] USB-iowarrior: Fine-tuning for some function  implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-21 16:00 +0200
    [PATCH 3/7] USB-iowarrior: Delete an unnecessary initialisation in  iowarrior_release() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-21 16:00 +0200
    [PATCH 4/7] USB-iowarrior: Delete unnecessary initialisations in  iowarrior_open() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-21 16:10 +0200
    [PATCH 6/7] USB-iowarrior: Delete unnecessary braces SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-21 16:10 +0200
    [PATCH 7/7] USB-iowarrior: Apply another recommendation from  "checkpatch.pl" SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-21 16:10 +0200
    [PATCH 5/7] USB-iowarrior: Delete unnecessary initialisations in  iowarrior_write() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-21 16:10 +0200

#1466979 — [PATCH 0/7] USB-iowarrior: Fine-tuning for some function implementations

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-08-21 16:00 +0200
Subject[PATCH 0/7] USB-iowarrior: Fine-tuning for some function implementations
Message-ID<s8Bs5-12P-3@gated-at.bofh.it>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 15:41:23 +0200

Several update suggestions were taken into account
from static source code analysis.

Markus Elfring (7):
  Use memdup_user() rather than duplicating its implementation
  Delete unnecessary initialisations for the variable "dev"
  Delete an unnecessary initialisation in iowarrior_release()
  Delete unnecessary initialisations in iowarrior_open()
  Delete unnecessary initialisations in iowarrior_write()
  Delete unnecessary braces
  Apply another recommendation from "checkpatch.pl"

 drivers/usb/misc/iowarrior.c | 53 ++++++++++++++++++--------------------------
 1 file changed, 22 insertions(+), 31 deletions(-)

-- 
2.9.3

[toc] | [next] | [standalone]


#1466980 — [PATCH 3/7] USB-iowarrior: Delete an unnecessary initialisation in iowarrior_release()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-08-21 16:00 +0200
Subject[PATCH 3/7] USB-iowarrior: Delete an unnecessary initialisation in iowarrior_release()
Message-ID<s8Bs5-12P-11@gated-at.bofh.it>
In reply to#1466979
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 13:45:09 +0200

The local variable "retval" will be set to an appropriate value
a bit later. Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/usb/misc/iowarrior.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index 6048f97..449bf64 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -644,7 +644,7 @@ out:
 static int iowarrior_release(struct inode *inode, struct file *file)
 {
 	struct iowarrior *dev;
-	int retval = 0;
+	int retval;
 
 	dev = file->private_data;
 	if (dev == NULL) {
-- 
2.9.3

[toc] | [prev] | [next] | [standalone]


#1466981 — [PATCH 4/7] USB-iowarrior: Delete unnecessary initialisations in iowarrior_open()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-08-21 16:10 +0200
Subject[PATCH 4/7] USB-iowarrior: Delete unnecessary initialisations in iowarrior_open()
Message-ID<s8BBL-1lk-1@gated-at.bofh.it>
In reply to#1466979
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 15:15:03 +0200

Two local variables will be set to an appropriate value a bit later.
Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/usb/misc/iowarrior.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index 449bf64..e3564d8 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -587,10 +587,10 @@ error_out:
  */
 static int iowarrior_open(struct inode *inode, struct file *file)
 {
-	struct iowarrior *dev = NULL;
+	struct iowarrior *dev;
 	struct usb_interface *interface;
 	int subminor;
-	int retval = 0;
+	int retval;
 
 	mutex_lock(&iowarrior_mutex);
 	subminor = iminor(inode);
-- 
2.9.3

[toc] | [prev] | [next] | [standalone]


#1466982 — [PATCH 6/7] USB-iowarrior: Delete unnecessary braces

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-08-21 16:10 +0200
Subject[PATCH 6/7] USB-iowarrior: Delete unnecessary braces
Message-ID<s8BBL-1lk-3@gated-at.bofh.it>
In reply to#1466979
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 15:25:30 +0200

Do not use curly brackets at a few source code places
where a single statement should be sufficient.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/usb/misc/iowarrior.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index ffbbb74..132c8cf 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -227,10 +227,10 @@ static void iowarrior_write_callback(struct urb *urb)
 	/* sync/async unlink faults aren't errors */
 	if (status &&
 	    !(status == -ENOENT ||
-	      status == -ECONNRESET || status == -ESHUTDOWN)) {
+	      status == -ECONNRESET || status == -ESHUTDOWN))
 		dev_dbg(&dev->interface->dev,
 			"nonzero write bulk status received: %d\n", status);
-	}
+
 	/* free up our allocated buffer */
 	usb_free_coherent(urb->dev, urb->transfer_buffer_length,
 			  urb->transfer_buffer, urb->transfer_dma);
@@ -304,25 +304,21 @@ static ssize_t iowarrior_read(struct file *file, char __user *buffer,
 								      read_index
 								      (dev)) !=
 								  -1));
-				if (r) {
+				if (r)
 					//we were interrupted by a signal
 					return -ERESTART;
-				}
-				if (!dev->present) {
+				if (!dev->present)
 					//The device was unplugged
 					return -ENODEV;
-				}
-				if (read_idx == -1) {
+				if (read_idx == -1)
 					// Can this happen ???
 					return 0;
-				}
 			}
 		}
 
 		offset = read_idx * (dev->report_size + 1);
-		if (copy_to_user(buffer, dev->read_queue + offset, count)) {
+		if (copy_to_user(buffer, dev->read_queue + offset, count))
 			return -EFAULT;
-		}
 	} while (atomic_read(&dev->overflow_flag));
 
 	read_idx = ++read_idx == MAX_INTERRUPT_BUFFER ? 0 : read_idx;
@@ -475,9 +471,8 @@ static long iowarrior_ioctl(struct file *file, unsigned int cmd,
 	int io_res;		/* checks for bytes read/written and copy_to/from_user results */
 
 	dev = file->private_data;
-	if (dev == NULL) {
+	if (!dev)
 		return -ENODEV;
-	}
 
 	buffer = kzalloc(dev->report_size, GFP_KERNEL);
 	if (!buffer)
@@ -647,9 +642,8 @@ static int iowarrior_release(struct inode *inode, struct file *file)
 	int retval;
 
 	dev = file->private_data;
-	if (dev == NULL) {
+	if (!dev)
 		return -ENODEV;
-	}
 
 	dev_dbg(&dev->interface->dev, "minor %d\n", dev->minor);
 
-- 
2.9.3

[toc] | [prev] | [next] | [standalone]


#1466983 — [PATCH 7/7] USB-iowarrior: Apply another recommendation from "checkpatch.pl"

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-08-21 16:10 +0200
Subject[PATCH 7/7] USB-iowarrior: Apply another recommendation from "checkpatch.pl"
Message-ID<s8BBL-1lk-13@gated-at.bofh.it>
In reply to#1466979
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 15:30:11 +0200

The script "checkpatch.pl" can point out that assignments should usually
not be performed within condition checks.
Thus move the assignments for two local variables to separate statements.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/usb/misc/iowarrior.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index 132c8cf..78b5d65 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -292,7 +292,8 @@ static ssize_t iowarrior_read(struct file *file, char __user *buffer,
 	/* repeat until no buffer overrun in callback handler occur */
 	do {
 		atomic_set(&dev->overflow_flag, 0);
-		if ((read_idx = read_index(dev)) == -1) {
+		read_idx = read_index(dev);
+		if (read_idx == -1) {
 			/* queue empty */
 			if (file->f_flags & O_NONBLOCK)
 				return -EAGAIN;
@@ -616,7 +617,8 @@ static int iowarrior_open(struct inode *inode, struct file *file)
 	}
 
 	/* setup interrupt handler for receiving values */
-	if ((retval = usb_submit_urb(dev->int_in_urb, GFP_KERNEL)) < 0) {
+	retval = usb_submit_urb(dev->int_in_urb, GFP_KERNEL);
+	if (retval < 0) {
 		dev_err(&interface->dev, "Error %d while submitting URB\n", retval);
 		retval = -EFAULT;
 		goto out;
-- 
2.9.3

[toc] | [prev] | [next] | [standalone]


#1466984 — [PATCH 5/7] USB-iowarrior: Delete unnecessary initialisations in iowarrior_write()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-08-21 16:10 +0200
Subject[PATCH 5/7] USB-iowarrior: Delete unnecessary initialisations in iowarrior_write()
Message-ID<s8BBL-1lk-11@gated-at.bofh.it>
In reply to#1466979
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 15:17:22 +0200

Two local variables will be set to an appropriate value a bit later.
Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/usb/misc/iowarrior.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index e3564d8..ffbbb74 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -338,8 +338,8 @@ static ssize_t iowarrior_write(struct file *file,
 			       size_t count, loff_t *ppos)
 {
 	struct iowarrior *dev;
-	int retval = 0;
-	char *buf = NULL;	/* for IOW24 and IOW56 we need a buffer */
+	int retval;
+	char *buf;	/* for IOW24 and IOW56 we need a buffer */
 	struct urb *int_out_urb = NULL;
 
 	dev = file->private_data;
-- 
2.9.3

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web