Use strany() instead of enum and strcmp staircase.
diff --git a/lib/portability.h b/lib/portability.h index 55e3ab2..29d5469 100644 --- a/lib/portability.h +++ b/lib/portability.h
@@ -302,16 +302,6 @@ ANDROID_LOG_FATAL, ANDROID_LOG_SILENT, } android_LogPriority; -typedef enum log_id { - LOG_ID_MAIN = 0, - LOG_ID_RADIO = 1, - LOG_ID_EVENTS = 2, - LOG_ID_SYSTEM = 3, - LOG_ID_CRASH = 4, - LOG_ID_STATS = 5, - LOG_ID_SECURITY = 6, - LOG_ID_KERNEL = 7, -} log_id_t; #endif #if !defined(__BIONIC__) || defined(__ANDROID_NDK__) // Android NDKv18 has liblog.so but not liblog.a for static builds.
diff --git a/toys/android/log.c b/toys/android/log.c index 5c4dcd9..1b05f4e 100644 --- a/toys/android/log.c +++ b/toys/android/log.c
@@ -49,15 +49,9 @@ ANDROID_LOG_VERBOSE, ANDROID_LOG_WARN}[i]; } if (!TT.t) TT.t = "log"; - if (!TT.b || !strcmp(TT.b, "main")) TT.buf = LOG_ID_MAIN; - else if (!strcmp(TT.b, "radio")) TT.buf = LOG_ID_RADIO; - else if (!strcmp(TT.b, "events")) TT.buf = LOG_ID_EVENTS; - else if (!strcmp(TT.b, "system")) TT.buf = LOG_ID_SYSTEM; - else if (!strcmp(TT.b, "crash")) TT.buf = LOG_ID_CRASH; - else if (!strcmp(TT.b, "stats")) TT.buf = LOG_ID_STATS; - else if (!strcmp(TT.b, "security")) TT.buf = LOG_ID_SECURITY; - else if (!strcmp(TT.b, "kernel")) TT.buf = LOG_ID_KERNEL; - else error_exit("unknown log buffer: %s", TT.b); + if (TT.b) TT.buf = anystr(TT.b, (char *[]){"main", "radio", "events", + "system", "crash", "stats", "security", "kernel", 0})-1; + if (TT.buf<0) error_exit("unknown log buffer: %s", TT.b); if (toys.optc) { for (i = 0; toys.optargs[i]; i++) {