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


Groups > linux.kernel > #1562215 > unrolled thread

[PATCH 4/5] um: ubd: Move two assignments for the variable "err" in ubd_remove()

Started bySF Markus Elfring <elfring@users.sourceforge.net>
First post2017-01-18 23:10 +0100
Last post2017-01-18 23:10 +0100
Articles 1 — 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 4/5] um: ubd: Move two assignments for the variable "err" in  ubd_remove() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-18 23:10 +0100

#1562215 — [PATCH 4/5] um: ubd: Move two assignments for the variable "err" in ubd_remove()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-01-18 23:10 +0100
Subject[PATCH 4/5] um: ubd: Move two assignments for the variable "err" in ubd_remove()
Message-ID<t16Ax-1or-5@gated-at.bofh.it>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 18 Jan 2017 22:23:18 +0100

A local variable was set to an error code in two cases before a concrete
error situation was detected. Thus move the corresponding assignments into
if branches to indicate a software failure there.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/um/drivers/ubd_kern.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 85410279beab..6d686f735538 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -1049,19 +1049,21 @@ static int ubd_remove(int n, char **error_out)
 {
 	struct gendisk *disk = ubd_gendisk[n];
 	struct ubd *ubd_dev;
-	int err = -ENODEV;
+	int err;
 
 	mutex_lock(&ubd_lock);
 
 	ubd_dev = &ubd_devs[n];
-
-	if(ubd_dev->file == NULL)
+	if (!ubd_dev->file) {
+		err = -ENODEV;
 		goto out;
+	}
 
 	/* you cannot remove a open disk */
-	err = -EBUSY;
-	if(ubd_dev->count > 0)
+	if (ubd_dev->count > 0) {
+		err = -EBUSY;
 		goto out;
+	}
 
 	ubd_gendisk[n] = NULL;
 	if(disk != NULL){
-- 
2.11.0

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web