hirc

IRC client
Log | Files | Refs

commit 56dcbf0cd45afb223365d8c27048cb62b45d19f8
parent 922362de863e7b93a87fdbcfe2d03bb10ea7597c
Author: hhvn <dev@hhvn.uk>
Date:   Mon,  2 May 2022 13:42:52 +0100

Please gcc -Wall

Diffstat:
Msrc/commands.c | 2+-
Msrc/complete.c | 1-
Msrc/config.c | 3++-
Msrc/format.c | 10+++++-----
Msrc/handle.c | 1-
Msrc/hist.c | 5+++--
Msrc/main.c | 2--
Msrc/mem.c | 2--
Msrc/nick.c | 8++++----
Msrc/serv.c | 7+++----
Msrc/str.c | 2+-
Msrc/ui.c | 15+++------------
12 files changed, 22 insertions(+), 36 deletions(-)

diff --git a/src/commands.c b/src/commands.c @@ -722,7 +722,7 @@ command_toggle) { ui_error("no such configuration variable", NULL); return; } - if (!conf->valtype == Val_bool) { + if (conf->valtype != Val_bool) { ui_error("%s is not a boolean variable", str); return; } diff --git a/src/complete.c b/src/complete.c @@ -147,7 +147,6 @@ void complete(wchar_t *str, size_t size, unsigned *counter) { wchar_t *wstem = NULL; char *stem = NULL; - static int pctok, prcnt; wchar_t **_toks; wchar_t **toks; wchar_t *cmd; diff --git a/src/config.c b/src/config.c @@ -182,7 +182,7 @@ config_setr(struct Config *conf, long a, long b) { void config_set(char *name, char *val) { char *str = val ? estrdup(val) : NULL; - char *tok[3], *save, *p; + char *tok[3], *save; struct Config *conf; int i, found; @@ -345,6 +345,7 @@ config_window_location(struct Config *conf, long num) { conf->num = windows[win].location = num; conf->isdef = 0; ui_redraw(); + return 0; } static int diff --git a/src/format.c b/src/format.c @@ -350,7 +350,7 @@ outcont: /* Save ret for use in snprintf */ save = estrdup(ret); rc = snprintf(ret, rs, "%1$*3$s%2$s", save, config_gets("divider.string"), - config_getl("divider.margin") + (strlen(ret) - ui_strlenc(window, ret, NULL))); + (int)(config_getl("divider.margin") + (strlen(ret) - ui_strlenc(window, ret, NULL)))); pfree(&save); format = strchr(format, '}') + 1; continue; @@ -372,7 +372,7 @@ outcont: save = ret; ret = NULL; format_(NULL, content, hist, 1); - rc += snprintf(&save[rc], rs - rc, "%1$*2$s", ret, pn); + rc += snprintf(&save[rc], rs - rc, "%1$*2$s", ret, (int)pn); pfree(&ret); ret = save; format = strchr(format+2+CONSTLEN("pad:"), ',') + strlen(content) + 2; @@ -461,7 +461,7 @@ outcont: if (escape && *format == 'n') { ret[rc++] = '\n'; rc += snprintf(&ret[rc], rs - rc, "%1$*3$s%2$s", "", config_gets("divider.string"), - ui_strlenc(NULL, ts, NULL) + config_getl("divider.margin")); + (int)(ui_strlenc(NULL, ts, NULL) + config_getl("divider.margin"))); escape = 0; format++; continue; @@ -487,7 +487,7 @@ outcont: ret[rc] = '\0'; if (!recursive && divider && !rhs) { save = estrdup(ret); - rc = snprintf(ret, rs, "%1$*4$s%2$s%3$s", "", config_gets("divider.string"), save, config_getl("divider.margin")); + rc = snprintf(ret, rs, "%1$*4$s%2$s%3$s", "", config_gets("divider.string"), save, (int)config_getl("divider.margin")); pfree(&save); } @@ -534,7 +534,7 @@ outcont: if (divider) { p += snprintf(p, rs - ((size_t)(p - ret)), "%1$*4$s %2$s%3$s", "", config_gets("divider.string"), save, - config_getl("divider.margin") + ui_strlenc(NULL, ts, NULL)); + (int)config_getl("divider.margin") + ui_strlenc(NULL, ts, NULL)); } else { p += snprintf(p, rs - ((size_t)(p - ret)), "%1$*3$s %2$s", "", save, ui_strlenc(NULL, ts, NULL)); } diff --git a/src/handle.c b/src/handle.c @@ -303,7 +303,6 @@ handle_RPL_ISUPPORT) { HANDLER( handle_RPL_AWAY) { struct Channel *priv; - struct HistInfo *history; if ((priv = chan_get(&server->privs, *(msg->params+2), -1)) != NULL) { hist_addp(priv->history, msg, Activity_status, HIST_DFL); diff --git a/src/hist.c b/src/hist.c @@ -245,7 +245,7 @@ hist_purgeopt(struct HistInfo *histinfo, enum HistOpt options) { struct History * hist_format(struct HistInfo *histinfo, enum Activity activity, enum HistOpt options, char *format, ...) { - char msg[1024], **params; + char msg[1024]; va_list ap; va_start(ap, format); @@ -263,7 +263,7 @@ hist_log(struct History *hist) { char filename[2048]; FILE *f; char *logdir; - int ret, serrno; + int ret; struct stat st; char *nick, *ident, *host, *raw; @@ -325,6 +325,7 @@ hist_log(struct History *hist) { } fclose(f); + return 0; } struct History * diff --git a/src/main.c b/src/main.c @@ -53,10 +53,8 @@ int main(int argc, char *argv[]) { struct Selected oldselected; struct Server *sp; - FILE *file; int i, j, refreshed, inputrefreshed; long pinginact, reconnectinterval, maxreconnectinterval; - char *tmp; if (argc > 2) { fprintf(stderr, "usage: %s [configfile]\n", basename(argv[0])); diff --git a/src/mem.c b/src/mem.c @@ -31,10 +31,8 @@ * than producing potential heisenbugs. */ void pfree_(void **ptr) { - size_t i; if (!ptr || !*ptr) return; - free(*ptr); *ptr = NULL; } diff --git a/src/nick.c b/src/nick.c @@ -31,7 +31,7 @@ short nick_getcolour(struct Nick *nick) { - unsigned short ret, sum; + unsigned short sum; int i; long range[2]; char *s = nick->nick; @@ -166,7 +166,7 @@ nick_isself_server(struct Nick *nick, struct Server *server) { struct Nick * nick_add(struct Nick **head, char *prefix, char priv, struct Server *server) { - struct Nick *nick, *p; + struct Nick *nick; if (!prefix || !priv) return NULL; @@ -262,9 +262,9 @@ enum { void nick_sort(struct Nick **head, struct Server *server) { - char *supportedprivs, *s[2]; + char *s[2]; struct Nick *p, *next; - int i, swapped; + int swapped; int map[CHAR_MAX] = { ['\0'] = S_null, [' '] = S_space, /* default p->priv */ diff --git a/src/serv.c b/src/serv.c @@ -219,7 +219,7 @@ serv_connect(struct Server *server) { struct Support *s, *prev; struct addrinfo hints; struct addrinfo *ai = NULL; - int fd, ret, serrno; + int fd, ret; if (!server) return; @@ -405,7 +405,7 @@ serv_read(struct Server *sp) { sp->inputbuf[SERVER_INPUT_SIZE - 1] = '\0'; line = sp->inputbuf; - while (end = strstr(line, "\r\n")) { + while ((end = strstr(line, "\r\n"))) { *end = '\0'; handle(sp, line); line = end + 2; @@ -419,7 +419,7 @@ int serv_write(struct Server *server, char *format, ...) { char msg[512]; va_list ap; - int ret, serrno; + int ret; if (!server || server->status == ConnStatus_notconnected) { ui_error("Not connected to server '%s'", server ? server->name : ""); @@ -492,7 +492,6 @@ serv_poll(struct Server **head, int timeout) { void serv_disconnect(struct Server *server, int reconnect, char *msg) { struct Channel *chan; - struct Support *s, *prev = NULL; int ret; if (msg) diff --git a/src/str.c b/src/str.c @@ -144,7 +144,7 @@ strrdate(time_t secs) { rc += snprintf(&ret[rc], sizeof(ret) - rc, "%d%s%s, ", mins, shrt ? "m" : " min", !shrt && mins != 1 ? "s" : ""); if (secs || verb) - rc += snprintf(&ret[rc], sizeof(ret) - rc, "%d%s%s, ", secs, + rc += snprintf(&ret[rc], sizeof(ret) - rc, "%d%s%s, ", (int)secs, shrt ? "s" : " sec", !shrt && secs != 1 ? "s" : ""); if (rc >= 2) ret[rc - 2] = '\0'; diff --git a/src/ui.c b/src/ui.c @@ -166,7 +166,6 @@ ui_read(void) { static wchar_t *backup = NULL; struct Keybind *kp; char *str; - wchar_t *wcs; wint_t key; int ret; int savecounter; @@ -273,7 +272,7 @@ ui_read(void) { } break; default: - if (iswprint(key) || iscntrl(key) && input.counter + 1 != sizeof(input.string)) { + if (iswprint(key) || (iscntrl(key) && input.counter + 1 != sizeof(input.string))) { memmove(input.string + input.counter + 1, input.string + input.counter, (wcslen(input.string + input.counter) + 1) * sizeof(wchar_t)); @@ -392,9 +391,7 @@ ui_redraw(void) { void ui_draw_input(void) { - char utfbuf[5]; wchar_t *p; - int utfc; int offset; int x; @@ -604,7 +601,6 @@ ui_draw_buflist(void) { int ui_wprintc(struct Window *window, int lines, char *format, ...) { - char utfbuf[5]; char *str; wchar_t *wcs, *s; va_list ap; @@ -612,10 +608,9 @@ ui_wprintc(struct Window *window, int lines, char *format, ...) { attr_t curattr; short temp; /* used only for wattr_get, because ncurses is dumb */ - int cc, lc, elc, utfc; + int cc, lc, elc; char colourbuf[2][3]; int colours[2]; - int colour = 0; int bold = 0; int underline = 0; int reverse = 0; @@ -682,7 +677,6 @@ ui_wprintc(struct Window *window, int lines, char *format, ...) { wattr_get(window->window, &curattr, &temp, NULL); wattr_set(window->window, curattr, ui_get_pair(colours[0], colours[1]), NULL); - colour = 1; break; case 9: /* ^I */ #ifdef A_ITALIC @@ -694,7 +688,6 @@ ui_wprintc(struct Window *window, int lines, char *format, ...) { #endif /* A_ITALIC */ break; case 15: /* ^O */ - colour = 0; bold = 0; underline = 0; reverse = 0; @@ -735,7 +728,6 @@ ui_wprintc(struct Window *window, int lines, char *format, ...) { end: pfree(&wcs); - colour = 0; bold = 0; underline =0; reverse = 0; @@ -777,7 +769,7 @@ ui_strlenc(struct Window *window, char *s, int *lines) { if ((*s & 0xC0) != 0x80) cc++; ret++; - if (window && cc == window->w || *s == '\n') { + if ((window && cc == window->w) || *s == '\n') { lc++; cc = 0; } @@ -793,7 +785,6 @@ ui_strlenc(struct Window *window, char *s, int *lines) { void ui_draw_main(void) { struct History *p, *hp; - char *format; int y, lines; int i;