aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2020-01-12 15:05:40 -0500
committerRuss Cox <rsc@swtch.com>2020-01-12 15:07:42 -0500
commitfafa622a5bdf71adfbb4334541c3b65f29c89ca9 (patch)
tree189d86fb978b151ddf2f303f9c4efab196d79f17 /src
parentfa325e9b42b0bdfb48857d1958d9fb7ceac55151 (diff)
downloadplan9port-fafa622a5bdf71adfbb4334541c3b65f29c89ca9.tar.gz
plan9port-fafa622a5bdf71adfbb4334541c3b65f29c89ca9.tar.bz2
plan9port-fafa622a5bdf71adfbb4334541c3b65f29c89ca9.zip
all: fix or silence various gcc warnings
As usual, gcc finds some real problems but also reports a ton of noise. Fix the problems and quiet the noise.
Diffstat (limited to 'src')
-rw-r--r--src/cmd/auth/factotum/p9cr.c2
-rw-r--r--src/cmd/draw/tweak.c2
-rw-r--r--src/cmd/eqn/text.c2
-rw-r--r--src/cmd/grap/coord.c2
-rw-r--r--src/cmd/mk/archive.c2
-rw-r--r--src/cmd/paint/eenter.c1
-rw-r--r--src/cmd/pic/input.c2
-rw-r--r--src/cmd/pic/pic.h2
-rw-r--r--src/cmd/rio/showevent/ShowEvent.c2
-rw-r--r--src/cmd/svgpic/input.c2
-rw-r--r--src/cmd/svgpic/pic.h2
-rw-r--r--src/cmd/tpic/input.c2
-rw-r--r--src/cmd/tpic/pic.h2
-rw-r--r--src/cmd/troff/t6.c6
-rw-r--r--src/lib9/_p9dialparse.c2
-rw-r--r--src/lib9/lrand.c12
16 files changed, 23 insertions, 22 deletions
diff --git a/src/cmd/auth/factotum/p9cr.c b/src/cmd/auth/factotum/p9cr.c
index 4f181e98..84860d16 100644
--- a/src/cmd/auth/factotum/p9cr.c
+++ b/src/cmd/auth/factotum/p9cr.c
@@ -290,6 +290,8 @@ p9crresp(ServerState *s, uchar *resp, int resplen)
Ticket t;
Ticketreq tr;
+ memset(&tr, 0, sizeof tr); // TODO: what should tr be initialized to?
+
if(xiowrite(s->asfd, resp, resplen) != resplen)
return -1;
diff --git a/src/cmd/draw/tweak.c b/src/cmd/draw/tweak.c
index 0a71e2dd..29e2b3d7 100644
--- a/src/cmd/draw/tweak.c
+++ b/src/cmd/draw/tweak.c
@@ -1142,7 +1142,7 @@ textedit(Thing *t, char *tag)
fc = f->info;
for(i=0; i<=w && i<=f->n; i++)
nfc[i] = fc[i];
- if(w+1 < i)
+ if(i < w+1)
memset(nfc+i, 0, ((w+1)-i)*sizeof(Fontchar));
x = fc[f->n].x;
for(; i<=w; i++)
diff --git a/src/cmd/eqn/text.c b/src/cmd/eqn/text.c
index 4ca0bbd9..6e2c8325 100644
--- a/src/cmd/eqn/text.c
+++ b/src/cmd/eqn/text.c
@@ -257,7 +257,7 @@ trans(int c, char *p1)
char *pad(int n) /* return the padding as a string */
{
- static char buf[20];
+ static char buf[30];
buf[0] = 0;
if (n < 0) {
diff --git a/src/cmd/grap/coord.c b/src/cmd/grap/coord.c
index 72f0fc3a..ea640458 100644
--- a/src/cmd/grap/coord.c
+++ b/src/cmd/grap/coord.c
@@ -35,7 +35,7 @@ void coordlog(int n) /* remember log scaling */
void coord(Obj *p) /* set coord range */
{
- static char buf[10];
+ static char buf[20];
ncoord++;
if (ncoord > 1 && strcmp(p->name, dflt_coord) == 0) {
diff --git a/src/cmd/mk/archive.c b/src/cmd/mk/archive.c
index 026641bd..5b0c1d00 100644
--- a/src/cmd/mk/archive.c
+++ b/src/cmd/mk/archive.c
@@ -202,7 +202,7 @@ atimes(char *ar)
name[namelen] = 0;
namelen = 0;
}else{
- strncpy(name, h.name, sizeof(h.name));
+ memmove(name, h.name, sizeof(h.name));
for(i = sizeof(h.name)-1; i > 0 && name[i] == ' '; i--)
;
if(name[i] == '/') /* system V bug */
diff --git a/src/cmd/paint/eenter.c b/src/cmd/paint/eenter.c
index 6c84f2fb..d3d68a35 100644
--- a/src/cmd/paint/eenter.c
+++ b/src/cmd/paint/eenter.c
@@ -78,6 +78,7 @@ eenter(char *ask, char *buf, int len, Mouse *m)
b = screen;
sc = b->clipr;
replclipr(b, 0, b->r);
+ t = ZP;
while(!done){
p = stringsize(font, buf ? buf : "");
diff --git a/src/cmd/pic/input.c b/src/cmd/pic/input.c
index a81f622e..92e8d62d 100644
--- a/src/cmd/pic/input.c
+++ b/src/cmd/pic/input.c
@@ -435,7 +435,7 @@ double errcheck(double x, char *s)
return x;
}
-char errbuf[200];
+char errbuf[1000];
void eprint(void);
diff --git a/src/cmd/pic/pic.h b/src/cmd/pic/pic.h
index 928d38dd..cdaf71e5 100644
--- a/src/cmd/pic/pic.h
+++ b/src/cmd/pic/pic.h
@@ -9,7 +9,7 @@
extern void yyerror(char *);
-extern char errbuf[200];
+extern char errbuf[1000];
#undef sprintf /* Snow Leopard */
diff --git a/src/cmd/rio/showevent/ShowEvent.c b/src/cmd/rio/showevent/ShowEvent.c
index 56f620d5..12942e11 100644
--- a/src/cmd/rio/showevent/ShowEvent.c
+++ b/src/cmd/rio/showevent/ShowEvent.c
@@ -68,7 +68,7 @@ Time time;
unsigned long min;
unsigned long hr;
unsigned long day;
- static char buffer[32];
+ static char buffer[50];
msec = time % 1000;
time /= 1000;
diff --git a/src/cmd/svgpic/input.c b/src/cmd/svgpic/input.c
index a81f622e..92e8d62d 100644
--- a/src/cmd/svgpic/input.c
+++ b/src/cmd/svgpic/input.c
@@ -435,7 +435,7 @@ double errcheck(double x, char *s)
return x;
}
-char errbuf[200];
+char errbuf[1000];
void eprint(void);
diff --git a/src/cmd/svgpic/pic.h b/src/cmd/svgpic/pic.h
index 928d38dd..cdaf71e5 100644
--- a/src/cmd/svgpic/pic.h
+++ b/src/cmd/svgpic/pic.h
@@ -9,7 +9,7 @@
extern void yyerror(char *);
-extern char errbuf[200];
+extern char errbuf[1000];
#undef sprintf /* Snow Leopard */
diff --git a/src/cmd/tpic/input.c b/src/cmd/tpic/input.c
index 6885f650..85b7dbb5 100644
--- a/src/cmd/tpic/input.c
+++ b/src/cmd/tpic/input.c
@@ -438,7 +438,7 @@ errcheck(double x, char *s)
return x;
}
-char errbuf[200];
+char errbuf[1000];
void
yyerror(char *s)
diff --git a/src/cmd/tpic/pic.h b/src/cmd/tpic/pic.h
index a11c7478..104caceb 100644
--- a/src/cmd/tpic/pic.h
+++ b/src/cmd/tpic/pic.h
@@ -11,7 +11,7 @@
#define dprintf if(dbg)printf
-extern char errbuf[200];
+extern char errbuf[1000];
#undef sprintf /* Snow Leopard */
diff --git a/src/cmd/troff/t6.c b/src/cmd/troff/t6.c
index 1e0dc968..3a2d8d85 100644
--- a/src/cmd/troff/t6.c
+++ b/src/cmd/troff/t6.c
@@ -723,15 +723,15 @@ setfp(int pos, int f, char *truename, int print) /* mount font f at position pos
else
strcpy(shortname, (char *) unpair(f));
if (truename && strrchr(truename, '/')) { /* .fp 1 R dir/file: use verbatim */
- sprintf(pathname, "%s", truename);
+ snprintf(pathname, NS, "%s", truename);
if (fonts[pos].truename)
free(fonts[pos].truename);
fonts[pos].truename = strdupl(truename);
} else if (truename) { /* synonym: .fp 1 R Avant */
- sprintf(pathname, "%s/dev%s/%s", fontdir, devname, truename);
+ snprintf(pathname, NS, "%s/dev%s/%s", fontdir, devname, truename);
truename = 0; /* so doesn't get repeated by ptfpcmd */
} else /* vanilla: .fp 5 XX */
- sprintf(pathname, "%s/dev%s/%s", fontdir, devname, shortname);
+ snprintf(pathname, NS, "%s/dev%s/%s", fontdir, devname, shortname);
if (truename == 0 && fonts[pos].truename != 0) {
free(fonts[pos].truename);
fonts[pos].truename = 0;
diff --git a/src/lib9/_p9dialparse.c b/src/lib9/_p9dialparse.c
index 2cc23574..4e56f5ee 100644
--- a/src/lib9/_p9dialparse.c
+++ b/src/lib9/_p9dialparse.c
@@ -72,7 +72,7 @@ p9dialparse(char *addr, char **pnet, char **punix, void *phost, int *pport)
if((port = strchr(host, '!')) == nil){
if(strcmp(net, "unix")==0 || strcmp(net, "net")==0){
Unix:
- if(strlen(host)+1 > sizeof ((struct sockaddr_un*)&ss)->sun_path){
+ if(strlen(host)+1 > sizeof ((struct sockaddr_un*)ss)->sun_path){
werrstr("unix socket name too long");
return -1;
}
diff --git a/src/lib9/lrand.c b/src/lib9/lrand.c
index 8f536456..3d1b05fe 100644
--- a/src/lib9/lrand.c
+++ b/src/lib9/lrand.c
@@ -63,17 +63,15 @@ p9lrand(void)
lock(&lk);
- rng_tap--;
- if(rng_tap < rng_vec) {
- if(rng_feed == 0) {
+ if(rng_tap <= rng_vec) {
+ if(rng_feed == 0)
isrand(1);
- rng_tap--;
- }
rng_tap += LEN;
}
- rng_feed--;
- if(rng_feed < rng_vec)
+ rng_tap--;
+ if(rng_feed <= rng_vec)
rng_feed += LEN;
+ rng_feed--;
x = (*rng_feed + *rng_tap) & MASK;
*rng_feed = x;