From 1c5911fade98c14bdda106f93d81701c9f34cda7 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 7 Feb 2024 22:22:13 +0000 Subject: [PATCH] Remove unused addKernelPanicSubReason() return value. The only caller that was looking at the return value just stopped. Test: treehugger Change-Id: Icf2508e8e1ee4969918eadeb580f70236ba53496 --- bootstat/bootstat.cpp | 82 +++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 42 deletions(-) diff --git a/bootstat/bootstat.cpp b/bootstat/bootstat.cpp index 85a9935e4..d402bf17b 100644 --- a/bootstat/bootstat.cpp +++ b/bootstat/bootstat.cpp @@ -830,7 +830,7 @@ std::string getSubreason(const std::string& content, size_t pos, bool quoted) { return subReason; } -bool addKernelPanicSubReason(const pstoreConsole& console, std::string& ret) { +void addKernelPanicSubReason(const pstoreConsole& console, std::string& ret) { // Check for kernel panic types to refine information if ((console.rfind("SysRq : Trigger a crash") != std::string::npos) || (console.rfind("PC is at sysrq_handle_crash+") != std::string::npos)) { @@ -842,63 +842,61 @@ bool addKernelPanicSubReason(const pstoreConsole& console, std::string& ret) { if (pos != std::string::npos) { ret += "," + getSubreason(console, pos + strlen(sysrqSubreason), /* quoted */ true); } - return true; + return; } if (console.rfind("Unable to handle kernel NULL pointer dereference at virtual address") != std::string::npos) { ret = "kernel_panic,null"; - return true; + return; } if (console.rfind("Kernel BUG at ") != std::string::npos) { ret = "kernel_panic,bug"; - return true; + return; } std::string panic("Kernel panic - not syncing: "); auto pos = console.rfind(panic); - if (pos != std::string::npos) { - static const std::vector> panicReasons = { - {"Out of memory", "oom"}, - {"out of memory", "oom"}, - {"Oh boy, that early out of memory", "oom"}, // omg - {"BUG!", "bug"}, - {"hung_task: blocked tasks", "hung"}, - {"audit: ", "audit"}, - {"scheduling while atomic", "atomic"}, - {"Attempted to kill init!", "init"}, - {"Requested init", "init"}, - {"No working init", "init"}, - {"Could not decompress init", "init"}, - {"RCU Stall", "hung,rcu"}, - {"stack-protector", "stack"}, - {"kernel stack overflow", "stack"}, - {"Corrupt kernel stack", "stack"}, - {"low stack detected", "stack"}, - {"corrupted stack end", "stack"}, - {"subsys-restart: Resetting the SoC - modem crashed.", "modem"}, - {"subsys-restart: Resetting the SoC - adsp crashed.", "adsp"}, - {"subsys-restart: Resetting the SoC - dsps crashed.", "dsps"}, - {"subsys-restart: Resetting the SoC - wcnss crashed.", "wcnss"}, - }; + if (pos == std::string::npos) return; - ret = "kernel_panic"; - for (auto& s : panicReasons) { - if (console.find(panic + s.first, pos) != std::string::npos) { - ret += "," + s.second; - return true; - } + static const std::vector> panicReasons = { + {"Out of memory", "oom"}, + {"out of memory", "oom"}, + {"Oh boy, that early out of memory", "oom"}, // omg + {"BUG!", "bug"}, + {"hung_task: blocked tasks", "hung"}, + {"audit: ", "audit"}, + {"scheduling while atomic", "atomic"}, + {"Attempted to kill init!", "init"}, + {"Requested init", "init"}, + {"No working init", "init"}, + {"Could not decompress init", "init"}, + {"RCU Stall", "hung,rcu"}, + {"stack-protector", "stack"}, + {"kernel stack overflow", "stack"}, + {"Corrupt kernel stack", "stack"}, + {"low stack detected", "stack"}, + {"corrupted stack end", "stack"}, + {"subsys-restart: Resetting the SoC - modem crashed.", "modem"}, + {"subsys-restart: Resetting the SoC - adsp crashed.", "adsp"}, + {"subsys-restart: Resetting the SoC - dsps crashed.", "dsps"}, + {"subsys-restart: Resetting the SoC - wcnss crashed.", "wcnss"}, + }; + + ret = "kernel_panic"; + for (auto& s : panicReasons) { + if (console.find(panic + s.first, pos) != std::string::npos) { + ret += "," + s.second; + return; } - auto reason = getSubreason(console, pos + panic.length(), /* newline */ false); - if (reason.length() > 3) { - ret += "," + reason; - } - return true; } - return false; + auto reason = getSubreason(console, pos + panic.length(), /* newline */ false); + if (reason.length() > 3) { + ret += "," + reason; + } } -bool addKernelPanicSubReason(const std::string& content, std::string& ret) { - return addKernelPanicSubReason(pstoreConsole(content), ret); +void addKernelPanicSubReason(const std::string& content, std::string& ret) { + addKernelPanicSubReason(pstoreConsole(content), ret); } const char system_reboot_reason_property[] = "sys.boot.reason";