--- embedaddon/mpd/src/log.c 2013/07/22 08:44:29 1.1.1.1 +++ embedaddon/mpd/src/log.c 2021/03/17 00:39:23 1.1.1.4 @@ -176,11 +176,13 @@ LogClose(void) */ int -LogCommand(Context ctx, int ac, char *av[], void *arg) +LogCommand(Context ctx, int ac, const char *const av[], const void *arg) { u_int k; int bits, add; + const char *s; + (void)arg; if (ac == 0) { #define LG_FMT " %-12s %-10s %s\r\n" @@ -195,28 +197,29 @@ LogCommand(Context ctx, int ac, char *av[], void *arg) } while (ac--) { - switch (**av) { + s = *av; + switch (*s) { case '+': - (*av)++; + s++; default: add = TRUE; break; case '-': add = FALSE; - (*av)++; + s++; break; } for (k = 0; - k < NUM_LOG_LEVELS && strcasecmp(*av, LogOptionList[k].name); + k < NUM_LOG_LEVELS && strcasecmp(s, LogOptionList[k].name); k++); if (k < NUM_LOG_LEVELS) bits = LogOptionList[k].mask; else { - if (!strcasecmp(*av, "all")) { + if (!strcasecmp(s, "all")) { for (bits = k = 0; k < NUM_LOG_LEVELS; k++) bits |= LogOptionList[k].mask; } else { - Printf("\"%s\" is unknown. Enter \"log\" for list.\r\n", *av); + Printf("\"%s\" is unknown. Enter \"log\" for list.\r\n", s); bits = 0; } } @@ -246,22 +249,23 @@ LogPrintf(const char *fmt, ...) } void -vLogPrintf(const char *fmt, va_list args) +vLogPrintf(const char *fmt, va_list args) NO_THREAD_SAFETY_ANALYSIS { if (!SLIST_EMPTY(&gConsole.sessions)) { - char buf[256]; + char buf[1000]; ConsoleSession s; vsnprintf(buf, sizeof(buf), fmt, args); #ifdef SYSLOG_FACILITY syslog(LOG_INFO, "%s", buf); #endif + pthread_cleanup_push(ConsoleCancelCleanup, gConsole.lock); RWLOCK_RDLOCK(gConsole.lock); SLIST_FOREACH(s, &gConsole.sessions, next) { if (Enabled(&s->options, CONSOLE_LOGGING)) s->write(s, "%s\r\n", buf); } - RWLOCK_UNLOCK(gConsole.lock); + pthread_cleanup_pop(1); #ifdef SYSLOG_FACILITY } else { vsyslog(LOG_INFO, fmt, args); @@ -296,7 +300,8 @@ LogPrintf2(const char *fmt, ...) void LogDumpBp2(Mbuf bp, const char *fmt, ...) { - int k, total; + int k; + unsigned total; u_char bytes[DUMP_BYTES_PER_LINE]; char line[128]; int linelen; @@ -316,7 +321,8 @@ LogDumpBp2(Mbuf bp, const char *fmt, ...) total = 0; if (bp) { - int start, stop, last = 0; + int start, last = 0; + unsigned stop; stop = ROUNDUP(total + MBLEN(bp), DUMP_BYTES_PER_LINE); for (start = total; total < stop; ) {