If a file name does not end with ".ko", there is no need to call fstat.
Since common use cases are like "modinfo modname", the string check
should come first to save a tiny amount of system time.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/154
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
{
struct stat st;
- if (stat(name, &st) == 0 && S_ISREG(st.st_mode) &&
- path_ends_with_kmod_ext(name, strlen(name)))
+ if (path_ends_with_kmod_ext(name, strlen(name)) && stat(name, &st) == 0 &&
+ S_ISREG(st.st_mode))
return true;
return false;