From: Ari Johnson Date: Mon, 7 Oct 2024 16:51:13 +0000 (-0400) Subject: Numerous compiler warnings X-Git-Url: https://git.theari.com/?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=cobramush.git Numerous compiler warnings --- diff --git a/game/txt/changes/0.73p4 b/game/txt/changes/0.73p4 index fc7362d..efc516b 100644 --- a/game/txt/changes/0.73p4 +++ b/game/txt/changes/0.73p4 @@ -15,3 +15,4 @@ CobraMUSH Version 0.73p4 * Compiler warning when RPMODE_SYS enabled [AEJ] * Recently introduced bug in channel connect/disconnect broadcasts [AEJ] * @prog could not use attribute trees from parent objects [AEJ] + * Numerous compiler warnings [AEJ] diff --git a/src/atr_tab.c b/src/atr_tab.c index dbc9076..b95c280 100644 --- a/src/atr_tab.c +++ b/src/atr_tab.c @@ -536,6 +536,7 @@ list_attribs(void) int nptrs = 0, i; ap = (ATTR *) ptab_firstentry(&ptab_attrib); + ptrs[0] = ""; while (ap) { ptrs[nptrs++] = AL_NAME(ap); ap = (ATTR *) ptab_nextentry(&ptab_attrib); diff --git a/src/bsd.c b/src/bsd.c index 93bbe26..735b1f2 100644 --- a/src/bsd.c +++ b/src/bsd.c @@ -3257,6 +3257,7 @@ do_page_port(dbref player, const char *pc, const char *message) switch (*message) { case SEMI_POSE_TOKEN: gap = ""; + /* fall through */ case POSE_TOKEN: key = 1; break; diff --git a/src/command.c b/src/command.c index cca892d..e7d911a 100644 --- a/src/command.c +++ b/src/command.c @@ -942,6 +942,7 @@ command_parse(dbref player, dbref cause, dbref realcause, char *string, int from break; } #endif /* CHAT_SYSTEM */ + /* fall through */ case NUMBER_TOKEN: /* parse_force() destructively modifies the command to replace * the first space with a '=' if the command is an actual @@ -1692,6 +1693,7 @@ list_commands(void) char *bp; int nptrs = 0, i; command = (COMMAND_INFO *) ptab_firstentry(&ptab_command); + ptrs[0] = ""; while (command) { ptrs[nptrs] = command->name; nptrs++; diff --git a/src/db.c b/src/db.c index 7b38e53..6bfd155 100644 --- a/src/db.c +++ b/src/db.c @@ -1181,6 +1181,7 @@ putbytes(FILE * f, unsigned char *lbytes, int byte_limit) { case '\"': case '\\': OUTPUT(putc('\\', f)); + /* fall through */ default: OUTPUT(putc(lbytes[i], f)); } diff --git a/src/destroy.c b/src/destroy.c index 0c23386..047ac9f 100644 --- a/src/destroy.c +++ b/src/destroy.c @@ -380,6 +380,7 @@ do_destroy(dbref player, char *name, int confirm) break; case TYPE_DIVISION: do_log(LT_WIZ, player, thing, "Division object scheduled for destruction."); + /* fall through */ case TYPE_THING: if (!Owns(player, thing)) { notify_format(player, T("%s's %s is scheduled to be destroyed."), diff --git a/src/division.c b/src/division.c index 044e425..e4e1517 100644 --- a/src/division.c +++ b/src/division.c @@ -657,8 +657,10 @@ powergroup_db_set(dbref executor, dbref player, const char *powergroup, switch (ycode) { case YES: GIVE_DPBIT(player, power->flag_yes); + /* fall through */ case YESLTE: GIVE_DPBIT(player, power->flag_lte); + /* fall through */ case YESLT: GIVE_DPBIT(player, power->flag_lt); break; @@ -1045,8 +1047,10 @@ rem_pg_from_player(dbref player, POWERGROUP * powergroup) switch (ycode) { case YES: GIVE_DPBIT(player, power->flag_yes); + /* fall through */ case YESLTE: GIVE_DPBIT(player, power->flag_lte); + /* fall through */ case YESLT: GIVE_DPBIT(player, power->flag_lt); break; @@ -1607,7 +1611,7 @@ create_div(dbref owner, const char *name) } Parent(obj) = SDIV(owner).object; current_state.divisions++; - strncpy(buf, object_header(owner, obj), BUFFER_LEN); + strncpy(buf, object_header(owner, obj), BUFFER_LEN - 1); notify_format(owner, T("Division created: %s Parent division: %s"), buf, object_header(owner, SDIV(obj).object)); return obj; @@ -1798,8 +1802,10 @@ division_empower(dbref exec, dbref target, const char *arg2) switch (flag) { case YES: GIVE_DPBIT(target, power->flag_yes); + /* fall through */ case YESLTE: GIVE_DPBIT(target, power->flag_lte); + /* fall through */ case YESLT: GIVE_DPBIT(target, power->flag_lt); break; @@ -2022,6 +2028,7 @@ adjust_powers(dbref obj, dbref to) switch (plev) { case YESLTE: GIVE_DPBIT(obj, power->flag_lte); + /* fall through */ case YESLT: GIVE_DPBIT(obj, power->flag_lt); break; @@ -2232,8 +2239,10 @@ string_to_dpbits(const char *powers) switch (plevel) { case 3: DPBIT_SET(powc, power->flag_yes); + /* fall through */ case 2: DPBIT_SET(powc, power->flag_lte); + /* fall through */ case 1: DPBIT_SET(powc, power->flag_lt); break; diff --git a/src/extchat.c b/src/extchat.c index 4a6e837..41b8df1 100644 --- a/src/extchat.c +++ b/src/extchat.c @@ -1578,7 +1578,9 @@ do_chat_by_name(dbref player, const char *name, const char *msg, int source) list_partial_matches(player, name, PMATCH_ON); return 1; } + /* fall through */ case CMATCH_EXACT: + /* fall through */ case CMATCH_PARTIAL: do_chat(player, c, msg); return 1; diff --git a/src/funlist.c b/src/funlist.c index 6101f46..c71be8a 100644 --- a/src/funlist.c +++ b/src/funlist.c @@ -441,9 +441,9 @@ FUNCTION(fun_fold) /* If we have three or more arguments, the third one is the base case */ if (nargs >= 3) { - strncpy(base, args[2], BUFFER_LEN); + strncpy(base, args[2], BUFFER_LEN - 1); } else { - strncpy(base, split_token(&cp, sep), BUFFER_LEN); + strncpy(base, split_token(&cp, sep), BUFFER_LEN - 1); } wenv[0] = base; wenv[1] = split_token(&cp, sep); diff --git a/src/funmath.c b/src/funmath.c index 574180a..251d1cd 100644 --- a/src/funmath.c +++ b/src/funmath.c @@ -1925,7 +1925,7 @@ MATH_FUNC(math_div) } temp = parse_integer(ptr[n]); - if (EQ(temp, 0)) { + if (EQ(temp, 0.0)) { safe_str(T("#-1 DIVISION BY ZERO"), buff, bp); return; } diff --git a/src/funstr.c b/src/funstr.c index 00af11b..e34db22 100644 --- a/src/funstr.c +++ b/src/funstr.c @@ -211,6 +211,7 @@ FUNCTION(fun_poss) safe_str(T(e_match), buff, bp); return; } + /* fall through */ safe_str(poss[get_gender(thing)], buff, bp); } @@ -2211,6 +2212,7 @@ FUNCTION(fun_speak) case '"': if (CHAT_STRIP_QUOTE) string++; + /* fall through */ default: say = 1; break; diff --git a/src/game.c b/src/game.c index 55c06cd..ba30f53 100644 --- a/src/game.c +++ b/src/game.c @@ -1925,7 +1925,7 @@ do_dolist(dbref player, char *list, char *command, dbref cause, char outbuf[BUFFER_LEN]; char *bp; int place; - char placestr[10]; + char placestr[12]; int j; char delim = ' '; if (!command || !*command) { @@ -1966,7 +1966,7 @@ do_dolist(dbref player, char *list, char *command, dbref cause, while (objstring) { curr = split_token(&objstring, delim); place++; - sprintf(placestr, "%d", place); + snprintf(placestr, 11, "%d", place); if (!(flags & DOL_MAP)) { /* @dolist, queue command */ bind_and_queue(player, cause, command, curr, placestr); diff --git a/src/help.c b/src/help.c index b7788be..d0bafa9 100644 --- a/src/help.c +++ b/src/help.c @@ -102,7 +102,7 @@ add_help_file(const char *command_name, const char *filename, int admin) char newfilename[256] = "\0"; /* Must use a buffer for MacOS file path conversion */ - strncpy(newfilename, filename, 256); + strncpy(newfilename, filename, 256 - 1); if (help_init == 0) init_help_files(); diff --git a/src/ident.c b/src/ident.c index 21be8ba..ec854de 100644 --- a/src/ident.c +++ b/src/ident.c @@ -333,7 +333,7 @@ id_query(ident_t * id, struct sockaddr *laddr, socklen_t llen, sprintf(buf, "%s , ", port); getnameinfo(faddr, flen, NULL, 0, port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV); - strncat(buf, port, sizeof(buf)); + strncat(buf, port, sizeof(buf) - 1); strncat(buf, "\r\n", sizeof(buf) - 1); if (timeout) { diff --git a/src/log.c b/src/log.c index 06afea1..6aaeb9e 100644 --- a/src/log.c +++ b/src/log.c @@ -96,7 +96,7 @@ start_log(FILE ** fp, const char *filename) } else { /* Must use a buffer for MacOS file path conversion */ - strncpy(newfilename, filename, 256); + strncpy(newfilename, filename, 255); *fp = fopen(newfilename, "a"); if (*fp == NULL) { diff --git a/src/notify.c b/src/notify.c index 387dab0..2882966 100644 --- a/src/notify.c +++ b/src/notify.c @@ -370,7 +370,9 @@ notify_makestring(const char *message, struct notify_strings messages[], return messages[type].message; case NA_NPASCII: strip = 1; + /* fall through */ case NA_PASCII: + /* fall through */ case NA_TPASCII: /* PLAYER Ascii. Different output. \n is \r\n */ if (type == NA_NPASCII) diff --git a/src/parse.c b/src/parse.c index df5be49..eea4908 100644 --- a/src/parse.c +++ b/src/parse.c @@ -685,7 +685,7 @@ process_expression(char *buff, char **bp, char const **str, if (*str) (*str)++; if (is_strict_integer(subspace)) - p = abs(parse_integer(subspace)); + p = labs(parse_integer(subspace)); else named_substring = subspace; } else { diff --git a/src/pcre.c b/src/pcre.c index 5c24c21..3a250e0 100644 --- a/src/pcre.c +++ b/src/pcre.c @@ -1687,9 +1687,13 @@ the pcre module can use all the optimization it can get). */ case OP_EXACT: /* Fall through */ tcode += 2; + /* fall through */ case OP_CHAR: + /* fall through */ case OP_CHARNC: + /* fall through */ case OP_PLUS: + /* fall through */ case OP_MINPLUS: set_bit(start_bits, tcode[1], caseless, cd); try_next = FALSE; @@ -2385,6 +2389,7 @@ Otherwise further processing may be required. */ /* \0 always starts an octal number, but we may drop through to here with a larger first octal digit. */ + /* fall through */ case '0': c -= '0'; while (i++ < 2 && ptr[1] >= '0' && ptr[1] <= '7') @@ -5376,9 +5381,13 @@ find_firstassertedchar(const uschar * code, int *options, BOOL inassert) case OP_EXACT: /* Fall through */ scode += 2; + /* fall through */ case OP_CHAR: + /* fall through */ case OP_CHARNC: + /* fall through */ case OP_PLUS: + /* fall through */ case OP_MINPLUS: if (!inassert) return -1; @@ -5912,15 +5921,25 @@ pattern. We can't be so clever for #-comments. */ case 'R': ptr++; + /* fall through */ case '0': + /* fall through */ case '1': + /* fall through */ case '2': + /* fall through */ case '3': + /* fall through */ case '4': + /* fall through */ case '5': + /* fall through */ case '6': + /* fall through */ case '7': + /* fall through */ case '8': + /* fall through */ case '9': ptr += 2; if (c != 'R') @@ -8647,6 +8666,7 @@ this stack. */ } /* For DOTALL case, fall through and treat as \C */ + /* fall through */ case OP_ANYBYTE: c = max - min; if (c > md->end_subject - eptr) diff --git a/src/speech.c b/src/speech.c index 713f950..8965b19 100644 --- a/src/speech.c +++ b/src/speech.c @@ -323,6 +323,7 @@ do_whisper(dbref player, const char *arg1, const char *arg2, int noisy) switch (*arg2) { case SEMI_POSE_TOKEN: gap = ""; + /* fall through */ case POSE_TOKEN: key = 1; arg2++; @@ -581,6 +582,7 @@ do_wall(dbref player, const char *message, enum wall_type target, int emit) break; case SEMI_POSE_TOKEN: gap = ""; + /* fall through */ case POSE_TOKEN: pose = 1; message++; @@ -825,6 +827,7 @@ do_page(dbref player, const char *arg1, const char *arg2, dbref cause, switch (*message) { case SEMI_POSE_TOKEN: gap = ""; + /* fall through */ case POSE_TOKEN: key = 1; message++; diff --git a/src/sql.c b/src/sql.c index 7ee1a61..4e989db 100644 --- a/src/sql.c +++ b/src/sql.c @@ -229,7 +229,7 @@ FUNCTION(fun_mapsql) if (do_fieldnames) { fields = mysql_fetch_fields(qres); - strncpy(numbuff, unparse_integer(0), 20); + strncpy(numbuff, unparse_integer(0), 19); wenv[0] = numbuff; for (i = 0; i < numfields && i < 9; i++) { wenv[i + 1] = fields[i].name; @@ -245,7 +245,7 @@ FUNCTION(fun_mapsql) if (rownum++ > 0 || do_fieldnames) { safe_str(osep, buff, bp); } - strncpy(numbuff, unparse_integer(rownum), 20); + strncpy(numbuff, unparse_integer(rownum), 19); wenv[0] = numbuff; for (i = 0; (i < numfields) && (i < 9); i++) { wenv[i + 1] = row_p[i]; diff --git a/src/strutil.c b/src/strutil.c index c177da5..758fb3c 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -1357,18 +1357,25 @@ format_long(long val, char *buff, char **bp, int maxlen, int base) case 0: while (current < stack + sizeof(stack)) { *((*bp)++) = *(current++); + /* fall through */ case 7: *((*bp)++) = *(current++); + /* fall through */ case 6: *((*bp)++) = *(current++); + /* fall through */ case 5: *((*bp)++) = *(current++); + /* fall through */ case 4: *((*bp)++) = *(current++); + /* fall through */ case 3: *((*bp)++) = *(current++); + /* fall through */ case 2: *((*bp)++) = *(current++); + /* fall through */ case 1: *((*bp)++) = *(current++); } diff --git a/src/utils.c b/src/utils.c index f91f5dd..d3359e7 100644 --- a/src/utils.c +++ b/src/utils.c @@ -221,7 +221,7 @@ fetch_ufun_attrib(char *attrname, dbref executor, ufun_attrib * ufun, pe_flags |= PE_DEBUG; /* Populate the ufun object */ - strncpy(ufun->contents, atr_value(attrib), BUFFER_LEN); + strncpy(ufun->contents, atr_value(attrib), BUFFER_LEN - 1); ufun->thing = thing; ufun->pe_flags = pe_flags; diff --git a/src/wiz.c b/src/wiz.c index 5ea21fc..c2574f3 100644 --- a/src/wiz.c +++ b/src/wiz.c @@ -1074,6 +1074,7 @@ do_debug_examine(dbref player, const char *name) mp = desc_mail(thing); notify_format(player, T("First mail sender: %d"), mp ? mp->from : NOTHING); #endif + /* fall through */ case TYPE_THING: notify_format(player, "Location: %d", Location(thing)); notify_format(player, "Home: %d", Home(thing));