jcs
/subtext
/amendments
/373
db: Remove unused variables, fix format strings, fix shadowing
jcs made amendment 373 over 2 years ago
--- db.c Mon Mar 6 16:35:28 2023
+++ db.c Tue Mar 7 23:11:38 2023
@@ -328,7 +328,7 @@ db_close(struct db *tdb)
short
db_migrate(struct db *tdb, short is_new, Str255 fullpath)
{
- struct user *user;
+ struct user *suser;
struct db *olddb;
char ver;
@@ -354,18 +354,19 @@ db_migrate(struct db *tdb, short is_new, Str255 fullpa
db_config_save(tdb);
/* create a default sysop user */
- user = xmalloczero(sizeof(struct user));
- if (user == NULL)
+ suser = xmalloczero(sizeof(struct user));
+ if (suser == NULL)
panic("Can't allocate new user");
- strncpy(user->username, "sysop", sizeof(user->username));
- user->created_at = Time;
- user->is_enabled = DB_TRUE;
- user_set_password(user, "p4ssw0rd");
- user->is_sysop = DB_TRUE;
+ strncpy(suser->username, "sysop", sizeof(suser->username));
+ suser->created_at = Time;
+ suser->is_enabled = DB_TRUE;
+ user_set_password(suser, "p4ssw0rd");
+ suser->is_sysop = DB_TRUE;
/* user_save assumes db is already set */
olddb = db;
db = tdb;
- user_save(user);
+ user_save(suser);
+ xfree(&suser);
user_cache_usernames();
db = olddb;
} else {
@@ -605,11 +606,11 @@ db_migrate(struct db *tdb, short is_new, Str255 fullpa
/* 13->14, move mail to separate db, add fidonet fields */
Str255 newfullpath;
struct bile *mail_bile;
- size_t nids, n, size, id;
+ size_t nids, n, size;
unsigned long *ids;
char *data;
- memcpy(newfullpath, fullpath, sizeof(newfullpath));
+ memcpy(&newfullpath, fullpath, sizeof(newfullpath));
PtoCstr(newfullpath);
strlcat((char *)&newfullpath, "-mail", sizeof(newfullpath));
CtoPstr(newfullpath);
@@ -652,7 +653,6 @@ db_migrate(struct db *tdb, short is_new, Str255 fullpa
case 14: {
/* 14->15, boards get a fido field */
struct bile_object *o;
- struct board *board;
size_t nids, grow, size, n;
unsigned long *ids;
@@ -781,7 +781,7 @@ db_cache_boards(struct db *tdb)
for (n = 0; n < tdb->nboards; n++) {
snprintf((char *)board_filename, sizeof(board_filename),
- "%s:%ld.%s", db_filename, tdb->boards[n].id, BOARD_FILENAME_EXT);
+ "%s:%lu.%s", db_filename, tdb->boards[n].id, BOARD_FILENAME_EXT);
CtoPstr(board_filename);
tdb->boards[n].bile = bile_open(board_filename,
tdb->bile->vrefnum);
@@ -838,7 +838,7 @@ db_board_create(struct db *tdb, struct board *board, b
panic("getpath failed on %s", PtoCstr(tdb->bile->filename));
PtoCstr(db_filename);
- snprintf((char *)&board_filename, sizeof(board_filename), "%s:%ld.%s",
+ snprintf((char *)&board_filename, sizeof(board_filename), "%s:%lu.%s",
db_filename, board->id, BOARD_FILENAME_EXT);
CtoPstr(board_filename);
@@ -919,7 +919,7 @@ db_cache_folders(struct db *tdb)
for (n = 0; n < tdb->nfolders; n++) {
snprintf((char *)folder_filename, sizeof(folder_filename),
- "%s:%ld.%s", db_filename, tdb->folders[n].id,
+ "%s:%lu.%s", db_filename, tdb->folders[n].id,
FOLDER_FILENAME_EXT);
CtoPstr(folder_filename);
tdb->folders[n].bile = bile_open(folder_filename,
@@ -989,7 +989,7 @@ db_folder_create(struct db *tdb, struct folder *folder
PtoCstr(db_filename);
snprintf((char *)&folder_filename, sizeof(folder_filename),
- "%s:%ld.%s", db_filename, folder->id, FOLDER_FILENAME_EXT);
+ "%s:%lu.%s", db_filename, folder->id, FOLDER_FILENAME_EXT);
CtoPstr(folder_filename);
if (delete_first)