1
0
mirror of https://github.com/golang/go synced 2024-11-22 00:44:39 -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){ if(dlm){
char buf[8]; char buf[8];
write(cout, buf, INITDAT-textsize); ewrite(cout, buf, INITDAT-textsize);
textsize = INITDAT; textsize = INITDAT;
} }
for(t = 0; t < datsize; t += sizeof(buf)-100) { 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! */ /* no bug if cbc < 0 since obuf(cbuf) followed by ibuf in buf! */
n = sizeof(buf.cbuf) - cbc; n = sizeof(buf.cbuf) - cbc;
if(n) if(n)
write(cout, buf.cbuf, n); ewrite(cout, buf.cbuf, n);
cbp = buf.cbuf; cbp = buf.cbuf;
cbc = sizeof(buf.cbuf); cbc = sizeof(buf.cbuf);
} }
@ -1398,7 +1398,7 @@ datblk(int32 s, int32 n, int str)
break; break;
} }
} }
write(cout, buf.dbuf, n); ewrite(cout, buf.dbuf, n);
} }
void void

View File

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

View File

@ -604,7 +604,7 @@ asmb(void)
if(dlm){ if(dlm){
char buf[8]; char buf[8];
write(cout, buf, INITDAT-textsize); ewrite(cout, buf, INITDAT-textsize);
textsize = INITDAT; textsize = INITDAT;
} }
@ -1080,7 +1080,7 @@ cflush(void)
n = sizeof(buf.cbuf) - cbc; n = sizeof(buf.cbuf) - cbc;
if(n) if(n)
write(cout, buf.cbuf, n); ewrite(cout, buf.cbuf, n);
cbp = buf.cbuf; cbp = buf.cbuf;
cbc = sizeof(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']) if(!debug['a'])
return; return;

View File

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

View File

@ -924,3 +924,12 @@ addsection(Segment *seg, char *name, int rwx)
*l = sect; *l = sect;
return 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); void mark(Sym *s);
char* expandpkg(char*, char*); char* expandpkg(char*, char*);
void deadcode(void); void deadcode(void);
void ewrite(int, void*, int);
int pathchar(void); int pathchar(void);
void* mal(uint32); void* mal(uint32);

View File

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

View File

@ -786,7 +786,8 @@ error:
goto done; goto done;
memset(buf, 0, sizeof buf); memset(buf, 0, sizeof buf);
seek(fd, sh[ep->shstrndx].offset, 0); 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++) { for(i = 0; i < ep->shnum; i++) {
if (strcmp(&buf[sh[i].name], ".gosymtab") == 0) { if (strcmp(&buf[sh[i].name], ".gosymtab") == 0) {
@ -967,7 +968,8 @@ error:
goto done; goto done;
memset(buf, 0, sizeof buf); memset(buf, 0, sizeof buf);
seek(fd, sh[ep->shstrndx].offset, 0); 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++) { for(i = 0; i < ep->shnum; i++) {
if (strcmp(&buf[sh[i].name], ".gosymtab") == 0) { if (strcmp(&buf[sh[i].name], ".gosymtab") == 0) {