jcs
/subtext
/amendments
/101
*: Lots of little cleanup
Remove unused variables and fix some returns
Found by compiling with Clang
jcs made amendment 101 over 2 years ago
--- AddressXlation.h Fri Sep 18 08:57:06 2020
+++ AddressXlation.h Sun May 15 22:02:59 2022
@@ -14,7 +14,7 @@
#define NUM_ALT_ADDRS 4
-typedef struct hostInfo {
+struct hostInfo {
int _pad; /* XXX: i don't know why this is needed, but without it,
* StrToAddrProcPtr() returns everything shifted 2 bytes */
int rtnCode;
@@ -22,14 +22,14 @@ typedef struct hostInfo {
unsigned long addr[NUM_ALT_ADDRS];
};
-typedef enum AddrClasses {
+enum AddrClasses {
A = 1,
NS,
CNAME = 5,
lastClass = 65535
};
-typedef struct cacheEntryRecord {
+struct cacheEntryRecord {
char *cname;
unsigned short type;
enum AddrClasses class;
--- ansi.h Thu Apr 28 13:22:14 2022
+++ ansi.h Sun May 15 22:04:03 2022
@@ -17,6 +17,8 @@
#ifndef __ANSI_H__
#define __ANSI_H__
+#include "session.h"
+
#define ESC 0x1b
enum {
--- logger.c Tue Apr 26 15:32:14 2022
+++ logger.c Sun May 15 22:05:44 2022
@@ -81,10 +81,6 @@ void
logger_layout(struct logger *logger, bool init, Rect *init_bounds)
{
Rect bounds, inset_bounds, win_bounds;
- Rect control_bounds = { 0 };
- Rect data_bounds = { 0, 0, 0, 1 }; /* tlbr */
- Point cell_size = { 0 };
- Cell cell = { 0, 0 };
if (init)
win_bounds = *init_bounds;
@@ -184,10 +180,9 @@ logger_mouse_down(struct focusable *focusable, EventRe
{
struct logger *logger = (struct logger *)(focusable->cookie);
Point p;
- Cell selected = { 0 }, now = { 0 }, t = { 0 };
ControlHandle control;
Rect r;
- int val, adj, page, ret;
+ int val, adj;
short part;
p = event->where;
@@ -239,7 +234,9 @@ logger_printf(struct logger *logger, const char *forma
va_start(va, format);
len = logger_vprintf(logger, format, va);
- va_end(argptr);
+ va_end(va);
+
+ return len;
}
size_t
@@ -249,10 +246,9 @@ logger_vprintf(struct logger *logger, const char *form
RgnHandle savergn;
Rect zerorect = { 0, 0, 0, 0 };
GrafPtr old_port;
- size_t len, n;
+ size_t len;
time_t now = Time;
short line_height = 0;
- bool stop_formatting = false;
if (!logger)
return 0;
@@ -308,10 +304,10 @@ te_overflow:
TEDelete(logger->messages_te);
/* scroll up, causing a repaint */
- TEPinScroll(0, INT_MAX, logger->messages_te);
+ TEPinScroll(0, SHRT_MAX, logger->messages_te);
/* then scroll back down to what it looked like before we did anything */
- TEPinScroll(0, -INT_MAX, logger->messages_te);
+ TEPinScroll(0, -SHRT_MAX, logger->messages_te);
/* resume normal drawing */
SetClip(savergn);
--- MacTCP.h Thu Feb 10 14:49:09 2022
+++ MacTCP.h Sun May 15 22:21:15 2022
@@ -747,6 +747,7 @@ struct UDPMTUPB {
};
typedef struct UDPMTUPB UDPMTUPB;
+typedef struct UDPiopb UDPiopb;
typedef void (*UDPIOCompletionProcPtr)(struct UDPiopb *iopb);
#if GENERATINGCFM
@@ -771,7 +772,6 @@ struct UDPiopb {
struct UDPMTUPB mtu;
} csParam;
};
-typedef struct UDPiopb UDPiopb;
enum {
uppGetIPIOCompletionProcInfo = kCStackBased
--- mail.c Sat May 14 22:52:48 2022
+++ mail.c Sun May 15 22:07:37 2022
@@ -346,8 +346,7 @@ mail_list(struct session *s, bool sent, unsigned long
size_t n, size;
struct private_message msg;
struct user *user;
- char *data, *input;
- short id;
+ char *data;
*nmsgs = mail_find_for_user_id(s->user->id, mail_ids);
if (*nmsgs == 0) {
@@ -509,7 +508,6 @@ size_t
mail_find_for_user_id(unsigned long user_id, unsigned long **mail_ids)
{
unsigned long msg_user_id;
- struct user_map *muser;
struct bile_object *o;
size_t nmsg, msgs_for_user, mail_ids_size, id;
short i, j;
--- session.c Sat May 14 20:06:07 2022
+++ session.c Sun May 15 22:10:09 2022
@@ -78,12 +78,10 @@ void
session_run(struct uthread *uthread, void *arg)
{
struct session *s = (struct session *)arg;
- Handle h;
char date[9];
struct tm *date_tm;
unsigned short c;
bool done = false;
- size_t len;
/* until we negotiate otherwise */
s->terminal_columns = DEFAULT_TERMINAL_COLUMNS;
@@ -311,7 +309,6 @@ session_log(struct session *session, const char *forma
{
static char session_log_tbuf[256];
va_list ap;
- size_t len;
va_start(ap, format);
vsnprintf(session_log_tbuf, sizeof(session_log_tbuf), format, ap);
@@ -405,7 +402,7 @@ session_output_template(struct session *session, const
size = session_expand_template(session, str, &output);
if (!size)
- return;
+ return 0;
size = session_output(session, output, size);
free(output);
@@ -422,7 +419,6 @@ session_wait_for_chars(struct session *session, unsign
if (timeout_ms)
expire = Ticks + (timeout_ms / ((double)1000 / (double)60));
-wait_for_char:
while (session->ibuflen < num_chars) {
session->node_funcs->input(session);
if (session->ending)
@@ -545,7 +541,7 @@ char *
session_field_input(struct session *session, unsigned short size,
unsigned short width, char *initial_input, char mask)
{
- short ilen = 0, ipos = 0, lastlen = 0;
+ short ilen = 0, ipos = 0;
char *field;
unsigned short c;
unsigned char chc;
@@ -932,7 +928,7 @@ session_expand_template(struct session *session, const
static char curvar[128], matchvar[128];
size_t tmpllen, retsize, retpos;
size_t vallen;
- short n, quote, invar = 0, varlen = 0, doif, sep;
+ short n, invar = 0, varlen = 0, doif, sep;
char *varseek, *curvarpos, *val;
bool end_expansion = false;
@@ -1180,10 +1176,8 @@ session_answer_page(struct session *s)
void
session_recents(struct session *s)
{
- struct bile_object *slog_obj;
struct session_log slog;
struct tm *date_tm;
- unsigned long idle;
size_t scount, rsize, *ids;
char sdate[12];
short printed;
@@ -1213,8 +1207,6 @@ session_recents(struct session *s)
slog.via,
slog.tspeed);
session_flush(s);
-
- free(slog_obj);
}
session_output(s, "\r\n", 2);
--- session.h Sat May 14 20:18:01 2022
+++ session.h Sun May 15 22:10:32 2022
@@ -45,6 +45,8 @@ enum session_input_state {
#define KEY_LEFT (0x0100 | 'D')
#define KEY_OTHER (0x0100 | 0xff)
+typedef struct session session;
+
struct node_funcs {
void (*setup)(struct session *session);
short (*input)(struct session *session);
--- settings.c Sun May 15 15:54:54 2022
+++ settings.c Sun May 15 22:27:29 2022
@@ -47,7 +47,6 @@ struct_editor(struct session *s, struct struct_field *
{
Handle ihandle;
struct struct_field *sf;
- size_t len;
long lval;
char co, initial[20];
char *input = NULL, *new_data;
@@ -276,7 +275,6 @@ view_editor_show(size_t id, char *title)
short width, height;
size_t vsize;
char *view = NULL;
- TEHandle te;
short padding = 10;
width = 480;
@@ -403,7 +401,7 @@ view_editor_mouse_down(struct focusable *focusable, Ev
Point p;
ControlHandle control;
Rect r;
- short val, adj, page, was_selected, part, i;
+ short val, adj, part;
p = event->where;
GlobalToLocal(&p);
@@ -475,13 +473,13 @@ view_editor_save(struct focusable *focusable, EventRec
{
struct view_editor *view_editor =
(struct view_editor *)focusable->cookie;
- size_t len, wlen;
+ size_t len;
HLock(view_editor->te);
HLock((*(view_editor->te))->hText);
len = (*(view_editor->te))->teLength;
- wlen = bile_write(db->bile, DB_TEXT_TYPE, view_editor->view_id,
+ bile_write(db->bile, DB_TEXT_TYPE, view_editor->view_id,
*(*(view_editor->te))->hText, len);
HUnlock((*(view_editor->te))->hText);
--- signup.c Mon May 9 15:49:09 2022
+++ signup.c Sun May 15 22:12:21 2022
@@ -29,11 +29,8 @@ struct user *
signup(struct session *s)
{
struct user *user = NULL;
- char junk[SHA256_DIGEST_STRING_LENGTH];
char *username = NULL, *password = NULL, *password_confirm = NULL,
*error = NULL;
- size_t len;
- short n;
session_log(s, "Signing up for an account");
--- tcp.c Mon Feb 21 11:12:31 2022
+++ tcp.c Sun May 15 22:13:11 2022
@@ -213,8 +213,6 @@ _TCPNoCopyRcv(TCPiopb *pb, StreamPtr stream, Ptr rdsPt
unsigned short rdsLength, Ptr userData, TCPIOCompletionProc ioCompletion,
Boolean async)
{
- OSErr osErr;
-
memset(pb, 0, sizeof(*pb));
pb->csCode = TCPNoCopyRcv;
@@ -384,7 +382,7 @@ _UDPMaxMTUSize(UDPiopb *pb, short *mtu)
/* convenience functions */
-static pascal void
+pascal void
StrToAddrMarkDone(struct hostInfo *hi, char *data)
{
volatile int *done = (int *)data;
--- user.c Wed Apr 20 20:23:52 2022
+++ user.c Sun May 15 22:23:17 2022
@@ -48,7 +48,7 @@ user_update_cache_map(void)
{
struct user_map *muser;
struct bile_object *o;
- size_t nuser, len, j, n;
+ size_t nuser, len;
if (db->user_map != NULL)
free(db->user_map);
@@ -119,10 +119,9 @@ user_find(unsigned long id)
struct user *
user_find_by_username(const char *username)
{
- struct user suser, *user;
+ struct user suser;
struct user_map *muser;
char lusername[DB_USERNAME_LENGTH + 1] = { 0 };
- char *data;
short n;
size_t len;
@@ -149,7 +148,6 @@ user_authenticate(struct user *user, const char *passw
{
char hash[SHA256_DIGEST_STRING_LENGTH];
char *salted;
- unsigned long tmp[8];
size_t plen, slen;
short n;
unsigned char res;
@@ -211,7 +209,7 @@ user_set_password(struct user *user, const char *passw
short
user_valid_username(char *username, char **error)
{
- char *lower = NULL, *tmp;
+ char *lower = NULL;
struct user *user;
size_t len, n;
char c;
--- util.c Wed Apr 20 15:49:59 2022
+++ util.c Sun May 15 22:16:44 2022
@@ -136,8 +136,6 @@ xmallocarray(size_t nmemb, size_t size)
void *
xreallocarray(void *optr, size_t nmemb, size_t size)
{
- void *new_ptr;
-
if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
nmemb > 0 && SIZE_MAX / nmemb < size)
panic("xreallocarray(%lu, %lu) failed", nmemb, size);
@@ -251,11 +249,9 @@ OSTypeToString(OSType type)
void
vwarn(short alert_func, const char *format, va_list ap)
{
- Rect bounds, irect;
+ Rect bounds;
short quit = 0, height, width, hit;
WindowPtr win, dialog;
- OSType itype;
- Handle ihandle;
GetPort(&win);
@@ -368,11 +364,9 @@ note(const char *format, ...)
short
ask(const char *format, ...)
{
- Rect bounds, irect;
+ Rect bounds;
short height, width, hit;
WindowPtr win, dialog;
- OSType itype;
- Handle ihandle;
va_list ap;
GetPort(&win);
@@ -824,7 +818,7 @@ FSReadLine(short frefnum, char *buf, size_t buflen)
{
char tbuf;
size_t pos, fsize, rlen = 1, total_read = 0;
- short error, found = -1, i;
+ short error;
GetFPos(frefnum, &pos);
GetEOF(frefnum, &fsize);
@@ -994,8 +988,7 @@ UpdateScrollbarForTE(ControlHandle control, TEHandle t
{
size_t vlines, telines;
TERec *ter;
- short fheight, fwidth, max, val, per_page, per_line, horiz, max_chars,
- n;
+ short fheight, fwidth, max, val, per_line, horiz, max_chars, n;
HLock(te);
ter = *te;
@@ -1205,8 +1198,7 @@ pascal bool
PasswordDialogFieldFilter(DialogPtr dlg, EventRecord *event, short *hit)
{
DialogPeek dlgp;
- WindowPtr event_win;
- short event_in, sel_start, sel_end;
+ short sel_start, sel_end;
char key;
dlgp = (DialogPeek)dlg;
--- util.h Tue Mar 29 13:17:24 2022
+++ util.h Sun May 15 22:17:06 2022
@@ -64,7 +64,7 @@ typedef struct {
void *addr;
} tCodeStub;
-typedef struct stat {
+struct stat {
short st_mode;
ssize_t st_size;
time_t st_ctime;