Merge pull request #222 from rkta/Wall

Fix all reported warnings when -Wall is enabled and enable -Wall by default. While there, move OPTS to end of CFLAGS. This allows the user to override default options.
This commit is contained in:
Tatsuya Kinoshita
2022-04-09 19:32:49 +09:00
committed by GitHub
23 changed files with 64 additions and 67 deletions
+1 -1
View File
@@ -35,7 +35,7 @@ RC_DIR = @RC_DIR@
ETC_DIR = $(sysconfdir)
CONF_DIR = $(sysconfdir)/$(PACKAGE)
CFLAGS = $(OPTS) -I. -I$(top_srcdir) @CFLAGS@ $(CPPFLAGS) $(DEFS)
CFLAGS = -Wall -I. -I$(top_srcdir) @CFLAGS@ $(CPPFLAGS) $(DEFS) $(OPTS)
WCCFLAGS = @WCCFLAGS@
CPPFLAGS = @CPPFLAGS@
DEFS = @DEFS@ -DAUXBIN_DIR=\"$(AUXBIN_DIR)\" \
+3 -5
View File
@@ -520,10 +520,8 @@ Sprintf(char *fmt, ...)
case SP_PREC:
if (IS_ALPHA(*f)) {
/* conversion char. */
double vd;
int vi;
char *vs;
void *vp;
switch (*f) {
case 'l':
@@ -545,7 +543,7 @@ Sprintf(char *fmt, ...)
case 'e':
case 'G':
case 'E':
vd = va_arg(ap, double);
va_arg(ap, double);
len += (p > 0) ? p : 15;
break;
case 'c':
@@ -558,11 +556,11 @@ Sprintf(char *fmt, ...)
len += (p > vi) ? p : vi;
break;
case 'p':
vp = va_arg(ap, void *);
va_arg(ap, void *);
len += 10;
break;
case 'n':
vp = va_arg(ap, void *);
va_arg(ap, void *);
break;
}
status = SP_NORMAL;
+2 -2
View File
@@ -239,7 +239,7 @@ writeBufferName(Buffer *buf, int n)
void
gotoLine(Buffer *buf, int n)
{
char msg[32];
char msg[36];
Line *l = buf->firstLine;
if (l == NULL)
@@ -284,7 +284,7 @@ gotoLine(Buffer *buf, int n)
void
gotoRealLine(Buffer *buf, int n)
{
char msg[32];
char msg[36];
Line *l = buf->firstLine;
if (l == NULL)
+2 -4
View File
@@ -1368,15 +1368,14 @@ cursorRight(Buffer *buf, int n)
{
int i, delta = 1, cpos, vpos2;
Line *l = buf->currentLine;
Lineprop *p;
if (buf->firstLine == NULL)
return;
if (buf->pos == l->len && !(l->next && l->next->bpos))
return;
i = buf->pos;
p = l->propBuf;
#ifdef USE_M17N
Lineprop *p = l->propBuf;
while (i + delta < l->len && p[i + delta] & PC_WCHAR2)
delta++;
#endif
@@ -1419,13 +1418,12 @@ cursorLeft(Buffer *buf, int n)
{
int i, delta = 1, cpos;
Line *l = buf->currentLine;
Lineprop *p;
if (buf->firstLine == NULL)
return;
i = buf->pos;
p = l->propBuf;
#ifdef USE_M17N
Lineprop *p = l->propBuf;
while (i - delta > 0 && p[i - delta] & PC_WCHAR2)
delta++;
#endif
+11 -7
View File
@@ -253,8 +253,10 @@ checkType(Str s, Lineprop **oprop, Linecolor **ocolor)
char *es = NULL;
#endif
int do_copy = FALSE;
#ifdef USE_M17N
int i;
int plen = 0, clen;
#endif
if (prop_size < s->length) {
prop_size = (s->length > LINELEN) ? s->length : LINELEN;
@@ -429,7 +431,6 @@ checkType(Str s, Lineprop **oprop, Linecolor **ocolor)
}
#endif
plen = get_mclen(str);
mode = get_mctype(str) | effect;
#ifdef USE_ANSI_COLOR
if (color) {
@@ -439,6 +440,7 @@ checkType(Str s, Lineprop **oprop, Linecolor **ocolor)
#endif
*(prop++) = mode;
#ifdef USE_M17N
plen = get_mclen(str);
if (plen > 1) {
mode = (mode & ~PC_WCHAR1) | PC_WCHAR2;
for (i = 1; i < plen; i++) {
@@ -2019,13 +2021,15 @@ static char Base64Table[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
Str
base64_encode(const unsigned char *src, size_t len)
base64_encode(const char *src, size_t len)
{
Str dest;
const unsigned char *in, *endw;
const unsigned char *in, *endw, *s;
unsigned long j;
size_t k;
s = (unsigned char*)src;
k = len;
if (k % 3)
k += 3 - (k % 3);
@@ -2041,9 +2045,9 @@ base64_encode(const unsigned char *src, size_t len)
return Strnew();
}
in = src;
in = s;
endw = src + len - 2;
endw = s + len - 2;
while (in < endw) {
j = *in++;
@@ -2056,9 +2060,9 @@ base64_encode(const unsigned char *src, size_t len)
Strcatc(dest, Base64Table[j & 0x3f]);
}
if (src + len - in) {
if (s + len - in) {
j = *in++;
if (src + len - in) {
if (s + len - in) {
j = j << 8 | *in++;
j = j << 8;
Strcatc(dest, Base64Table[(j >> 18) & 0x3f]);
+12 -15
View File
@@ -1290,7 +1290,7 @@ AuthDigestCred(struct http_auth *ha, Str uname, Str pw, ParsedURL *pu,
tmp = Strnew_m_charp(uname->ptr, ":",
qstr_unquote(get_auth_param(ha->param, "realm"))->ptr,
":", pw->ptr, NULL);
MD5(tmp->ptr, strlen(tmp->ptr), md5);
MD5((unsigned char *)tmp->ptr, strlen(tmp->ptr), md5);
a1buf = digest_hex(md5);
if (algorithm) {
@@ -1303,7 +1303,7 @@ AuthDigestCred(struct http_auth *ha, Str uname, Str pw, ParsedURL *pu,
tmp = Strnew_m_charp(a1buf->ptr, ":",
qstr_unquote(nonce)->ptr,
":", qstr_unquote(cnonce)->ptr, NULL);
MD5(tmp->ptr, strlen(tmp->ptr), md5);
MD5((unsigned char *)tmp->ptr, strlen(tmp->ptr), md5);
a1buf = digest_hex(md5);
}
else if (strcasecmp(algorithm->ptr, "MD5") == 0)
@@ -1325,23 +1325,23 @@ AuthDigestCred(struct http_auth *ha, Str uname, Str pw, ParsedURL *pu,
Str ebody;
ebody = Strfgetall(fp);
fclose(fp);
MD5(ebody->ptr, strlen(ebody->ptr), md5);
MD5((unsigned char *)ebody->ptr, strlen(ebody->ptr), md5);
}
else {
MD5("", 0, md5);
MD5((unsigned char *)"", 0, md5);
}
}
else {
MD5(request->body, request->length, md5);
MD5((unsigned char *)request->body, request->length, md5);
}
}
else {
MD5("", 0, md5);
MD5((unsigned char *)"", 0, md5);
}
Strcat_char(tmp, ':');
Strcat(tmp, digest_hex(md5));
}
MD5(tmp->ptr, strlen(tmp->ptr), md5);
MD5((unsigned char *)tmp->ptr, strlen(tmp->ptr), md5);
a2buf = digest_hex(md5);
if (qop_i >= QOP_AUTH) {
@@ -1359,7 +1359,7 @@ AuthDigestCred(struct http_auth *ha, Str uname, Str pw, ParsedURL *pu,
":", qstr_unquote(cnonce)->ptr,
":", qop_i == QOP_AUTH ? "auth" : "auth-int",
":", a2buf->ptr, NULL);
MD5(tmp->ptr, strlen(tmp->ptr), md5);
MD5((unsigned char *)tmp->ptr, strlen(tmp->ptr), md5);
rd = digest_hex(md5);
}
else {
@@ -1369,7 +1369,7 @@ AuthDigestCred(struct http_auth *ha, Str uname, Str pw, ParsedURL *pu,
tmp = Strnew_m_charp(a1buf->ptr, ":",
qstr_unquote(get_auth_param(ha->param, "nonce"))->
ptr, ":", a2buf->ptr, NULL);
MD5(tmp->ptr, strlen(tmp->ptr), md5);
MD5((unsigned char *)tmp->ptr, strlen(tmp->ptr), md5);
rd = digest_hex(md5);
}
@@ -3803,7 +3803,7 @@ process_button(struct parsed_tag *tag)
{
Str tmp = NULL;
char *p, *q, *r, *qq = "";
int qlen, v;
int v;
if (cur_form_id < 0) {
char *s = "<form_int method=internal action=none>";
@@ -3847,7 +3847,6 @@ process_button(struct parsed_tag *tag)
}
if (q) {
qq = html_quote(q);
qlen = strlen(q);
}
/* Strcat_charp(tmp, "<pre_int>"); */
@@ -4002,7 +4001,6 @@ void
process_option(void)
{
char begin_char = '[', end_char = ']';
int len;
if (cur_select == NULL || cur_option == NULL)
return;
@@ -4013,6 +4011,7 @@ process_option(void)
if (cur_option_label == NULL)
cur_option_label = cur_option;
#ifdef MENU_SELECT
int len;
if (!select_is_multiple) {
len = get_Str_strwidth(cur_option_label);
if (len > cur_option_maxwidth)
@@ -7601,7 +7600,6 @@ loadGopherSearch0(URLFile *uf, ParsedURL *pu)
{
Str tmp;
char *volatile p, *volatile q;
MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL;
#ifdef USE_M17N
wc_ces doc_charset = DocumentCharset;
#endif
@@ -8166,7 +8164,6 @@ int
save2tmp(URLFile uf, char *tmpf)
{
FILE *ff;
int check;
clen_t linelen = 0, trbyte = 0;
MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL;
static JMP_BUF env_bak;
@@ -8183,8 +8180,8 @@ save2tmp(URLFile uf, char *tmpf)
goto _end;
}
TRAP_ON;
check = 0;
#ifdef USE_NNTP
int check = 0;
if (uf.scheme == SCM_NEWS) {
char c;
while (c = UFgetc(&uf), !iseos(uf.stream)) {
+3 -4
View File
@@ -551,13 +551,12 @@ loadImage(Buffer *buf, int flag)
}
#else /* !DONT_CALL_GC_AFTER_FORK */
if ((cache->pid = fork()) == 0) {
Buffer *b;
/*
* setup_child(TRUE, 0, -1);
*/
setup_child(FALSE, 0, -1);
image_source = cache->file;
b = loadGeneralFile(cache->url, cache->current, NULL, 0, NULL);
loadGeneralFile(cache->url, cache->current, NULL, 0, NULL);
/* TODO make sure removing this didn't break anything
if (!b || !b->real_type || strncasecmp(b->real_type, "image/", 6))
unlink(cache->file);
@@ -734,7 +733,7 @@ getImageSize(ImageCache * cache)
{
Str tmp;
FILE *f;
int w = 0, h = 0;
unsigned int w = 0, h = 0;
if (!activeImage)
return FALSE;
@@ -752,7 +751,7 @@ getImageSize(ImageCache * cache)
f = popen(tmp->ptr, "r");
if (!f)
return FALSE;
while (fscanf(f, "%d %d", &w, &h) < 0) {
while (fscanf(f, "%u %u", &w, &h) < 0) {
if (feof(f))
break;
}
+1 -1
View File
@@ -821,7 +821,7 @@ growbuf_reserve(struct growbuf *gb, int leastarea)
}
void
growbuf_append(struct growbuf *gb, const char *src, int len)
growbuf_append(struct growbuf *gb, const unsigned char *src, int len)
{
growbuf_reserve(gb, gb->length + len);
memcpy(&gb->ptr[gb->length], src, len);
+1 -1
View File
@@ -83,7 +83,7 @@ extern void growbuf_init_without_GC(struct growbuf *gb);
extern void growbuf_clear(struct growbuf *gb);
extern Str growbuf_to_Str(struct growbuf *gb);
extern void growbuf_reserve(struct growbuf *gb, int leastarea);
extern void growbuf_append(struct growbuf *gb, const char *src, int len);
extern void growbuf_append(struct growbuf *gb, const unsigned char *src, int len);
#define GROWBUF_ADD_CHAR(gb,ch) ((((gb)->length>=(gb)->area_size)?growbuf_reserve(gb,(gb)->length+1):(void)0),(void)((gb)->ptr[(gb)->length++] = (ch)))
extern char *w3m_auxbin_dir();
+1 -2
View File
@@ -418,7 +418,6 @@ ssl_check_cert_ident(X509 * x, char *hostname)
if (alt) {
int n;
GENERAL_NAME *gn;
X509V3_EXT_METHOD *method;
Str seen_dnsname = NULL;
n = sk_GENERAL_NAME_num(alt);
@@ -459,7 +458,7 @@ ssl_check_cert_ident(X509 * x, char *hostname)
break;
}
}
method = X509V3_EXT_get(ex);
X509V3_EXT_get(ex);
sk_GENERAL_NAME_free(alt);
if (i < n) /* Found a match */
match_ident = TRUE;
-2
View File
@@ -77,8 +77,6 @@ static Str strCurrentBuf;
static int use_hist;
#ifdef USE_M17N
static void ins_char(Str str);
#else
static void ins_char(char c);
#endif
char *
+8 -1
View File
@@ -380,17 +380,19 @@ localcgi_post(char *uri, char *qstr, FormList *request, char *referer)
cgi_dir = mydirname(file);
#endif
cgi_basename = mybasename(file);
pid = open_pipe_rw(&fr, NULL);
pid = open_pipe_rw(&fr, NULL); /* open_pipe_rw() forks */
/* Don't invoke gc after here, or the program might crash in some platforms */
if (pid < 0) {
if (fw)
fclose(fw);
return NULL;
} else if (pid) {
/* parent */
if (fw)
fclose(fw);
return fr;
}
/* child */
setup_child(TRUE, 2, fw ? fileno(fw) : -1);
set_cgi_environ(name, file, uri);
@@ -433,4 +435,9 @@ localcgi_post(char *uri, char *qstr, FormList *request, char *referer)
file, cgi_basename, strerror(errno));
exit(1);
#endif
/*
* Suppress compiler warning: function might return no value
* This code is never reached.
*/
return NULL;
}
+6 -7
View File
@@ -394,10 +394,15 @@ die_oom(size_t bytes)
{
fprintf(stderr, "Out of memory: %lu bytes unavailable!\n", (unsigned long)bytes);
exit(1);
/*
* Suppress compiler warning: function might return no value
* This code is never reached.
*/
return NULL;
}
int
main(int argc, char **argv, char **envp)
main(int argc, char **argv)
{
Buffer *newbuf = NULL;
char *p;
@@ -1808,15 +1813,11 @@ static int
dispincsrch(int ch, Str buf, Lineprop *prop)
{
static Buffer sbuf;
static Line *currentLine;
static int pos;
char *str;
int do_next_search = FALSE;
if (ch == 0 && buf == NULL) {
SAVE_BUFPOSITION(&sbuf); /* search starting point */
currentLine = sbuf.currentLine;
pos = sbuf.pos;
return -1;
}
@@ -1865,8 +1866,6 @@ dispincsrch(int ch, Str buf, Lineprop *prop)
arrangeCursor(Currentbuf);
srchcore(str, searchRoutine);
arrangeCursor(Currentbuf);
currentLine = Currentbuf->currentLine;
pos = Currentbuf->pos;
}
displayBuffer(Currentbuf, B_FORCE_REDRAW);
clear_mark(Currentbuf->currentLine);
+1 -2
View File
@@ -1100,7 +1100,7 @@ process_mMouse(int btn, int x, int y)
{
Menu *menu;
int mselect, i;
static int press_btn = MOUSE_BTN_RESET, press_x, press_y;
static int press_btn = MOUSE_BTN_RESET, press_y;
char c = ' ';
menu = CurrentMenu;
@@ -1169,7 +1169,6 @@ process_mMouse(int btn, int x, int y)
if (btn != MOUSE_BTN4_DOWN_RXVT || press_btn == MOUSE_BTN_RESET) {
press_btn = btn;
press_x = x;
press_y = y;
}
else {
+1 -1
View File
@@ -26,7 +26,7 @@ defhashfunc(HashItem_ss *, int, hss_i)
/* *INDENT-ON* */
int
main(int argc, char *argv[], char **envp)
main(int argc, char *argv[])
{
FILE *f;
Hash_ss *hash;
+1 -2
View File
@@ -235,7 +235,6 @@ InputStream
openNewsStream(ParsedURL *pu)
{
char *host, *mode, *group, *p;
Str tmp;
int port, status;
if (pu->file == NULL || *pu->file == '\0')
@@ -262,7 +261,7 @@ openNewsStream(ParsedURL *pu)
mode = NULL;
if (current_news.host) {
if (!strcmp(current_news.host, host) && current_news.port == port) {
tmp = news_command(&current_news, "MODE", mode ? mode : "READER",
news_command(&current_news, "MODE", mode ? mode : "READER",
&status);
if (status != 200 && status != 201)
news_close(&current_news);
+2 -2
View File
@@ -5,7 +5,7 @@
*
* Created: Wed Feb 10 12:47:03 1999
*/
extern int main(int argc, char **argv, char **envp);
extern int main(int argc, char **argv);
extern void nulcmd(void);
extern void pushEvent(int cmd, void *data);
extern MySignalHandler intTrap(SIGNAL_ARG);
@@ -831,4 +831,4 @@ void srand48(long);
long lrand48(void);
#endif
extern Str base64_encode(const unsigned char *src, size_t len);
extern Str base64_encode(const char *src, size_t len);
+1 -1
View File
@@ -37,7 +37,7 @@
#include <stdio.h>
int
main()
main(void)
{
char *cp;
Display *dpy;
+1 -1
View File
@@ -181,7 +181,7 @@ push_symbol(Str str, char symbol, int width, int n)
#endif
p = alt_symbol[(unsigned char)symbol % N_SYMBOL];
for (i = 0; i < 2 && *p; i++, p++)
buf[i] = (*p == ' ') ? NBSP_CODE : *p;
buf[i] = (*p == ' ') ? (char)NBSP_CODE : *p;
Strcat(str, Sprintf("<_SYMBOL TYPE=%d>", symbol));
for (; n > 0; n--)
+2 -2
View File
@@ -419,7 +419,7 @@ suspend_or_pushdata(struct table *tbl, char *line)
#ifdef USE_M17N
#define PUSH_TAG(str,n) Strcat_charp_n(tagbuf, str, n)
#else
#define PUSH_TAG(str,n) Strcat_char(tagbuf, *str)
#define PUSH_TAG(str,n) Strcat_char(tagbuf, *str), (void)n
#endif
int visible_length_offset = 0;
@@ -1524,7 +1524,7 @@ check_table_height(struct table *t)
short maxcell;
short size;
int *height;
} cell;
} cell = {0};
int space = 0;
cell.size = 0;
+2 -2
View File
@@ -356,7 +356,7 @@ char *ttyname(int);
#define SETCHMODE(var,mode) ((var) = (((var)&~C_WHICHCHAR) | mode))
#ifdef USE_M17N
#define SETCH(var,ch,len) ((var) = New_Reuse(char, (var), (len) + 1), \
strncpy((var), (ch), (len)), (var)[len] = '\0')
strncpy((var), (ch), (len + 1)))
#else
#define SETCH(var,ch,len) ((var) = (ch))
#endif
@@ -737,7 +737,7 @@ save_first_animation_frame(const char *path)
/* Header */
if (len != st.st_size || strncmp(header, "GIF89a", 6) != 0) {
if (len != st.st_size || strncmp((char *)header, "GIF89a", 6) != 0) {
return NULL;
}
+1 -1
View File
@@ -181,7 +181,7 @@ insert_bookmark(char *bmark, struct parsed_tagarg *data)
}
int
main(int argc, char *argv[], char **envp)
main(void)
{
extern char *getenv();
char *p;
+1 -1
View File
@@ -164,7 +164,7 @@ editMailcap(char *mailcap, struct parsed_tagarg *args)
}
int
main(int argc, char *argv[], char **envp)
main(void)
{
Str mailcapfile;
extern char *getenv();