diff options
author | Elliott Hughes <enh@google.com> | 2023-04-17 23:12:58 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-04-17 23:12:58 +0000 |
commit | b05398e85acc2e73763d7537d876baec70103979 (patch) | |
tree | 5a68bde37dae41ca6c7e9076ab47dbfc02d20ab7 | |
parent | 41263a045bee2884428b213d8dd808bb6892ee8d (diff) | |
parent | 84670993d4088cb3bdb85e99037cf81b59d43f12 (diff) | |
download | toybox-b05398e85acc2e73763d7537d876baec70103979.tar.gz |
Merge "Upgrade toybox to 8626a6ac7dff93bf97f754c93c3e426ee5c6b1e0" am: abfa1d892f am: 3d11fff0fe am: e5bf8d33fd am: 84670993d4
Original change: https://android-review.googlesource.com/c/platform/external/toybox/+/2540670
Change-Id: I2dea13e6dcbaf8aa864abc44fc8da550e3e7ae74
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | METADATA | 4 | ||||
-rw-r--r-- | toys/other/oneit.c | 15 | ||||
-rw-r--r-- | toys/other/vmstat.c | 2 |
3 files changed, 11 insertions, 10 deletions
@@ -13,11 +13,11 @@ third_party { type: GIT value: "https://github.com/landley/toybox" } - version: "c8f758c734506d6131c2eefdb5ce2618d4b2b1d2" + version: "8626a6ac7dff93bf97f754c93c3e426ee5c6b1e0" license_type: UNENCUMBERED last_upgrade_date { year: 2023 month: 4 - day: 14 + day: 17 } } diff --git a/toys/other/oneit.c b/toys/other/oneit.c index d154f582..c0b0c09d 100644 --- a/toys/other/oneit.c +++ b/toys/other/oneit.c @@ -72,14 +72,15 @@ void oneit_main(void) // Autodetect console from sysfs if no -c memcpy(toybuf, "/dev/", 5); - if (!TT.c && (TT.c = readfile("/sys/class/tty/console/active", ss, 4096))) { - // Remove null terminator, take last entry - for (;;) { - if (!(ss = strchr(TT.c, '\n'))) break; - if (!ss[1]) *ss = 0; - else TT.c = ++ss; + i = sizeof(toybuf)-6; + if (!TT.c && (TT.c = readfile("/sys/class/tty/console/active", ss, i))) { + // Take last entry, remove newline terminator + while (TT.c[i = strcspn(TT.c, " \n")]) { + TT.c[i++] = 0; + if (TT.c[i]) TT.c += i; + else break; } - // Ensure /dev prefix + // Ensure exactly one /dev prefix strstart(&TT.c, "/dev/"); memmove(toybuf+5, TT.c, strlen(TT.c)); TT.c = toybuf; diff --git a/toys/other/vmstat.c b/toys/other/vmstat.c index ebe5399e..94502f1f 100644 --- a/toys/other/vmstat.c +++ b/toys/other/vmstat.c @@ -49,7 +49,7 @@ static void get_vmstat_proc(struct vmstat_proc *vmsp) "Buffers:", "Cached:", "SwapFree:", "SwapTotal:", "SReclaimable:", "/proc/vmstat", "pgpgin ", "pgpgout ", "pswpin ", "pswpout " }; unsigned long long *new = (void *)vmsp; - char *p, *name = name, *file = 0; + char *p = 0, *name = name, *file = 0; int i, j; // We use vmstuff to fill out vmstat_proc as an array of long long: |