Message ID | 20250107061905.91316-2-lizhijian@fujitsu.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Cleanup and Optimization in requires() | expand |
diff --git a/common/rc b/common/rc index 0c8b51f64291..7fd178b01989 100644 --- a/common/rc +++ b/common/rc @@ -77,6 +77,8 @@ _have_module() { } _have_module_param() { + _have_driver "$1" || return + if [ -d "/sys/module/$1" ]; then if [ -e "/sys/module/$1/parameters/$2" ]; then return 0 @@ -96,10 +98,6 @@ _have_module_param_value() { local expected_value="$3" local value - if ! _have_driver "$modname"; then - return 1; - fi - if ! _have_module_param "$modname" "$param"; then return 1 fi
Similar to previous _have_module_param_value() and to improve efficiency and avoid unnecessary error messages, _have_module_param() should first verify the presence of the driver using _have_driver(). This change prevents redundant checks if the driver is not available. Previously, an unintended error message 'modinfo: ERROR: Module scsi_debug not found' was displayed before the test execution. For example: # ./check scsi/005 modinfo: ERROR: Module scsi_debug not found. scsi/005 (test SCSI device blacklisting) [not run] driver scsi_debug is not available module scsi_debug does not have parameter inq_vendor Signed-off-by: Li Zhijian <lizhijian@fujitsu.com> --- common/rc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)