mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-25 02:35:22 +00:00
crossystem: Fix cros_debug detection on non-chrome systems.
"cros_debug" is usually the last token of kernel command line on UEFI/legacy
BIOS systems.
However, kernel command line may end with new line ("\n") and that may cause
strcmp to fail (i.e., can't detect "cros_debug" if it's the last parameter in
command line), so we need to add that into strtok delimiters.
BRANCH=none
BUG=chromium:222248
TEST=crossystem cros_debug # display 1 on UEFI system with cros_debug
Change-Id: I9aed1562291469118acbadcc5211ff5c45eb9feb
Reviewed-on: https://gerrit.chromium.org/gerrit/46106
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Hung-Te Lin <hungte@chromium.org>
This commit is contained in:
@@ -129,6 +129,7 @@ int VbGetCrosDebug(void) {
|
|||||||
FILE* f = NULL;
|
FILE* f = NULL;
|
||||||
char buf[4096] = "";
|
char buf[4096] = "";
|
||||||
char *t, *saveptr;
|
char *t, *saveptr;
|
||||||
|
const char *delimiters = " \r\n";
|
||||||
|
|
||||||
/* If the currently running system specifies its debug status, use
|
/* If the currently running system specifies its debug status, use
|
||||||
* that in preference to other indicators. */
|
* that in preference to other indicators. */
|
||||||
@@ -138,7 +139,8 @@ int VbGetCrosDebug(void) {
|
|||||||
buf[0] = 0;
|
buf[0] = 0;
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
for (t = strtok_r(buf, " ", &saveptr); t; t=strtok_r(NULL, " ", &saveptr)) {
|
for (t = strtok_r(buf, delimiters, &saveptr); t;
|
||||||
|
t = strtok_r(NULL, delimiters, &saveptr)) {
|
||||||
if (0 == strcmp(t, "cros_debug"))
|
if (0 == strcmp(t, "cros_debug"))
|
||||||
return 1;
|
return 1;
|
||||||
else if (0 == strcmp(t, "cros_nodebug"))
|
else if (0 == strcmp(t, "cros_nodebug"))
|
||||||
|
|||||||
Reference in New Issue
Block a user