commit b75af9b4adebaa3208029df33a82f5fdabf230b0
parent 8fa4b8b8dc70bab372d2ffd8fcb05546bfe7e2cc
Author: Rolf Eike Beer <eike@sf-mail.de>
Date: Tue, 31 Dec 2019 13:59:28 +0100
rename local variables shadowing global variables of the same name
Diffstat:
7 files changed, 33 insertions(+), 46 deletions(-)
diff --git a/.cirrus.yml b/.cirrus.yml
@@ -15,7 +15,7 @@ task:
pkginstall_script:
- pkg install -y groff pkgconf check
configure_script:
- - echo "clang -O2 -Wall" > conf-cc
+ - echo "clang -O2 -Wall -Wshadow" > conf-cc
compile_script:
- make it man
test_script:
diff --git a/.travis.yml b/.travis.yml
@@ -14,7 +14,7 @@ addons:
- pkg-config
- check
script:
- - echo "${CC} -O2 -Wall" > conf-cc
+ - echo "${CC} -O2 -Wall -Wshadow" > conf-cc
- if [ -n "${FORCE_UTMP}" ]; then cp qtmp.h1 qtmp.h; fi
- make ${MAKEFLAGS} it man
- make test
diff --git a/cdbmake_add.c b/cdbmake_add.c
@@ -10,17 +10,13 @@ struct cdbmake *cdbm;
cdbm->numentries = 0;
}
-int cdbmake_add(cdbm,h,p,alloc)
-struct cdbmake *cdbm;
-uint32 h;
-uint32 p;
-char *(*alloc)();
+int cdbmake_add(struct cdbmake *cdbm, uint32 h, uint32 p, char *(*alloc_fun)())
{
struct cdbmake_hplist *head;
head = cdbm->head;
if (!head || (head->num >= CDBMAKE_HPLIST)) {
- head = (struct cdbmake_hplist *) alloc(sizeof(struct cdbmake_hplist));
+ head = (struct cdbmake_hplist *) alloc_fun(sizeof(struct cdbmake_hplist));
if (!head) return 0;
head->num = 0;
head->next = cdbm->head;
@@ -33,9 +29,7 @@ char *(*alloc)();
return 1;
}
-int cdbmake_split(cdbm,alloc)
-struct cdbmake *cdbm;
-char *(*alloc)();
+int cdbmake_split(struct cdbmake *cdbm, char *(*alloc_fun)())
{
int i;
uint32 u;
@@ -63,7 +57,7 @@ char *(*alloc)();
u /= sizeof(struct cdbmake_hp);
if (memsize > u) return 0;
- cdbm->split = (struct cdbmake_hp *) alloc(memsize * sizeof(struct cdbmake_hp));
+ cdbm->split = (struct cdbmake_hp *) alloc_fun(memsize * sizeof(struct cdbmake_hp));
if (!cdbm->split) return 0;
cdbm->hash = cdbm->split + cdbm->numentries;
diff --git a/dns.c b/dns.c
@@ -220,32 +220,28 @@ stralloc *sa;
#define FMT_IAA 40
-static int iaafmt(s,ip)
-char *s;
-struct ip_address *ip;
+static int iaafmt(char *s, struct ip_address *ipa)
{
unsigned int i;
unsigned int len;
len = 0;
- i = fmt_ulong(s,(unsigned long) ip->d[3]); len += i; if (s) s += i;
+ i = fmt_ulong(s,(unsigned long) ipa->d[3]); len += i; if (s) s += i;
i = fmt_str(s,"."); len += i; if (s) s += i;
- i = fmt_ulong(s,(unsigned long) ip->d[2]); len += i; if (s) s += i;
+ i = fmt_ulong(s,(unsigned long) ipa->d[2]); len += i; if (s) s += i;
i = fmt_str(s,"."); len += i; if (s) s += i;
- i = fmt_ulong(s,(unsigned long) ip->d[1]); len += i; if (s) s += i;
+ i = fmt_ulong(s,(unsigned long) ipa->d[1]); len += i; if (s) s += i;
i = fmt_str(s,"."); len += i; if (s) s += i;
- i = fmt_ulong(s,(unsigned long) ip->d[0]); len += i; if (s) s += i;
+ i = fmt_ulong(s,(unsigned long) ipa->d[0]); len += i; if (s) s += i;
i = fmt_str(s,".in-addr.arpa."); len += i; if (s) s += i;
return len;
}
-int dns_ptr(sa,ip)
-stralloc *sa;
-struct ip_address *ip;
+int dns_ptr(stralloc *sa, struct ip_address *ipa)
{
int r;
- if (!stralloc_ready(sa,iaafmt((char *) 0,ip))) return DNS_MEM;
- sa->len = iaafmt(sa->s,ip);
+ if (!stralloc_ready(sa,iaafmt((char *) 0,ipa))) return DNS_MEM;
+ sa->len = iaafmt(sa->s,ipa);
switch(resolve(sa,T_PTR))
{
case DNS_MEM: return DNS_MEM;
@@ -264,10 +260,7 @@ struct ip_address *ip;
return DNS_HARD;
}
-static int dns_ipplus(ia,sa,pref)
-ipalloc *ia;
-stralloc *sa;
-int pref;
+static int dns_ipplus(ipalloc *ia, stralloc *sa, int dpref)
{
int r;
struct ip_mx ix;
@@ -292,7 +285,7 @@ int pref;
while ((r = findip(T_A)) != 2)
{
ix.ip = ip;
- ix.pref = pref;
+ ix.pref = dpref;
if (r == DNS_SOFT) return DNS_SOFT;
if (r == 1)
if (!ipalloc_append(ia,&ix)) return DNS_MEM;
diff --git a/qmail-local.c b/qmail-local.c
@@ -79,7 +79,7 @@ char *dir;
{
unsigned long pid;
unsigned long time;
- char host[64];
+ char myhost[64];
char *s;
int loop;
struct stat st;
@@ -90,8 +90,8 @@ char *dir;
sig_alarmcatch(sigalrm);
if (chdir(dir) == -1) { if (error_temp(errno)) _exit(1); _exit(2); }
pid = getpid();
- host[0] = 0;
- gethostname(host,sizeof(host));
+ myhost[0] = 0;
+ gethostname(myhost,sizeof(myhost));
for (loop = 0;;++loop)
{
time = now();
@@ -99,7 +99,7 @@ char *dir;
s += fmt_str(s,"tmp/");
s += fmt_ulong(s,time); *s++ = '.';
s += fmt_ulong(s,pid); *s++ = '.';
- s += fmt_strn(s,host,sizeof(host)); *s++ = 0;
+ s += fmt_strn(s,myhost,sizeof(myhost)); *s++ = 0;
if (stat(fntmptph,&st) == -1) if (errno == error_noent) break;
/* really should never get to this point */
if (loop == 2) _exit(1);
@@ -531,7 +531,7 @@ char **argv;
if (!stralloc_copys(&ufline,"From ")) temp_nomem();
if (*sender)
{
- int len; int i; char ch;
+ int len; char ch;
len = str_len(sender);
if (!stralloc_readyplus(&ufline,len)) temp_nomem();
diff --git a/qmail-pw2u.c b/qmail-pw2u.c
@@ -198,18 +198,18 @@ void dosubuser()
int i;
char *x;
unsigned int xlen;
- char *uugh;
+ char *u;
x = line.s; xlen = line.len; i = byte_chr(x,xlen,':'); if (i == xlen) return;
if (!stralloc_copyb(&sub,x,i)) die_nomem();
++i; x += i; xlen -= i; i = byte_chr(x,xlen,':'); if (i == xlen) return;
- uugh = constmap(&mapuser,x,i);
- if (!uugh) die_user(x,i);
+ u = constmap(&mapuser,x,i);
+ if (!u) die_user(x,i);
++i; x += i; xlen -= i; i = byte_chr(x,xlen,':'); if (i == xlen) return;
if (substdio_puts(subfdout,"=") == -1) die_write();
if (substdio_put(subfdout,sub.s,sub.len) == -1) die_write();
- if (substdio_puts(subfdout,uugh) == -1) die_write();
+ if (substdio_puts(subfdout,u) == -1) die_write();
if (substdio_puts(subfdout,dashcolon) == -1) die_write();
if (substdio_put(subfdout,x,i) == -1) die_write();
if (substdio_puts(subfdout,":\n") == -1) die_write();
@@ -218,7 +218,7 @@ void dosubuser()
if (substdio_puts(subfdout,"+") == -1) die_write();
if (substdio_put(subfdout,sub.s,sub.len) == -1) die_write();
if (substdio_put(subfdout,auto_break,1) == -1) die_write();
- if (substdio_puts(subfdout,uugh) == -1) die_write();
+ if (substdio_puts(subfdout,u) == -1) die_write();
if (substdio_puts(subfdout,dashcolon) == -1) die_write();
if (substdio_put(subfdout,x,i) == -1) die_write();
if (substdio_puts(subfdout,"-:\n") == -1) die_write();
diff --git a/qmail-send.c b/qmail-send.c
@@ -1254,7 +1254,7 @@ fd_set *rfds;
int match;
unsigned long id;
unsigned int len;
- direntry *d;
+ direntry *dent;
int c;
unsigned long uid;
unsigned long pid;
@@ -1280,17 +1280,17 @@ fd_set *rfds;
nexttodorun = recent + SLEEP_TODO;
}
- d = readdir(tododir);
- if (!d)
+ dent = readdir(tododir);
+ if (!dent)
{
closedir(tododir);
tododir = 0;
return;
}
- if (str_equal(d->d_name,".")) return;
- if (str_equal(d->d_name,"..")) return;
- len = scan_ulong(d->d_name,&id);
- if (!len || d->d_name[len]) return;
+ if (str_equal(dent->d_name,".")) return;
+ if (str_equal(dent->d_name,"..")) return;
+ len = scan_ulong(dent->d_name,&id);
+ if (!len || dent->d_name[len]) return;
fnmake_todo(id);