nvmet-fc: slight cleanup for kbuild test warnings
Subsystems (3)
PATCH 1/1 nvmet-fc: slight cleanup for kbuild test warnings
The kbuild tst robot flagged the following 3 issues:
Case 1)
Quoted 4 lines
Quoted 4 lines
drivers/nvme/target/fc.c:1201:37: warning: Either the condition '!assoc' is redundant or there is possible null pointer dereference:
assoc. [nullPointerRedundantCheck]
structnvmet_fc_tgtport*tgtport =assoc->tgtport;
^
Quoted 3 lines
Quoted 3 lines
drivers/nvme/target/fc.c:1853:7: note: Assuming that condition '!assoc' is not redundant
if (!assoc)
^
Quoted 4 lines
Quoted 4 lines
drivers/nvme/target/fc.c:1850:37: note: Assignment 'assoc=nvmet_fc_find_target_assoc(tgtport,be64_to_cpu(rqst->associd.association_id))', assigned value is 0assoc = nvmet_fc_find_target_assoc(tgtport,
^
Quoted 3 lines
Quoted 3 lines
drivers/nvme/target/fc.c:1896:31: note: Calling function 'nvmet_fc_delete_target_assoc', 1st argument 'assoc' value is 0
nvmet_fc_delete_target_assoc(assoc);
^
The tool isn't smart enough to see that line 1854 sets a ret value which thereafter causes the routine to exit. This occurs before any of the assoc references, so it is not an issue. There are 2 more reportings of this same failure.
To quiet the tool - rework the if test that does the exit to also reference assoc. No change in logic otherwise.
Case 2)drivers/nvme/target/fc.c:1202:29: warning: The scope of the variable 'queue' can be reduced. [variableScope]
struct nvmet_fc_tgt_queue *queue;
^The tool is requesting the variable be declared within the code block that utilizes it. Ignoring this report as existing code style is fine.
Case 3)drivers/nvme/target/fc.c:1137:16: warning: Variable 'needrandom' is assigned a value that is never used. [unreadVariable]
needrandom = true;
^Another parsing issue with the tool. Given that parens were not used with the list_for_each_entry() check, it inadvertantly thinks the break exited the outer while loop not the inner for loop.
This is not an error. But, added parens to the inner list_for_each_entry() to quiet the tool and as it is better coding style.
-- james
--- drivers/nvme/target/fc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/nvme/target/fc.c +4 -3
@@ -1132,11 +1132,12 @@ nvmet_fc_alloc_target_assoc(struct nvmet_fc_tgtport *tgtport, void *hosthandle)spin_lock_irqsave (&tgtport->lock, flags); needrandom = false; -list_for_each_entry (tmpassoc, &tgtport->assoc_list, a_list) +list_for_each_entry (tmpassoc, &tgtport->assoc_list, a_list) {if (ran == tmpassoc->association_id) { needrandom = true;break ; } + }if (!needrandom) { assoc->association_id = ran;list_add_tail (&assoc->a_list, &tgtport->assoc_list);
@@ -1837,7 +1838,7 @@ nvmet_fc_ls_disconnect(struct nvmet_fc_tgtport *tgtport, &iod->rqstbuf->rq_dis_assoc;struct fcnvme_ls_disconnect_assoc_acc *acc = &iod->rspbuf->rsp_dis_assoc; -struct nvmet_fc_tgt_assoc *assoc; +struct nvmet_fc_tgt_assoc *assoc =NULL ;struct nvmet_fc_ls_iod *oldls =NULL ;unsigned long flags;int ret =0 ;
@@ -1854,7 +1855,7 @@ nvmet_fc_ls_disconnect(struct nvmet_fc_tgtport *tgtport, ret =VERR_NO_ASSOC ; } -if (ret) { +if (ret || !assoc) {dev_err (tgtport->dev,"Disconnect LS failed: %s\n" , validation_errors[ret]);
Signature · 7 lines
2.16.4 _______________________________________________ linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Thanks, applied to nvme-5.8.
_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme