Skip to content

Commit

Permalink
common/rc: test _have_driver before checking driver parameter
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Shin'ichiro Kawasaki <[email protected]>
  • Loading branch information
zhijianli88 authored and kawasaki committed Jan 16, 2025
1 parent f6c0fd9 commit 542e523
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions common/rc
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,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
Expand All @@ -98,10 +100,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
Expand Down

0 comments on commit 542e523

Please sign in to comment.