1
0
mirror of https://github.com/golang/go synced 2024-11-21 18:44:45 -07:00

various: appease the ubuntu gcc monster

Silence warnings about not checking
return values from read and write system calls.

R=r, r2
CC=golang-dev
https://golang.org/cl/2258045
This commit is contained in:
Russ Cox 2010-09-28 13:00:13 -04:00
parent ec13ed1fce
commit 05cc83bf4e
8 changed files with 27 additions and 15 deletions

View File

@ -482,7 +482,7 @@ asmb(void)
if(dlm){
char buf[8];
write(cout, buf, INITDAT-textsize);
ewrite(cout, buf, INITDAT-textsize);
textsize = INITDAT;
}
for(t = 0; t < datsize; t += sizeof(buf)-100) {
@ -987,7 +987,7 @@ cflush(void)
/* no bug if cbc < 0 since obuf(cbuf) followed by ibuf in buf! */
n = sizeof(buf.cbuf) - cbc;
if(n)
write(cout, buf.cbuf, n);
ewrite(cout, buf.cbuf, n);
cbp = buf.cbuf;
cbc = sizeof(buf.cbuf);
}
@ -1398,7 +1398,7 @@ datblk(int32 s, int32 n, int str)
break;
}
}
write(cout, buf.dbuf, n);
ewrite(cout, buf.dbuf, n);
}
void

View File

@ -575,7 +575,7 @@ asmb(void)
if(dlm){
char buf[8];
write(cout, buf, INITDAT-textsize);
ewrite(cout, buf, INITDAT-textsize);
textsize = INITDAT;
}
@ -649,7 +649,7 @@ asmb(void)
cflush();
elfstro = seek(cout, 0, 1);
elfsymsize = elfstro - elfsymo;
write(cout, elfstrdat, elfstrsize);
ewrite(cout, elfstrdat, elfstrsize);
if(debug['v'])
Bprint(&bso, "%5.2f dwarf\n", cputime());
@ -938,7 +938,7 @@ cflush(void)
n = sizeof(buf.cbuf) - cbc;
if(n)
write(cout, buf.cbuf, n);
ewrite(cout, buf.cbuf, n);
cbp = buf.cbuf;
cbc = sizeof(buf.cbuf);
}
@ -1208,7 +1208,7 @@ datblk(int32 s, int32 n)
}
}
write(cout, buf.dbuf, n);
ewrite(cout, buf.dbuf, n);
if(!debug['a'])
return;

View File

@ -604,7 +604,7 @@ asmb(void)
if(dlm){
char buf[8];
write(cout, buf, INITDAT-textsize);
ewrite(cout, buf, INITDAT-textsize);
textsize = INITDAT;
}
@ -1080,7 +1080,7 @@ cflush(void)
n = sizeof(buf.cbuf) - cbc;
if(n)
write(cout, buf.cbuf, n);
ewrite(cout, buf.cbuf, n);
cbp = buf.cbuf;
cbc = sizeof(buf.cbuf);
}
@ -1213,7 +1213,7 @@ datblk(int32 s, int32 n, int32 rodata)
}
}
write(cout, buf.dbuf, n);
ewrite(cout, buf.dbuf, n);
if(!debug['a'])
return;

View File

@ -316,7 +316,7 @@ elfwriteinterp(void)
n = strlen(interp)+1;
seek(cout, ELFRESERVE-n, 0);
write(cout, interp, n);
ewrite(cout, interp, n);
return n;
}

View File

@ -924,3 +924,12 @@ addsection(Segment *seg, char *name, int rwx)
*l = sect;
return sect;
}
void
ewrite(int fd, void *buf, int n)
{
if(write(fd, buf, n) < 0) {
diag("write error: %r");
errorexit();
}
}

View File

@ -128,6 +128,7 @@ void ldpkg(Biobuf*, char*, int64, char*, int);
void mark(Sym *s);
char* expandpkg(char*, char*);
void deadcode(void);
void ewrite(int, void*, int);
int pathchar(void);
void* mal(uint32);

View File

@ -430,8 +430,8 @@ domacholink(void)
}
}
write(cout, linkdata, nlinkdata);
write(cout, strtab, nstrtab);
ewrite(cout, linkdata, nlinkdata);
ewrite(cout, strtab, nstrtab);
}
return rnd(nlinkdata+nstrtab, INITRND);
}

View File

@ -786,7 +786,8 @@ error:
goto done;
memset(buf, 0, sizeof buf);
seek(fd, sh[ep->shstrndx].offset, 0);
read(fd, buf, sh[ep->shstrndx].size);
i = read(fd, buf, sh[ep->shstrndx].size);
USED(i); // shut up ubuntu gcc
for(i = 0; i < ep->shnum; i++) {
if (strcmp(&buf[sh[i].name], ".gosymtab") == 0) {
@ -967,7 +968,8 @@ error:
goto done;
memset(buf, 0, sizeof buf);
seek(fd, sh[ep->shstrndx].offset, 0);
read(fd, buf, sh[ep->shstrndx].size);
i = read(fd, buf, sh[ep->shstrndx].size);
USED(i); // shut up ubuntu gcc
for(i = 0; i < ep->shnum; i++) {
if (strcmp(&buf[sh[i].name], ".gosymtab") == 0) {