From db15b6f93d828d0c4a9705e845b41d48be22b6f2 Mon Sep 17 00:00:00 2001 From: Kelvin Zhang Date: Wed, 3 May 2023 15:28:39 -0700 Subject: [PATCH] Improve error message of libmodprobe Log path of module if that module is not found. Bug: 273752147 Test: th Change-Id: I428a116ee26f97455229df642acbdc1297098a32 --- libmodprobe/libmodprobe.cpp | 5 +++-- libmodprobe/libmodprobe_ext.cpp | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libmodprobe/libmodprobe.cpp b/libmodprobe/libmodprobe.cpp index 858b9555f..d20b6b10a 100644 --- a/libmodprobe/libmodprobe.cpp +++ b/libmodprobe/libmodprobe.cpp @@ -230,7 +230,7 @@ void Modprobe::ParseCfg(const std::string& cfg, } std::vector lines = android::base::Split(cfg_contents, "\n"); - for (const std::string line : lines) { + for (const auto& line : lines) { if (line.empty() || line[0] == '#') { continue; } @@ -421,7 +421,8 @@ bool Modprobe::LoadWithAliases(const std::string& module_name, bool strict, } if (strict && !module_loaded) { - LOG(ERROR) << "LoadWithAliases was unable to load " << module_name; + LOG(ERROR) << "LoadWithAliases was unable to load " << module_name + << ", tried: " << android::base::Join(modules_to_load, ", "); return false; } return true; diff --git a/libmodprobe/libmodprobe_ext.cpp b/libmodprobe/libmodprobe_ext.cpp index 94a1dc4e9..c4519e392 100644 --- a/libmodprobe/libmodprobe_ext.cpp +++ b/libmodprobe/libmodprobe_ext.cpp @@ -84,7 +84,7 @@ bool Modprobe::Rmmod(const std::string& module_name) { } bool Modprobe::ModuleExists(const std::string& module_name) { - struct stat fileStat; + struct stat fileStat {}; if (blocklist_enabled && module_blocklist_.count(module_name)) { LOG(INFO) << "module " << module_name << " is blocklisted"; return false; @@ -95,7 +95,7 @@ bool Modprobe::ModuleExists(const std::string& module_name) { return false; } if (stat(deps.front().c_str(), &fileStat)) { - LOG(INFO) << "module " << module_name << " does not exist"; + PLOG(INFO) << "module " << module_name << " can't be loaded; can't access " << deps.front(); return false; } if (!S_ISREG(fileStat.st_mode)) {