block: wrong return value
PATCH v2 1/1 block: wrong return value
while compiling integer err was showing as a set but unused variable. elevator_init_fn can be either cfq_init_queue or deadline_init_queue or noop_init_queue.
all three of these functions are returning -ENOMEM if they fail to allocate the queue.
so we should actually be returning the error code rather than returning 0 always.
---
change in v2: added elevator_put
block/elevator.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
block/elevator.c +4 -2
@@ -184,7 +184,7 @@ static void elevator_release(struct kobject *kobj)int elevator_init (struct request_queue *q,char *name) {struct elevator_type *e =NULL ; -int err; +int err =0 ;/* * q->sysfs_lock must be held to provide mutual exclusion between
@@ -229,7 +229,9 @@ int elevator_init(struct request_queue *q, char *name) } err = e->ops.elevator_init_fn (q, e); -return 0 ; +if (err) +elevator_put (e); +return err; }EXPORT_SYMBOL (elevator_init);
Signature · 1 line
1.8.1.2
Jens Axboe
maintainerQuoted 21 lines · Sudip Mukherjee
while compiling integer err was showing as a set but unused variable.
elevator_init_fncan be eithercfq_init_queueordeadline_init_queueornoop_init_queue.
all three of these functions are returning-ENOMEMif they fail to allocate the queue.
so we should actually be returning the error code rather than returning 0 always.Signed-off-by Sudip Mukherjee <[email protected]>---
change in v2: added
elevator_putblock/elevator.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)block/elevator.c +0
-0
block/elevator.c static void elevator_release(struct kobject *kobj) · line 187
Quoted 5 lines
block/elevator.c +1
-1@@ -184,7 +184,7 @@ static void elevator_release(struct kobject *kobj)int elevator_init (struct request_queue *q,char *name) {struct elevator_type *e =NULL ; -int err; +int err =0 ;
Why init it to 0?
Signature · 1 line
Jens Axboe
Quoted 17 lines · Jens Axboe
Quoted 16 lines · Sudip Mukherjee
while compiling integer err was showing as a set but unused variable.
elevator_init_fncan be eithercfq_init_queueordeadline_init_queueornoop_init_queue.
all three of these functions are returning-ENOMEMif they fail to allocate the queue.
so we should actually be returning the error code rather than returning 0 always.Signed-off-by Sudip Mukherjee <[email protected]>---
change in v2: added
elevator_putblock/elevator.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Quoted 12 lines
block/elevator.c static void elevator_release(struct kobject *kobj) · line 187
Quoted 10 lines
block/elevator.c +1
-1@@ -184,7 +184,7 @@ static void elevator_release(struct kobject *kobj)int elevator_init (struct request_queue *q,char *name) {struct elevator_type *e =NULL ; -int err; +int err =0 ;Why init it to 0?
not required actually. my initial thinking was that we are returning 0 on success or else the error code. so gave it a default value of 0. but elevator_init_fn is returning 0 on success , so we will get 0 even if we do not initialize it.
should i resend after modifying it?
thanks
sudip
Quoted 4 lines
Signature · 2 lines
-- Jens Axboe
Jens Axboe
maintainerQuoted 30 lines · Sudip Mukherjee
Quoted 17 lines · Jens Axboe
Quoted 16 lines · Sudip Mukherjee
while compiling integer err was showing as a set but unused variable.
elevator_init_fncan be eithercfq_init_queueordeadline_init_queueornoop_init_queue.
all three of these functions are returning-ENOMEMif they fail to allocate the queue.
so we should actually be returning the error code rather than returning 0 always.Signed-off-by Sudip Mukherjee <[email protected]>---
change in v2: added
elevator_putblock/elevator.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)Quoted 12 lines
block/elevator.c static void elevator_release(struct kobject *kobj) · line 187
Quoted 10 lines
block/elevator.c +1
-1@@ -184,7 +184,7 @@ static void elevator_release(struct kobject *kobj)int elevator_init (struct request_queue *q,char *name) {struct elevator_type *e =NULL ; -int err; +int err =0 ;Why init it to 0?
Quoted 3 lines
not required actually. my initial thinking was that we are returning 0 on success or else the error code. so gave it a default value of 0. but
elevator_init_fnis returning 0 on success , so we will get 0 even if we do not initialize it.
should i resend after modifying it?
Yes resend it please, the assignment is meaningless as it is overwritten later before being used.
Signature · 1 line
Jens Axboe