Skip to content

Commit ff28476

Browse files
committed
common/rc: Optimize _module_file_exists()
Reduce the time spent in _module_file_exists() by eliminating one fork() call. Signed-off-by: Bart Van Assche <[email protected]>
1 parent 87411d3 commit ff28476

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

common/rc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,13 @@ _module_file_exists()
3737
local ko_underscore=${1//-/_}.ko
3838
local ko_hyphen=${1//_/-}.ko
3939
local libpath
40-
local -i count
4140

4241
libpath="/lib/modules/$(uname -r)/kernel"
4342
[[ ! -d $libpath ]] && return 1
44-
count=$(find "$libpath" -name "$ko_underscore*" -o \
45-
-name "$ko_hyphen*" | wc -l)
46-
((count)) && return 0
47-
return 1
43+
local module_path
44+
module_path="$(find "$libpath" -name "$ko_underscore*" -o \
45+
-name "$ko_hyphen*")"
46+
[ -n "${module_path}" ]
4847
}
4948

5049
# Check that the specified module or driver is available, regardless of whether

0 commit comments

Comments
 (0)