AmendHub

Download:

jcs

/

subtext

/

amendments

/

580

*: Minor cleanups, remove dead variables, fix some error paths


jcs made amendment 580 10 months ago
--- binkp.c Thu Nov 23 13:52:56 2023 +++ binkp.c Tue Jan 23 16:24:43 2024 @@ -125,9 +125,6 @@ binkp_atexit(void) void binkp_poll(void) { - char filename[16]; - size_t n, pkt_buf_size; - char *pkt_buf; unsigned long started = Time, elapsed; binkp_last_poll_error = false; @@ -978,8 +975,7 @@ binkp_deliver_outbox(void) DirInfo *dpb = (DirInfo *)&cipbr; CMovePBRec cmpbr = { 0 }; struct stat sb; - unsigned long started = Time, elapsed; - size_t len, data_size, fsize_left; + size_t len, fsize_left; short dir_id, error, frefnum; char *data = NULL; @@ -1147,7 +1143,7 @@ binkp_packets_in_outbox(void) CInfoPBRec cipbr = { 0 }; HFileInfo *fpb = (HFileInfo *)&cipbr; DirInfo *dpb = (DirInfo *)&cipbr; - Str255 file_name_c, path; + Str255 file_name_c; short dir_id, error; fpb->ioVRefNum = 0; @@ -1156,7 +1152,7 @@ binkp_packets_in_outbox(void) if (error) { logger_printf("[binkp] PBGetCatInfo on binkp outbox failed: %d", error); - return; + return false; } dir_id = dpb->ioDrDirID; @@ -1178,7 +1174,7 @@ binkp_scan_message(struct fidopkt_message *msg) Str255 path; char filename[32]; char *buf = NULL; - short error, frefnum; + short error, frefnum = 0; size_t size, asize; bool ret = false; --- binkp.h Thu Nov 16 13:12:46 2023 +++ binkp.h Tue Jan 23 16:25:03 2024 @@ -17,6 +17,7 @@ #ifndef __BINKP_H__ #define __BINKP_H__ +#include "fidopkt.h" #include "tcp.h" #include "uthread.h" #include "util.h" --- board.c Tue Dec 19 10:29:51 2023 +++ board.c Tue Jan 23 16:25:33 2024 @@ -1183,13 +1183,11 @@ board_post_create(struct board *board, struct board_th struct fidopkt_message fidomsg = { 0 }; struct username_cache *user; struct fidopkt_address our_address, hub_address; - struct bile_object *o; short ret; char *data; - size_t size, insert, npost_ids; + size_t size, insert; ssize_t n, j; unsigned long *post_ids, *parent_post_ids; - struct board_id_time_map *id_map; if (board->ftn_area[0]) { if (!post->id) --- folder.c Tue Sep 19 21:10:13 2023 +++ folder.c Tue Jan 23 16:26:32 2024 @@ -345,9 +345,9 @@ folder_upload(struct session *s, struct folder *folder struct stat sb; struct zmodem_session *zs; struct nomodem_session *ns; - char *upload_path = NULL, *tmp = NULL, *file_name; - size_t size, rsize, file_size; - short c, n, error; + char *upload_path = NULL, *file_name; + size_t file_size; + short error; if (!s->user) { session_printf(s, "Uploading is not available to guests.\r\n" @@ -593,11 +593,11 @@ folder_file_view(struct session *s, struct folder *fol nfolder_file_object_fields, data, size, &file, sizeof(file), true); xfree(&data); if (bret == BILE_ERR_NO_MEMORY) - return; + return ret; dopts = xmalloc(sizeof(opts)); if (dopts == NULL) - return; + return ret; memcpy(dopts, opts, sizeof(opts)); if (!(s->user && (s->user->is_sysop || s->user->id == file.uploader_user_id))) { --- folder.h Wed Apr 26 15:57:03 2023 +++ folder.h Tue Jan 23 16:26:51 2024 @@ -20,6 +20,7 @@ #include <stddef.h> #include <stdio.h> #include "db.h" +#include "session.h" #include "settings.h" #include "sha1.h" --- mail.c Thu Nov 23 13:23:26 2023 +++ mail.c Tue Jan 23 16:27:19 2024 @@ -446,7 +446,7 @@ mail_compose_start: if (msg.ftn_to[0]) { if (ftn_reply_msgid != NULL && ftn_reply_msgid[0]) strlcpy(msg.ftn_reply, ftn_reply_msgid, - sizeof(ftn_reply_msgid)); + sizeof(msg.ftn_reply)); msg.ftn_msgid.id = 0x10FF0000 | ((unsigned long)ftn_our_address.node << 24) | msg.id; --- main_menu.c Tue Nov 28 09:39:27 2023 +++ main_menu.c Tue Jan 23 16:27:48 2024 @@ -27,7 +27,8 @@ struct main_menu_option *main_menu_options = NULL; struct main_menu_option * main_menu_parse(char *opts, size_t len) { - char *line, *action, *menu_key, *all_keys, *label; + char *line = NULL, *action = NULL, *menu_key = NULL, *all_keys = NULL, + *label = NULL; size_t n, m, linelen, lastsep, linenum, ret_size; short actionid, ret_count; struct main_menu_option *ret = NULL; --- session.h Fri Nov 17 10:55:03 2023 +++ session.h Tue Jan 23 16:28:20 2024 @@ -14,6 +14,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +/* forward declarations */ +struct session; +struct session_menu_option; + #ifndef __SESSION_H__ #define __SESSION_H__ --- settings.c Mon Nov 27 22:00:57 2023 +++ settings.c Tue Jan 23 16:29:43 2024 @@ -38,14 +38,14 @@ struct_editor(struct session *s, const struct struct_f { 'q', "QqXx", "Discard changes and return to main menu" }, { '?', "?", "List menu options" }, }; - struct session_menu_option *dopts = NULL, *opt; + struct session_menu_option *dopts = NULL; const struct struct_field *sf; long lval; - char co, initial[20]; + char initial[20]; char *input = NULL, *new_data; size_t nopts; - short n, j, i, sval, on, ret; - bool any_changes, done, show_list; + short n, i, sval, on, ret; + bool any_changes = false, done, show_list; unsigned short c; new_data = xmalloc(dsize); @@ -56,7 +56,7 @@ struct_editor(struct session *s, const struct struct_f nopts = nitems(opts) + nextra_opts; dopts = xcalloc(sizeof(struct session_menu_option), nopts); if (dopts == NULL) - return; + goto done; if (extra_opts != NULL) memcpy(dopts, extra_opts, sizeof(struct session_menu_option) * nextra_opts); @@ -319,7 +319,8 @@ done: *result = new_data; return 0; } else { - xfree(&new_data); + if (new_data) + xfree(&new_data); *result = NULL; return ret; } --- sysop.c Tue Nov 28 10:07:43 2023 +++ sysop.c Tue Jan 23 16:30:33 2024 @@ -265,7 +265,7 @@ next_field: if (reinits & (1 << CONFIG_REQUIRES_IPDB_REINIT)) { if (db->ipdb) ipdb_close(&db->ipdb); - if (db->config.ipdb_path) + if (db->config.ipdb_path[0]) db->ipdb = ipdb_open(db->config.ipdb_path); } @@ -294,8 +294,8 @@ sysop_edit_boards(struct session *s) struct board *board, *new_board; struct bile *new_board_bile; size_t n, size; - short bn, ret, id, sc; - char c, *data = NULL, *name; + short bn, ret, sc; + char c, *data = NULL; bool done, show_list, show_help; show_list = true;