Skip to content

Commit

Permalink
Merge pull request #222 from rkta/Wall
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tats authored Apr 9, 2022
2 parents fecbe42 + 5b33d9f commit ca9f5fc
Show file tree
Hide file tree
Showing 23 changed files with 64 additions and 67 deletions.
2 changes: 1 addition & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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)\" \
Expand Down
8 changes: 3 additions & 5 deletions Str.c
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand All @@ -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':
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions display.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
18 changes: 11 additions & 7 deletions etc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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++) {
Expand Down Expand Up @@ -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);
Expand All @@ -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++;
Expand All @@ -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]);
Expand Down
27 changes: 12 additions & 15 deletions file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
Expand All @@ -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) {
Expand All @@ -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 {
Expand All @@ -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);
}

Expand Down Expand Up @@ -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>";
Expand Down Expand Up @@ -3847,7 +3847,6 @@ process_button(struct parsed_tag *tag)
}
if (q) {
qq = html_quote(q);
qlen = strlen(q);
}

/* Strcat_charp(tmp, "<pre_int>"); */
Expand Down Expand Up @@ -4002,7 +4001,6 @@ void
process_option(void)
{
char begin_char = '[', end_char = ']';
int len;

if (cur_select == NULL || cur_option == NULL)
return;
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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)) {
Expand Down
7 changes: 3 additions & 4 deletions image.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion indep.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion indep.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions istream.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions linein.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down
9 changes: 8 additions & 1 deletion local.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Loading

0 comments on commit ca9f5fc

Please sign in to comment.