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


Groups > linux.kernel > #1564336 > unrolled thread

[PATCH 0/5] block: Fine-tuning for five function implementations

Started bySF Markus Elfring <elfring@users.sourceforge.net>
First post2017-01-22 09:40 +0100
Last post2017-01-23 16:20 +0100
Articles 5 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [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

#1564336 — [PATCH 0/5] block: Fine-tuning for five function implementations

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-01-22 09:40 +0100
Subject[PATCH 0/5] block: Fine-tuning for five function implementations
Message-ID<t2lQR-6Vp-9@gated-at.bofh.it>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 21 Jan 2017 23:00:00 +0100

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

Markus Elfring (5):
  Move three assignments for the variable "ret" in tg_set_max()
  Move an assignment for the variable "ret" in tg_set_conf()
  Adjust two function calls together with a variable assignment
  Move an assignment for the variable "ret" in __cfqg_set_weight_device()
  Adjust one function call together with a variable assignment

 block/blk-throttle.c | 34 ++++++++++++++++++++--------------
 block/cfq-iosched.c  | 11 +++++++----
 2 files changed, 27 insertions(+), 18 deletions(-)

-- 
2.11.0

[toc] | [next] | [standalone]


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

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-01-22 09:40 +0100
Subject[PATCH 4/5] cfq-iosched: Move an assignment for the variable "ret" in __cfqg_set_weight_device()
Message-ID<t2lQS-6Vp-13@gated-at.bofh.it>
In reply to#1564336
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

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


#1564338 — [PATCH 3/5] blk-throttle: Adjust two function calls together with a variable assignment

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-01-22 09:40 +0100
Subject[PATCH 3/5] blk-throttle: Adjust two function calls together with a variable assignment
Message-ID<t2lQS-6Vp-19@gated-at.bofh.it>
In reply to#1564336
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 21 Jan 2017 22:15:33 +0100

The script "checkpatch.pl" pointed information out like the following.

ERROR: do not use assignment in if condition

Thus fix the affected source code places.

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

diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index b392b48310ba..3cf7472fbba2 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -866,10 +866,12 @@ static void tg_update_disptime(struct throtl_grp *tg)
 	unsigned long read_wait = -1, write_wait = -1, min_wait = -1, disptime;
 	struct bio *bio;
 
-	if ((bio = throtl_peek_queued(&sq->queued[READ])))
+	bio = throtl_peek_queued(&sq->queued[READ]);
+	if (bio)
 		tg_may_dispatch(tg, bio, &read_wait);
 
-	if ((bio = throtl_peek_queued(&sq->queued[WRITE])))
+	bio = throtl_peek_queued(&sq->queued[WRITE]);
+	if (bio)
 		tg_may_dispatch(tg, bio, &write_wait);
 
 	min_wait = min(read_wait, write_wait);
-- 
2.11.0

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


#1564811 — Re: [PATCH 3/5] blk-throttle: Adjust two function calls together with a variable assignment

FromJohannes Thumshirn <jthumshirn@suse.de>
Date2017-01-23 10:30 +0100
SubjectRe: [PATCH 3/5] blk-throttle: Adjust two function calls together with a variable assignment
Message-ID<t2J6O-4DB-17@gated-at.bofh.it>
In reply to#1564338
On Sun, Jan 22, 2017 at 09:33:08AM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 21 Jan 2017 22:15:33 +0100
> 
> The script "checkpatch.pl" pointed information out like the following.
> 
> ERROR: do not use assignment in if condition
> 
> Thus fix the affected source code places.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---

Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
if Jens wants doesn't mind.

-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

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


#1565044 — Re: [PATCH 3/5] blk-throttle: Adjust two function calls together with a variable assignment

FromJens Axboe <axboe@kernel.dk>
Date2017-01-23 16:20 +0100
SubjectRe: [PATCH 3/5] blk-throttle: Adjust two function calls together with a variable assignment
Message-ID<t2Ozx-84K-41@gated-at.bofh.it>
In reply to#1564811
On 01/23/2017 02:20 AM, Johannes Thumshirn wrote:
> On Sun, Jan 22, 2017 at 09:33:08AM +0100, SF Markus Elfring wrote:
>> From: Markus Elfring <elfring@users.sourceforge.net>
>> Date: Sat, 21 Jan 2017 22:15:33 +0100
>>
>> The script "checkpatch.pl" pointed information out like the following.
>>
>> ERROR: do not use assignment in if condition
>>
>> Thus fix the affected source code places.
>>
>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>> ---
> 
> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
> if Jens wants doesn't mind.

I don't mind these, but I completely agree on the patches for moving the
'error' assignment. What ends up happening for those cases is that
someone adds a new section and forgets to set 'error', and then all hell
breaks lose.

So Markus, don't bother sending those patches again for the block layer
or drivers, I'm not going to take them.

-- 
Jens Axboe

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web