Hello golang-dev@googlegroups.com, I'd like you to review this change to https://go.googlecode.com/hg/
Update issue 5764 ? On Sat, Aug 3, 2013 at 10:03 AM, <iant@golang.org> wrote: > Reviewers: golang-dev1, > > Message: > Hello golang-dev@googlegroups.com, > > I'd like you to review this change to > https://go.googlecode.com/hg/ > > > Description: > libbio: add casts to remove -Wconversion warnings > > Please review this at https://codereview.appspot.com/12388043/ > > Affected files: > src/libbio/bflush.c > src/libbio/bgetc.c > src/libbio/bgetrune.c > src/libbio/bprint.c > src/libbio/bputc.c > src/libbio/bputrune.c > src/libbio/brdline.c > src/libbio/brdstr.c > src/libbio/bread.c > src/libbio/bseek.c > src/libbio/bwrite.c > > > Index: src/libbio/bflush.c > =================================================================== > --- a/src/libbio/bflush.c > +++ b/src/libbio/bflush.c > @@ -37,7 +37,7 @@ > n = bp->bsize+bp->ocount; > if(n == 0) > return 0; > - c = write(bp->fid, bp->bbuf, n); > + c = (int)write(bp->fid, bp->bbuf, (size_t)n); > if(n == c) { > bp->offset += n; > bp->ocount = -bp->bsize; > Index: src/libbio/bgetc.c > =================================================================== > --- a/src/libbio/bgetc.c > +++ b/src/libbio/bgetc.c > @@ -49,7 +49,7 @@ > * buffer to allow that many ungets. > */ > memmove(bp->bbuf-Bungetsize, bp->ebuf-Bungetsize, Bungetsize); > - i = read(bp->fid, bp->bbuf, bp->bsize); > + i = (int)read(bp->fid, bp->bbuf, (size_t)bp->bsize); > bp->gbuf = bp->bbuf; > if(i <= 0) { > bp->state = Bracteof; > @@ -58,7 +58,7 @@ > return Beof; > } > if(i < bp->bsize) { > - memmove(bp->ebuf-i-Bungetsize, bp->bbuf-Bungetsize, > i+Bungetsize); > + memmove(bp->ebuf-i-Bungetsize, bp->bbuf-Bungetsize, > (size_t)(i+Bungetsize)); > bp->gbuf = bp->ebuf-i; > } > bp->icount = -i; > Index: src/libbio/bgetrune.c > =================================================================== > --- a/src/libbio/bgetrune.c > +++ b/src/libbio/bgetrune.c > @@ -40,13 +40,13 @@ > bp->runesize = 1; > return c; > } > - str[0] = c; > + str[0] = (char)c; > > for(i=1;;) { > c = Bgetc(bp); > if(c < 0) > return c; > - str[i++] = c; > + str[i++] = (char)c; > > if(fullrune(str, i)) { > bp->runesize = chartorune(&rune, str); > Index: src/libbio/bprint.c > =================================================================== > --- a/src/libbio/bprint.c > +++ b/src/libbio/bprint.c > @@ -49,7 +49,7 @@ > return 0; > > bp = f->farg; > - bp->ocount = (char*)f->to - (char*)f->stop; > + bp->ocount = (int)((char*)f->to - (char*)f->stop); > if(Bflush(bp) < 0) { > f->stop = nil; > f->to = nil; > @@ -76,7 +76,7 @@ > n = fmtvprint(&f, fmt, arg); > > if(f.stop != nil) > - bp->ocount = (char*)f.to - (char*)f.stop; > + bp->ocount = (int)((char*)f.to - (char*)f.stop); > > return n; > } > Index: src/libbio/bputc.c > =================================================================== > --- a/src/libbio/bputc.c > +++ b/src/libbio/bputc.c > @@ -35,7 +35,7 @@ > for(;;) { > i = bp->ocount; > if(i) { > - bp->ebuf[i++] = c; > + bp->ebuf[i++] = (unsigned char)c; > bp->ocount = i; > return 0; > } > Index: src/libbio/bputrune.c > =================================================================== > --- a/src/libbio/bputrune.c > +++ b/src/libbio/bputrune.c > @@ -35,9 +35,9 @@ > char str[UTFmax]; > int n; > > - rune = c; > + rune = (Rune)c; > if(rune < Runeself) { > - Bputc(bp, rune); > + Bputc(bp, (int)rune); > return 1; > } > n = runetochar(str, &rune); > Index: src/libbio/brdline.c > =================================================================== > --- a/src/libbio/brdline.c > +++ b/src/libbio/brdline.c > @@ -51,9 +51,9 @@ > * first try in remainder of buffer (gbuf doesn't change) > */ > ip = (char*)bp->ebuf - i; > - ep = memchr(ip, delim, i); > + ep = memchr(ip, delim, (size_t)i); > if(ep) { > - j = (ep - ip) + 1; > + j = (int)((ep - ip) + 1); > bp->rdline = j; > bp->icount += j; > return ip; > @@ -63,7 +63,7 @@ > * copy data to beginning of buffer > */ > if(i < bp->bsize) > - memmove(bp->bbuf, ip, i); > + memmove(bp->bbuf, ip, (size_t)i); > bp->gbuf = bp->bbuf; > > /* > @@ -71,12 +71,12 @@ > */ > ip = (char*)bp->bbuf + i; > while(i < bp->bsize) { > - j = read(bp->fid, ip, bp->bsize-i); > + j = (int)read(bp->fid, ip, (size_t)(bp->bsize-i)); > if(j <= 0) { > /* > * end of file with no delim > */ > - memmove(bp->ebuf-i, bp->bbuf, i); > + memmove(bp->ebuf-i, bp->bbuf, (size_t)i); > bp->rdline = i; > bp->icount = -i; > bp->gbuf = bp->ebuf-i; > @@ -84,7 +84,7 @@ > } > bp->offset += j; > i += j; > - ep = memchr(ip, delim, j); > + ep = memchr(ip, delim, (size_t)j); > if(ep) { > /* > * found in new piece > @@ -92,10 +92,10 @@ > */ > ip = (char*)bp->ebuf - i; > if(i < bp->bsize){ > - memmove(ip, bp->bbuf, i); > + memmove(ip, bp->bbuf, (size_t)i); > bp->gbuf = (unsigned char*)ip; > } > - j = (ep - (char*)bp->bbuf) + 1; > + j = (int)((ep - (char*)bp->bbuf) + 1); > bp->rdline = j; > bp->icount = j - i; > return ip; > Index: src/libbio/brdstr.c > =================================================================== > --- a/src/libbio/brdstr.c > +++ b/src/libbio/brdstr.c > @@ -37,14 +37,14 @@ > linelen = Blinelen(bp); > if(n == 0 && linelen == 0) > return nil; > - nq = realloc(q, n+linelen+1); > + nq = realloc(q, (size_t)(n+linelen+1)); > if(nq == nil) { > free(q); > return nil; > } > q = nq; > if(p != nil) { > - memmove(q+n, p, linelen); > + memmove(q+n, p, (size_t)linelen); > n += linelen; > if(nulldelim) > q[n-1] = '\0'; > Index: src/libbio/bread.c > =================================================================== > --- a/src/libbio/bread.c > +++ b/src/libbio/bread.c > @@ -41,11 +41,11 @@ > while(c > 0) { > n = -ic; > if(n > c) > - n = c; > + n = (int)c; > if(n == 0) { > if(bp->state != Bractive) > break; > - i = read(bp->fid, bp->bbuf, bp->bsize); > + i = (int)read(bp->fid, bp->bbuf, (size_t)bp->bsize); > if(i <= 0) { > bp->state = Bracteof; > if(i < 0) > @@ -55,13 +55,13 @@ > bp->gbuf = bp->bbuf; > bp->offset += i; > if(i < bp->bsize) { > - memmove(bp->ebuf-i, bp->bbuf, i); > + memmove(bp->ebuf-i, bp->bbuf, (size_t)i); > bp->gbuf = bp->ebuf-i; > } > ic = -i; > continue; > } > - memmove(p, bp->ebuf+ic, n); > + memmove(p, bp->ebuf+ic, (size_t)n); > c -= n; > ic += n; > p += n; > Index: src/libbio/bseek.c > =================================================================== > --- a/src/libbio/bseek.c > +++ b/src/libbio/bseek.c > @@ -62,9 +62,9 @@ > */ > if(base == 0) { > d = n - Boffset(bp); > - bufsz = bp->ebuf - bp->gbuf; > + bufsz = (int)(bp->ebuf - bp->gbuf); > if(-bufsz <= d && d <= bufsz){ > - bp->icount += d; > + bp->icount += (int)d; > if(d >= 0) { > if(bp->icount <= 0) > return n; > Index: src/libbio/bwrite.c > =================================================================== > --- a/src/libbio/bwrite.c > +++ b/src/libbio/bwrite.c > @@ -41,11 +41,11 @@ > while(c > 0) { > n = -oc; > if(n > c) > - n = c; > + n = (int)c; > if(n == 0) { > if(bp->state != Bwactive) > return Beof; > - i = write(bp->fid, bp->bbuf, bp->bsize); > + i = (int)write(bp->fid, bp->bbuf, > (size_t)bp->bsize); > if(i != bp->bsize) { > bp->state = Binactive; > return Beof; > @@ -54,7 +54,7 @@ > oc = -bp->bsize; > continue; > } > - memmove(bp->ebuf+oc, p, n); > + memmove(bp->ebuf+oc, p, (size_t)n); > oc += n; > c -= n; > p += n; > > > -- > > ---You received this message because you are subscribed to the Google Groups > "golang-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-dev+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > >
On Fri, Aug 2, 2013 at 5:04 PM, Dave Cheney <dave@cheney.net> wrote: > Update issue 5764 ? Thanks, done. Ian > On Sat, Aug 3, 2013 at 10:03 AM, <iant@golang.org> wrote: >> Reviewers: golang-dev1, >> >> Message: >> Hello golang-dev@googlegroups.com, >> >> I'd like you to review this change to >> https://go.googlecode.com/hg/ >> >> >> Description: >> libbio: add casts to remove -Wconversion warnings >> >> Please review this at https://codereview.appspot.com/12388043/ >> >> Affected files: >> src/libbio/bflush.c >> src/libbio/bgetc.c >> src/libbio/bgetrune.c >> src/libbio/bprint.c >> src/libbio/bputc.c >> src/libbio/bputrune.c >> src/libbio/brdline.c >> src/libbio/brdstr.c >> src/libbio/bread.c >> src/libbio/bseek.c >> src/libbio/bwrite.c >> >> >> Index: src/libbio/bflush.c >> =================================================================== >> --- a/src/libbio/bflush.c >> +++ b/src/libbio/bflush.c >> @@ -37,7 +37,7 @@ >> n = bp->bsize+bp->ocount; >> if(n == 0) >> return 0; >> - c = write(bp->fid, bp->bbuf, n); >> + c = (int)write(bp->fid, bp->bbuf, (size_t)n); >> if(n == c) { >> bp->offset += n; >> bp->ocount = -bp->bsize; >> Index: src/libbio/bgetc.c >> =================================================================== >> --- a/src/libbio/bgetc.c >> +++ b/src/libbio/bgetc.c >> @@ -49,7 +49,7 @@ >> * buffer to allow that many ungets. >> */ >> memmove(bp->bbuf-Bungetsize, bp->ebuf-Bungetsize, Bungetsize); >> - i = read(bp->fid, bp->bbuf, bp->bsize); >> + i = (int)read(bp->fid, bp->bbuf, (size_t)bp->bsize); >> bp->gbuf = bp->bbuf; >> if(i <= 0) { >> bp->state = Bracteof; >> @@ -58,7 +58,7 @@ >> return Beof; >> } >> if(i < bp->bsize) { >> - memmove(bp->ebuf-i-Bungetsize, bp->bbuf-Bungetsize, >> i+Bungetsize); >> + memmove(bp->ebuf-i-Bungetsize, bp->bbuf-Bungetsize, >> (size_t)(i+Bungetsize)); >> bp->gbuf = bp->ebuf-i; >> } >> bp->icount = -i; >> Index: src/libbio/bgetrune.c >> =================================================================== >> --- a/src/libbio/bgetrune.c >> +++ b/src/libbio/bgetrune.c >> @@ -40,13 +40,13 @@ >> bp->runesize = 1; >> return c; >> } >> - str[0] = c; >> + str[0] = (char)c; >> >> for(i=1;;) { >> c = Bgetc(bp); >> if(c < 0) >> return c; >> - str[i++] = c; >> + str[i++] = (char)c; >> >> if(fullrune(str, i)) { >> bp->runesize = chartorune(&rune, str); >> Index: src/libbio/bprint.c >> =================================================================== >> --- a/src/libbio/bprint.c >> +++ b/src/libbio/bprint.c >> @@ -49,7 +49,7 @@ >> return 0; >> >> bp = f->farg; >> - bp->ocount = (char*)f->to - (char*)f->stop; >> + bp->ocount = (int)((char*)f->to - (char*)f->stop); >> if(Bflush(bp) < 0) { >> f->stop = nil; >> f->to = nil; >> @@ -76,7 +76,7 @@ >> n = fmtvprint(&f, fmt, arg); >> >> if(f.stop != nil) >> - bp->ocount = (char*)f.to - (char*)f.stop; >> + bp->ocount = (int)((char*)f.to - (char*)f.stop); >> >> return n; >> } >> Index: src/libbio/bputc.c >> =================================================================== >> --- a/src/libbio/bputc.c >> +++ b/src/libbio/bputc.c >> @@ -35,7 +35,7 @@ >> for(;;) { >> i = bp->ocount; >> if(i) { >> - bp->ebuf[i++] = c; >> + bp->ebuf[i++] = (unsigned char)c; >> bp->ocount = i; >> return 0; >> } >> Index: src/libbio/bputrune.c >> =================================================================== >> --- a/src/libbio/bputrune.c >> +++ b/src/libbio/bputrune.c >> @@ -35,9 +35,9 @@ >> char str[UTFmax]; >> int n; >> >> - rune = c; >> + rune = (Rune)c; >> if(rune < Runeself) { >> - Bputc(bp, rune); >> + Bputc(bp, (int)rune); >> return 1; >> } >> n = runetochar(str, &rune); >> Index: src/libbio/brdline.c >> =================================================================== >> --- a/src/libbio/brdline.c >> +++ b/src/libbio/brdline.c >> @@ -51,9 +51,9 @@ >> * first try in remainder of buffer (gbuf doesn't change) >> */ >> ip = (char*)bp->ebuf - i; >> - ep = memchr(ip, delim, i); >> + ep = memchr(ip, delim, (size_t)i); >> if(ep) { >> - j = (ep - ip) + 1; >> + j = (int)((ep - ip) + 1); >> bp->rdline = j; >> bp->icount += j; >> return ip; >> @@ -63,7 +63,7 @@ >> * copy data to beginning of buffer >> */ >> if(i < bp->bsize) >> - memmove(bp->bbuf, ip, i); >> + memmove(bp->bbuf, ip, (size_t)i); >> bp->gbuf = bp->bbuf; >> >> /* >> @@ -71,12 +71,12 @@ >> */ >> ip = (char*)bp->bbuf + i; >> while(i < bp->bsize) { >> - j = read(bp->fid, ip, bp->bsize-i); >> + j = (int)read(bp->fid, ip, (size_t)(bp->bsize-i)); >> if(j <= 0) { >> /* >> * end of file with no delim >> */ >> - memmove(bp->ebuf-i, bp->bbuf, i); >> + memmove(bp->ebuf-i, bp->bbuf, (size_t)i); >> bp->rdline = i; >> bp->icount = -i; >> bp->gbuf = bp->ebuf-i; >> @@ -84,7 +84,7 @@ >> } >> bp->offset += j; >> i += j; >> - ep = memchr(ip, delim, j); >> + ep = memchr(ip, delim, (size_t)j); >> if(ep) { >> /* >> * found in new piece >> @@ -92,10 +92,10 @@ >> */ >> ip = (char*)bp->ebuf - i; >> if(i < bp->bsize){ >> - memmove(ip, bp->bbuf, i); >> + memmove(ip, bp->bbuf, (size_t)i); >> bp->gbuf = (unsigned char*)ip; >> } >> - j = (ep - (char*)bp->bbuf) + 1; >> + j = (int)((ep - (char*)bp->bbuf) + 1); >> bp->rdline = j; >> bp->icount = j - i; >> return ip; >> Index: src/libbio/brdstr.c >> =================================================================== >> --- a/src/libbio/brdstr.c >> +++ b/src/libbio/brdstr.c >> @@ -37,14 +37,14 @@ >> linelen = Blinelen(bp); >> if(n == 0 && linelen == 0) >> return nil; >> - nq = realloc(q, n+linelen+1); >> + nq = realloc(q, (size_t)(n+linelen+1)); >> if(nq == nil) { >> free(q); >> return nil; >> } >> q = nq; >> if(p != nil) { >> - memmove(q+n, p, linelen); >> + memmove(q+n, p, (size_t)linelen); >> n += linelen; >> if(nulldelim) >> q[n-1] = '\0'; >> Index: src/libbio/bread.c >> =================================================================== >> --- a/src/libbio/bread.c >> +++ b/src/libbio/bread.c >> @@ -41,11 +41,11 @@ >> while(c > 0) { >> n = -ic; >> if(n > c) >> - n = c; >> + n = (int)c; >> if(n == 0) { >> if(bp->state != Bractive) >> break; >> - i = read(bp->fid, bp->bbuf, bp->bsize); >> + i = (int)read(bp->fid, bp->bbuf, (size_t)bp->bsize); >> if(i <= 0) { >> bp->state = Bracteof; >> if(i < 0) >> @@ -55,13 +55,13 @@ >> bp->gbuf = bp->bbuf; >> bp->offset += i; >> if(i < bp->bsize) { >> - memmove(bp->ebuf-i, bp->bbuf, i); >> + memmove(bp->ebuf-i, bp->bbuf, (size_t)i); >> bp->gbuf = bp->ebuf-i; >> } >> ic = -i; >> continue; >> } >> - memmove(p, bp->ebuf+ic, n); >> + memmove(p, bp->ebuf+ic, (size_t)n); >> c -= n; >> ic += n; >> p += n; >> Index: src/libbio/bseek.c >> =================================================================== >> --- a/src/libbio/bseek.c >> +++ b/src/libbio/bseek.c >> @@ -62,9 +62,9 @@ >> */ >> if(base == 0) { >> d = n - Boffset(bp); >> - bufsz = bp->ebuf - bp->gbuf; >> + bufsz = (int)(bp->ebuf - bp->gbuf); >> if(-bufsz <= d && d <= bufsz){ >> - bp->icount += d; >> + bp->icount += (int)d; >> if(d >= 0) { >> if(bp->icount <= 0) >> return n; >> Index: src/libbio/bwrite.c >> =================================================================== >> --- a/src/libbio/bwrite.c >> +++ b/src/libbio/bwrite.c >> @@ -41,11 +41,11 @@ >> while(c > 0) { >> n = -oc; >> if(n > c) >> - n = c; >> + n = (int)c; >> if(n == 0) { >> if(bp->state != Bwactive) >> return Beof; >> - i = write(bp->fid, bp->bbuf, bp->bsize); >> + i = (int)write(bp->fid, bp->bbuf, >> (size_t)bp->bsize); >> if(i != bp->bsize) { >> bp->state = Binactive; >> return Beof; >> @@ -54,7 +54,7 @@ >> oc = -bp->bsize; >> continue; >> } >> - memmove(bp->ebuf+oc, p, n); >> + memmove(bp->ebuf+oc, p, (size_t)n); >> oc += n; >> c -= n; >> p += n; >> >> >> -- >> >> ---You received this message because you are subscribed to the Google Groups >> "golang-dev" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-dev+unsubscribe@googlegroups.com. >> For more options, visit https://groups.google.com/groups/opt_out. >> >>
LGTM Let's see what breaks. :-)
*** Submitted as https://code.google.com/p/go/source/detail?r=ec2c681e5f21 *** libbio: add casts to remove -Wconversion warnings Update issue 5764 R=golang-dev, dave, rsc CC=golang-dev https://codereview.appspot.com/12388043