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


Groups > linux.kernel > #1564337

[PATCH 4/5] cfq-iosched: Move an assignment for the variable "ret" in __cfqg_set_weight_device()

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 4/5] cfq-iosched: Move an assignment for the variable "ret" in __cfqg_set_weight_device()
Date 2017-01-22 09:40 +0100
Message-ID <t2lQS-6Vp-13@gated-at.bofh.it> (permalink)
References <t2lQR-6Vp-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 21 Jan 2017 22:26:38 +0100

A local variable was set to an error code before a concrete error situation
was detected. Thus move the corresponding assignment into an if branch
to indicate a software failure there.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 block/cfq-iosched.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index c73a6fcaeb9d..454297fe8fd6 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -1788,9 +1788,10 @@ static ssize_t __cfqg_set_weight_device(struct kernfs_open_file *of,
 
 	if (sscanf(ctx.body, "%llu", &v) == 1) {
 		/* require "default" on dfl */
-		ret = -ERANGE;
-		if (!v && on_dfl)
+		if (!v && on_dfl) {
+			ret = -ERANGE;
 			goto out_finish;
+		}
 	} else if (!strcmp(strim(ctx.body), "default")) {
 		v = 0;
 	} else {
-- 
2.11.0

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


Thread

[PATCH 0/5] block: Fine-tuning for five function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-22 09:40 +0100
  [PATCH 4/5] cfq-iosched: Move an assignment for the variable "ret" in  __cfqg_set_weight_device() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-22 09:40 +0100
  [PATCH 3/5] blk-throttle: Adjust two function calls together with a  variable assignment SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-22 09:40 +0100
    Re: [PATCH 3/5] blk-throttle: Adjust two function calls together  with a variable assignment Johannes Thumshirn <jthumshirn@suse.de> - 2017-01-23 10:30 +0100
      Re: [PATCH 3/5] blk-throttle: Adjust two function calls together with  a variable assignment Jens Axboe <axboe@kernel.dk> - 2017-01-23 16:20 +0100

csiph-web