From: Ari Johnson Date: Fri, 2 May 2025 13:22:36 +0000 (-0400) Subject: Miscellaneous formatting improvements to suppress compiler warnings X-Git-Url: https://git.theari.com/?a=commitdiff_plain;h=641762966670be6de437decc1930d3c2bd660ad4;p=cobramush.git Miscellaneous formatting improvements to suppress compiler warnings --- diff --git a/src/access.c b/src/access.c index 6d1bee4..2535497 100644 --- a/src/access.c +++ b/src/access.c @@ -269,7 +269,7 @@ write_access_file(void) fprintf(fp, "!%s ", c->name); break; } - if (ap->comment && *ap->comment) + if (*ap->comment) fprintf(fp, "# %s\n", ap->comment); else fprintf(fp, "\n"); diff --git a/src/bsd.c b/src/bsd.c index 735b1f2..74ae633 100644 --- a/src/bsd.c +++ b/src/bsd.c @@ -194,12 +194,12 @@ static CLIENT_DEFAULTS client_maps[] = { * option negotiation code for setting client-side line-editing mode * to it. If it gets a reply, a flag in the descriptor struct is * turned on indicated telnet-awareness. - * + * * If the reply indicates that the client supports linemode, further * instructions as to what linemode options are to be used is sent. * Those options: Client-side line editing, and expanding literal * client-side-entered tabs into spaces. - * + * * Option negotation requests sent by the client are processed, * with the only one we confirm rather than refuse outright being * suppress-go-ahead, since a number of telnet clients try it. @@ -243,7 +243,7 @@ static const char *register_success = static const char *shutdown_message = "Going down - Bye"; #ifndef COMPILE_CONSOLE #ifdef HAS_OPENSSL -static const char *ssl_shutdown_message = +static const char *ssl_shutdown_message = "GAME: SSL connections must be dropped, sorry."; #endif #endif @@ -715,7 +715,7 @@ set_signals(void) install_sig_handler(SIGINT, signal_shutdown); install_sig_handler(SIGTERM, bailout); #else - /* Win32 stuff: + /* Win32 stuff: * No support for SIGUSR2 or SIGINT. * SIGTERM is never generated on NT-based Windows (according to MSDN) * MSVC++ will let you get away with installing a handler anyway, @@ -1470,7 +1470,7 @@ logout_sock(DESC *d) d->unidle_times++; } snprintf(tbuf1, BUFFER_LEN-1, "%ld %ld %d %d", (mudtime - d->connected_at), - d->idle_total, d->unidle_times, d->cmds); + d->idle_total, d->unidle_times, d->cmds); tbuf1[strlen(tbuf1)+1] = '\0'; (void) atr_add(d->player, "LASTACTIVITY", tbuf1, GOD, NOTHING); announce_disconnect(d->player); @@ -1553,8 +1553,8 @@ shutdownsock(DESC *d) d->idle_total += difftime(mudtime, d->last_time); d->unidle_times++; } - snprintf(tbuf1, BUFFER_LEN-1, "%ld %ld %d %d", (mudtime - d->connected_at), - d->idle_total , d->unidle_times, d->cmds); + snprintf(tbuf1, BUFFER_LEN-1, "%ld %ld %d %d", (mudtime - d->connected_at), + d->idle_total , d->unidle_times, d->cmds); tbuf1[strlen(tbuf1)+1] = '\0'; (void) atr_add(d->player, "LASTACTIVITY", tbuf1, GOD, NOTHING); announce_disconnect(d->player); @@ -2703,7 +2703,7 @@ process_commands(void) } retval = cdesc->input_handler(cdesc, (char *) t->start); reset_cpu_timer(); - if(retval == -1 && do_su_exit(cdesc)) + if(retval == -1 && do_su_exit(cdesc)) retval = 1; if (retval == 0) { @@ -2752,7 +2752,7 @@ do_command(DESC *d, char *command) (d->cmds)++; - if(difftime(mudtime, d->last_time) >= 300) { + if(difftime(mudtime, d->last_time) >= 300) { d->idle_total += difftime(mudtime, d->last_time); d->unidle_times++; } @@ -3469,7 +3469,7 @@ dump_users(DESC *call_by, char *match, int doing) { DESC *d; #ifdef COLOREDWHO - int tcount = 0; + int tcount = 0; #endif int count = 0; time_t now; @@ -3519,8 +3519,8 @@ dump_users(DESC *call_by, char *match, int doing) if (d->connected) { if (!GoodObject(d->player)) continue; - if (COUNT_ALL || (!Hidden(d) || call_by->player == d->player - || (call_by->player && Priv_Who(call_by->player)))) { + if (COUNT_ALL || (!Hidden(d) || call_by->player == d->player || + (call_by->player && Priv_Who(call_by->player)))) { count++; #ifdef COLOREDWHO tcount++; @@ -3582,22 +3582,21 @@ dump_users(DESC *call_by, char *match, int doing) if (!Hidden(d) || call_by->player == d->player || (call_by->player && Priv_Who(call_by->player) && (doing))) { - sprintf(tbuf1, "%-16s %4s %10s %4s%c %s", tprintf("%s%s", Name(d->player), InProg(d->player) ? "(P)" : ""), empabb(d->player), - time_format_1(now - d->connected_at), + sprintf(tbuf1, "%-16s %4s %10s %4s%c %s", tprintf("%s%s", Name(d->player), InProg(d->player) ? "(P)" : ""), + empabb(d->player), time_format_1(now - d->connected_at), time_format_2(now - d->last_time), - (Dark(d->player) ? 'D' : (Hidden(d) ? 'H' : ' ')) - , d->doing); + (Dark(d->player) ? 'D' : (Hidden(d) ? 'H' : ' ')), + d->doing); } } if (!Hidden(d) || (call_by->player && Priv_Who(call_by->player))) { #ifdef COLOREDWHO if(ShowAnsiColor(call_by->player)) - queue_string(call_by, tprintf("%s%s%s%s%s", ANSI_NORMAL, (tcount % 2 ? "" : ANSI_HILITE), - (tcount % 2 ? ANSI_CYAN : ANSI_WHITE), - tbuf1, ANSI_NORMAL)); + queue_string(call_by, tprintf("%s%s%s%s%s", ANSI_NORMAL, (tcount % 2 ? "" : ANSI_HILITE), + (tcount % 2 ? ANSI_CYAN : ANSI_WHITE), tbuf1, ANSI_NORMAL)); - else + else #endif queue_string(call_by, tbuf1); queue_newwrite(call_by, (unsigned char *) "\r\n", 2); @@ -3646,7 +3645,7 @@ dump_users(DESC *call_by, char *match, int doing) if(ShowAnsiColor(call_by->player)) queue_string(call_by, tprintf("%s%s%s%s%s", ANSI_NORMAL,tcount % 2 ? "" : ANSI_HILITE, tcount % 2 ? ANSI_CYAN : ANSI_WHITE, tbuf1, ANSI_NORMAL)); - else + else #endif queue_string(call_by, tbuf1); queue_newwrite(call_by, (unsigned char *) "\r\n", 2); @@ -3668,7 +3667,7 @@ dump_users(DESC *call_by, char *match, int doing) if(ShowAnsiColor(call_by->player)) queue_string(call_by, tprintf("%s%s%s%s%s", ANSI_NORMAL, (tcount+1) % 2 ? "" : ANSI_HILITE , (tcount+1) % 2 ? ANSI_CYAN : ANSI_WHITE, tbuf1, ANSI_NORMAL)); - else + else #endif queue_string(call_by, tbuf1); if (SUPPORT_PUEBLO && (call_by->conn_flags & CONN_HTML)) { @@ -4061,7 +4060,7 @@ do_poll(dbref player, const char *message, int clear) /** Match the partial name of a connected player. * \param match string to match. - * \return dbref of a unique connected player whose name partial-matches, + * \return dbref of a unique connected player whose name partial-matches, * AMBIGUOUS, or NOTHING. */ dbref @@ -4098,7 +4097,7 @@ short_page(const char *match) /** Match the partial name of a connected player the enactor can see. * \param player the enactor * \param match string to match. - * \return dbref of a unique connected player whose name partial-matches, + * \return dbref of a unique connected player whose name partial-matches, * AMBIGUOUS, or NOTHING. */ dbref @@ -4158,7 +4157,7 @@ FUNCTION(fun_lwho) if(!Priv_Who(victim)) powered = 0; } else victim = executor; - + if(xwho) { if (!is_strict_integer(args[0]) || !is_strict_integer(args[1])) { safe_str(T(e_int), buff, bp); @@ -4618,7 +4617,6 @@ FUNCTION(fun_idle_average) { safe_number(0, buff, bp); else safe_number((match->idle_total / match->unidle_times), buff, bp); - } else safe_str("-1", buff, bp); } @@ -4640,7 +4638,7 @@ FUNCTION(fun_unidle_times) { DESC *match = lookup_desc(executor, args[0]); if(match) { - safe_number((difftime(mudtime, match->last_time) >= 300) ? + safe_number((difftime(mudtime, match->last_time) >= 300) ? (match->unidle_times+1) : match->unidle_times, buff, bp); } else safe_str("-1", buff, bp); @@ -4728,7 +4726,7 @@ FUNCTION(fun_lports) FUNCTION(fun_ports) { /* returns a list of the network descriptors that a player is - * connected to + * connected to */ dbref target; @@ -4792,7 +4790,7 @@ hide_player(dbref player, int hide) notify(player, T("You now appear on the WHO list.")); } -/** Perform the periodic check of inactive descriptors, and +/** Perform the periodic check of inactive descriptors, and * disconnect them or autohide them as appropriate. */ void @@ -4833,7 +4831,7 @@ inactivity_check(void) idle = atoi(tbuf); if(idle > 0) goto after_idle_atr_check; - } + } idle = INACTIVITY_LIMIT ? INACTIVITY_LIMIT : INT_MAX; after_idle_atr_check: if ((d->connected) ? (idle_for > idle ) : (idle_for > unconnected_idle)) { @@ -5413,7 +5411,7 @@ load_reboot_db(void) /* Syntax: @snoop[/list] [!] - */ + */ COMMAND(cmd_snoop) { DESC *d; int descn, on, n, sn; @@ -5421,83 +5419,81 @@ COMMAND(cmd_snoop) { char buf[BUFFER_LEN], *bp; if(SW_ISSET(sw, SWITCH_LIST)) { - descn = atoi(arg_left); - - bp = buf; + descn = atoi(arg_left); + bp = buf; + d = port_desc(descn); - d = port_desc(descn); + if (LEVEL(player) <= 28) { + notify(player, MSG_HUH); + return; + } + /* make sure teh desc exists and they're connected (no spying on 'em at the connect screen!) */ + if(!d || (d && !IsPlayer(d->player))) { + notify(player, "There is no one connected on that descriptor."); + return; + } - if (LEVEL(player) <= 28) { - notify(player, MSG_HUH); - return; - } - /* make sure teh desc exists and they're connected (no spying on 'em at the connect screen!) */ - if(!d || (d && !IsPlayer(d->player))) { - notify(player, "There is no one connected on that descriptor."); - return; - } + for(sn = 0, n = 0; n < MAX_SNOOPS; n++) + if(d->snooper[n] != -1) { + memset(snooplist[sn], '\0', BUFFER_LEN); + snprintf(snooplist[sn++], BUFFER_LEN-1, "%s", Name(d->snooper[n])); + } - for(sn = 0, n = 0; n < MAX_SNOOPS; n++) - if(d->snooper[n] != -1) { - memset(snooplist[sn], '\0', BUFFER_LEN); - snprintf(snooplist[sn++], BUFFER_LEN-1, "%s", Name(d->snooper[n])); - } - *snooplist[sn] = '\0'; - - for(n = 0; n < sn; n++) { - if(n != 0) - safe_str(", ", buf, &bp); - if(n == (sn-1) && sn > 1) - safe_str("& ", buf, &bp); - safe_str(snooplist[n], buf, &bp); - } - *bp = '\0'; - notify_format(player, "%s is being snooped on by: %s", Name(d->player), buf); + *snooplist[sn] = '\0'; + for(n = 0; n < sn; n++) { + if(n != 0) + safe_str(", ", buf, &bp); + if(n == (sn-1) && sn > 1) + safe_str("& ", buf, &bp); + safe_str(snooplist[n], buf, &bp); + } + *bp = '\0'; + notify_format(player, "%s is being snooped on by: %s", Name(d->player), buf); } else { - if(*arg_left== '!') { - on = 0; - descn = atoi(arg_left+1); - } else { - descn = atoi(arg_left); - on = 1; - } - - d = port_desc(descn); - if (LEVEL(player) <= 28) { - notify(player, MSG_HUH); - return; - } - /* make sure teh desc exists and they're connected (no spying on 'em at the connect screen!) */ - if(!d || (d && !IsPlayer(d->player))) { - notify(player, "There is no one connected on that descriptor."); - return; - } - - if(on) { - if((d->player == player)) { - notify(player, "You can't snoop yourself."); - return; - } + if(*arg_left== '!') { + on = 0; + descn = atoi(arg_left+1); + } else { + descn = atoi(arg_left); + on = 1; + } - switch(set_snoop(player,d)) { - case -1: /* Too Many */ - notify(player, "Sorry, can't snoop at this time."); + d = port_desc(descn); + if (LEVEL(player) <= 28) { + notify(player, MSG_HUH); return; - case -2: /* Already Snoopin on 'em */ - notify(player, "You can only snoop one person at a time."); + } + /* make sure the desc exists and they're connected (no spying on 'em at the connect screen!) */ + if(!d || (d && !IsPlayer(d->player))) { + notify(player, "There is no one connected on that descriptor."); return; - default: - notify_format(player, T("Snoop now set on %s(%d)"), Name(d->player), descn); - } - } else { - for(on = n = 0; n < MAX_SNOOPS; n++) - if(d->snooper[n] == player) { - d->snooper[n] = -1; - on = 1; + } + + if(on) { + if((d->player == player)) { + notify(player, "You can't snoop yourself."); + return; + } + + switch(set_snoop(player,d)) { + case -1: /* Too Many */ + notify(player, "Sorry, can't snoop at this time."); + return; + case -2: /* Already Snoopin on 'em */ + notify(player, "You can only snoop one person at a time."); + return; + default: + notify_format(player, T("Snoop now set on %s(%d)"), Name(d->player), descn); } + } else { + for(on = n = 0; n < MAX_SNOOPS; n++) + if(d->snooper[n] == player) { + d->snooper[n] = -1; + on = 1; + } notify(player, on ? "Snoop deactivated." : "Snooping Error."); - } + } } } @@ -5517,19 +5513,19 @@ void feed_snoop(DESC *d, const char *s, char dir) { continue; if(dir == 1) /* player sees */ notify_format((dbref) d->snooper[n], T("%s%s<-%s %s"), - object_header(d->snooper[n],d->player), - ANSI_BLUE, ANSI_NORMAL, snstr); + object_header(d->snooper[n],d->player), + ANSI_BLUE, ANSI_NORMAL, snstr); else /* player types */ notify_format((dbref) d->snooper[n], T("%s%s->%s %s%s"), - object_header(d->snooper[n],d->player), - ANSI_BLUE, ANSI_RED, snstr, ANSI_NORMAL); + object_header(d->snooper[n],d->player), + ANSI_BLUE, ANSI_RED, snstr, ANSI_NORMAL); } } char is_snooped(DESC *d) { int n; - for(n = 0; n < MAX_SNOOPS; n++) + for(n = 0; n < MAX_SNOOPS; n++) if(IsPlayer(d->snooper[n])) return 1; return 0; @@ -5566,7 +5562,7 @@ COMMAND(cmd_su) { /* Stage 1. Make sure arg_left exists */ if(arg_left && *arg_left) { - if(!strcasecmp(cmd->name, "@SD")) { + if(!strcasecmp(cmd->name, "@SD")) { target = match_result(player, arg_left, TYPE_DIVISION, MAT_EVERYTHING); if(!GoodObject(target) || Typeof(target) != TYPE_DIVISION) { notify(player, "No such division."); @@ -5584,8 +5580,8 @@ COMMAND(cmd_su) { return; } /* get least idle desc */ - DESC_ITER_CONN(d) - if ((d->player == player) && (!match || (d->last_time > match->last_time))) + DESC_ITER_CONN(d) + if ((d->player == player) && (!match || (d->last_time > match->last_time))) match = d; /* We're only entering using a password at this moment */ #ifdef COMPILE_CONSOLE @@ -5609,8 +5605,8 @@ COMMAND(cmd_su) { } do_log(LT_WIZ, player, target, "** @SU ATTEMPT **"); /* get least idle desc */ - DESC_ITER_CONN(d) - if ((d->player == player) && (!match || (d->last_time > match->last_time))) + DESC_ITER_CONN(d) + if ((d->player == player) && (!match || (d->last_time > match->last_time))) match = d; /* Step 2. Find if we can get in without a pass, if * we need a pass. Throw them into password_handler() internal diff --git a/src/notify.c b/src/notify.c index 6296f65..80df86d 100644 --- a/src/notify.c +++ b/src/notify.c @@ -192,7 +192,6 @@ struct notify_strings { int made; /**< True if message has been rendered. */ }; -static void fillstate(int state[], const unsigned char **f); static void ansi_change_state(char *t, char **o, int color, int *state, int *newstate); static enum na_type notify_type(DESC *d); diff --git a/src/player.c b/src/player.c index 2813540..3e5021f 100644 --- a/src/player.c +++ b/src/player.c @@ -476,12 +476,12 @@ make_player(const char *name, const char *password, const char *host, void do_password(dbref player, dbref cause, const char *old, const char *newobj) { - if (!global_eval_context.process_command_port) { - char old_eval[BUFFER_LEN]; - char new_eval[BUFFER_LEN]; - char const *sp; - char *bp; + char old_eval[BUFFER_LEN]; + char new_eval[BUFFER_LEN]; + char const *sp; + char *bp; + if (!global_eval_context.process_command_port) { sp = old; bp = old_eval; process_expression(old_eval, &bp, &sp, player, player, cause, diff --git a/src/wiz.c b/src/wiz.c index c2574f3..442021d 100644 --- a/src/wiz.c +++ b/src/wiz.c @@ -780,12 +780,11 @@ do_newpassword(dbref player, dbref cause, const char *name, const char *password) { dbref victim; + char pass_eval[BUFFER_LEN]; + char const *sp; + char *bp; if (!global_eval_context.process_command_port) { - char pass_eval[BUFFER_LEN]; - char const *sp; - char *bp; - sp = password; bp = pass_eval; process_expression(pass_eval, &bp, &sp, player, player, cause,