--- embedaddon/mpd/src/console.c 2019/10/22 13:49:55 1.1.1.4 +++ embedaddon/mpd/src/console.c 2021/03/17 00:39:23 1.1.1.5 @@ -58,7 +58,7 @@ static int ConsoleUserHashEqual(struct ghash *g, const void *item1, const void *item2); static u_int32_t ConsoleUserHash(struct ghash *g, const void *item); - static int ConsoleSetCommand(Context ctx, int ac, char *av[], void *arg); + static int ConsoleSetCommand(Context ctx, int ac, const char *const av[], const void *arg); /* @@ -76,7 +76,7 @@ ConsoleSetCommand, NULL, 0, (void *) SET_ENABLE }, { "disable [opt ...]", "Disable this console option" , ConsoleSetCommand, NULL, 0, (void *) SET_DISABLE }, - { NULL }, + { NULL, NULL, NULL, NULL, 0, NULL }, }; struct ghash *gUsers; /* allowed users */ @@ -96,8 +96,8 @@ { 0, 0, NULL }, }; - struct termios gOrigTermiosAttrs; - int gOrigFlags; +static struct termios gOrigTermiosAttrs; +static int gOrigFlags; /* * ConsoleInit() @@ -176,7 +176,7 @@ ConsoleClose(Console c) } void -ConsoleCancelCleanup(void *rwlock) +ConsoleCancelCleanup(void *rwlock) NO_THREAD_SAFETY_ANALYSIS { pthread_rwlock_t p = (pthread_rwlock_t)rwlock; @@ -188,13 +188,18 @@ ConsoleCancelCleanup(void *rwlock) */ int -ConsoleStat(Context ctx, int ac, char *av[], void *arg) +ConsoleStat(Context ctx, int ac, const char *const av[], const void *arg) + NO_THREAD_SAFETY_ANALYSIS { Console c = &gConsole; ConsoleSession s; ConsoleSession cs = ctx->cs; char addrstr[INET6_ADDRSTRLEN]; + (void)ac; + (void)av; + (void)arg; + Printf("Configuration:\r\n"); Printf("\tState : %s\r\n", c->fd ? "OPENED" : "CLOSED"); Printf("\tIP-Address : %s\r\n", u_addrtoa(&c->addr,addrstr,sizeof(addrstr))); @@ -234,7 +239,8 @@ ConsoleConnect(int type, void *cookie) "\xFF\xFD\x01"; /* DO echo */ char addrstr[INET6_ADDRSTRLEN]; struct sockaddr_storage ss; - + + (void)type; Log(LG_CONSOLE, ("CONSOLE: Connect")); cs = Malloc(MB_CONS, sizeof(*cs)); if ((cs->fd = TcpAcceptConnection(c->fd, &ss, FALSE)) < 0) @@ -392,6 +398,7 @@ ConsoleSessionReadEvent(int type, void *cookie) char *av_copy[MAX_CONSOLE_ARGS]; char addrstr[INET6_ADDRSTRLEN]; + (void)type; while(1) { if ((n = read(cs->fd, &c, 1)) <= 0) { if (n < 0) { @@ -612,9 +619,9 @@ success: cs->context.lnk ? cs->context.lnk->name : (cs->context.bund? cs->context.bund->name : ""), cs->user.username, cs->cmd)); - DoCommand(&cs->context, ac, av, NULL, 0); + DoCommand(&cs->context, ac, (const char *const *)av, NULL, 0); } else { - HelpCommand(&cs->context, ac, av, NULL); + HelpCommand(&cs->context, ac, (const char *const *)av, NULL); } FreeArgs(ac, av_copy); if (cs->exit) @@ -719,6 +726,7 @@ StdConsoleSessionWrite(ConsoleSession cs, const char * static void StdConsoleSessionWriteV(ConsoleSession cs, const char *fmt, va_list vl) { + (void)cs; vprintf(fmt, vl); fflush(stdout); } @@ -765,10 +773,11 @@ ConsoleSessionShowPrompt(ConsoleSession cs) static u_int32_t ConsoleUserHash(struct ghash *g, const void *item) { - ConsoleUser u = (ConsoleUser) item; - u_char *s = (u_char *) u->username; + const struct console_user *u = (const struct console_user *) item; + const u_char *s = (const u_char *) u->username; u_int32_t hash = 0x811c9dc5; + (void)g; while (*s) { hash += (hash<<1) + (hash<<4) + (hash<<7) + (hash<<8) + (hash<<24); /* xor the bottom with the current octet */ @@ -785,9 +794,10 @@ ConsoleUserHash(struct ghash *g, const void *item) static int ConsoleUserHashEqual(struct ghash *g, const void *item1, const void *item2) { - ConsoleUser u1 = (ConsoleUser) item1; - ConsoleUser u2 = (ConsoleUser) item2; + const struct console_user *u1 = (const struct console_user *) item1; + const struct console_user *u2 = (const struct console_user *) item2; + (void)g; if (u1 && u2) return (strcmp(u1->username, u2->username) == 0); else @@ -799,7 +809,7 @@ ConsoleUserHashEqual(struct ghash *g, const void *item */ static int -ConsoleSetCommand(Context ctx, int ac, char *av[], void *arg) +ConsoleSetCommand(Context ctx, int ac, const char *const av[], const void *arg) { Console c = &gConsole; ConsoleSession cs = ctx->cs; @@ -874,10 +884,13 @@ ConsoleShutdown(Console c) */ int -UserCommand(Context ctx, int ac, char *av[], void *arg) +UserCommand(Context ctx, int ac, const char *const av[], const void *arg) { ConsoleUser u; + (void)arg; + (void)ctx; + if (ac < 2 || ac > 3) return(-1); @@ -908,10 +921,15 @@ UserCommand(Context ctx, int ac, char *av[], void *arg */ int -UserStat(Context ctx, int ac, char *av[], void *arg) +UserStat(Context ctx, int ac, const char *const av[], const void *arg) + NO_THREAD_SAFETY_ANALYSIS { struct ghash_walk walk; ConsoleUser u; + + (void)ac; + (void)av; + (void)arg; Printf("Configured users:\r\n"); pthread_cleanup_push(ConsoleCancelCleanup, gUsersLock);