Skip to content

Commit

Permalink
Remove unused addKernelPanicSubReason() return value.
Browse files Browse the repository at this point in the history
The only caller that was looking at the return value just stopped.

Test: treehugger
Change-Id: Icf2508e8e1ee4969918eadeb580f70236ba53496
  • Loading branch information
enh-google committed Feb 7, 2024
1 parent c72c9a6 commit 1c5911f
Showing 1 changed file with 40 additions and 42 deletions.
82 changes: 40 additions & 42 deletions bootstat/bootstat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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<std::pair<const std::string, const std::string>> 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;

static const std::vector<std::pair<const std::string, const std::string>> 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 true;
}
}
auto reason = getSubreason(console, pos + panic.length(), /* newline */ false);
if (reason.length() > 3) {
ret += "," + reason;
ret = "kernel_panic";
for (auto& s : panicReasons) {
if (console.find(panic + s.first, pos) != std::string::npos) {
ret += "," + s.second;
return;
}
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";
Expand Down

0 comments on commit 1c5911f

Please sign in to comment.