Re: [PATCH blktests v3 3/3] nvme: introduce nvmet_target_{setup/cleanup} common code

From: Shinichiro Kawasaki
Date: Thu Aug 24 2023 - 20:54:47 EST


On Aug 24, 2023 / 07:36, Bart Van Assche wrote:
> On 8/23/23 20:09, Shinichiro Kawasaki wrote:
> > CC+: Bart,
> >
> > This patch makes shellcheck unhappy:
> >
> > tests/nvme/003:26:2: note: Use _nvmet_target_setup "$@" if function's $1 should mean script's $1. [SC2119]
> > tests/nvme/004:26:2: note: Use _nvmet_target_setup "$@" if function's $1 should mean script's $1. [SC2119]
> > tests/nvme/005:26:2: note: Use _nvmet_target_setup "$@" if function's $1 should mean script's $1. [SC2119]
> > tests/nvme/006:24:2: note: Use _nvmet_target_setup "$@" if function's $1 should mean script's $1. [SC2119]
> > tests/nvme/008:25:2: note: Use _nvmet_target_setup "$@" if function's $1 should mean script's $1. [SC2119]
> > tests/nvme/010:25:2: note: Use _nvmet_target_setup "$@" if function's $1 should mean script's $1. [SC2119]
> > tests/nvme/012:29:2: note: Use _nvmet_target_setup "$@" if function's $1 should mean script's $1. [SC2119]
> > tests/nvme/014:28:2: note: Use _nvmet_target_setup "$@" if function's $1 should mean script's $1. [SC2119]
> > tests/nvme/018:26:2: note: Use _nvmet_target_setup "$@" if function's $1 should mean script's $1. [SC2119]
> > tests/nvme/019:27:2: note: Use _nvmet_target_setup "$@" if function's $1 should mean script's $1. [SC2119]
> > tests/nvme/023:25:2: note: Use _nvmet_target_setup "$@" if function's $1 should mean script's $1. [SC2119]
> >
> > But I think the warn SC2119 is false-positive and we should suppress it. In the
> > past, blktests had suppressed it until the recent commit 26664dff17b6 ("Do not
> > suppress any shellcheck warnings"). I think this commit should be reverted
> > together with this series.
> Please do not revert commit 26664dff17b6 because it produces useful
> warnings.

Hmm, I see... SC2119 is false-positive for this patch, but it sometimes useful
functions which takes "$@" as arguments.

> Do you agree that the above warnings are easy to suppress,
> e.g. by changing "_nvmet_target_setup" into
> "_nvmet_target_setup ignored_argument"?

This works, but a bit ugly. Another idea is to make one of the optional
arguments mandatory, a positional argument. I think the option --device_type
worth making mandatory and explicit, like,

_nvmet_target_setup device
_nvmet_target_setup file

This will make it easier for me to review which test case uses which type.
(This might be against Sagi's comment, though.)

Daniel, what do you think?