]> Cypherpunks repositories - gostls13.git/commitdiff
libbio: add casts to remove -Wconversion warnings
authorIan Lance Taylor <iant@golang.org>
Sat, 3 Aug 2013 18:36:47 +0000 (11:36 -0700)
committerIan Lance Taylor <iant@golang.org>
Sat, 3 Aug 2013 18:36:47 +0000 (11:36 -0700)
Update #5764

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/12388043

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 8a071cb5cb2261342d45b3feb89b553e2e84b965..ea7ae2c62b15e28223e36ff783789f8c4e0b6773 100644 (file)
@@ -37,7 +37,7 @@ Bflush(Biobuf *bp)
                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 52ed241f9b6fa485639f57e987dfbd409382e117..4ddfba15269ee7dc63bf347dbfeb92ef52008128 100644 (file)
@@ -49,7 +49,7 @@ loop:
         * 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 @@ loop:
                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 1538f3ea7417d36058e83242c5b917a84dcbd0a1..dd59eb38ffb2d25ccee6eaff957ec09f0bd472c7 100644 (file)
@@ -40,13 +40,13 @@ Bgetrune(Biobuf *bp)
                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 b5d3e9ece01597e2581f3d851ace25e3cab06931..301dc0c7f34c87a192db5cf9be2a9a8bdc23ec41 100644 (file)
@@ -49,7 +49,7 @@ bflush(Fmt *f)
                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 @@ Bvprint(Biobuf *bp, char *fmt, va_list arg)
        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 4cdbe8f7ac961cdf652907a191bc5b53f7ab0572..ec98144a477d840187e4e85c8899c0d569bde2f4 100644 (file)
@@ -35,7 +35,7 @@ Bputc(Biobuf *bp, int c)
        for(;;) {
                i = bp->ocount;
                if(i) {
-                       bp->ebuf[i++] = c;
+                       bp->ebuf[i++] = (unsigned char)c;
                        bp->ocount = i;
                        return 0;
                }
index e46f3c7101c73175b396c301fe39b9d408cb9d02..34f4fffdd83b5a82a25174aff5fd9773a7490454 100644 (file)
@@ -35,9 +35,9 @@ Bputrune(Biobuf *bp, long c)
        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 a02bf106d5f0cd280fdbcfd98d4a7b5827fde2e9..1c3093ecf3a69e0987e303d225a4a1190f2c4d31 100644 (file)
@@ -51,9 +51,9 @@ Brdline(Biobuf *bp, int delim)
         * 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 @@ Brdline(Biobuf *bp, int delim)
         * 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 @@ Brdline(Biobuf *bp, int delim)
         */
        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 @@ Brdline(Biobuf *bp, int delim)
                }
                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 @@ Brdline(Biobuf *bp, int delim)
                         */
                        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 0398ab07bd08cfb9284008f9354891e5663f88de..6a90cf69b2a7adc76d92062697844a923e0bac5a 100644 (file)
@@ -37,14 +37,14 @@ Brdstr(Biobuf *bp, int delim, int nulldelim)
                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 5cf9a05c867ade3c5029ccb0efa5b45e87bafecd..343a0bf29bee1e7497b4a6b68cb4ad8ac43830c9 100644 (file)
@@ -41,11 +41,11 @@ Bread(Biobuf *bp, void *ap, long count)
        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 @@ Bread(Biobuf *bp, void *ap, long count)
                        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 29149810895d3f5c27019bca38f4cc9f34ea1b0b..eb426ccfc99e1336c29f991921af1f9ac1cbecfb 100644 (file)
@@ -62,9 +62,9 @@ Bseek(Biobuf *bp, vlong offset, int base)
                 */
                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 daed161cbf2d8c03956cd4e2d3382e658e80bf64..8b9943ab086f969fac4d3bcdc5b1f60f808ecf38 100644 (file)
@@ -41,11 +41,11 @@ Bwrite(Biobuf *bp, void *ap, long count)
        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 @@ Bwrite(Biobuf *bp, void *ap, long count)
                        oc = -bp->bsize;
                        continue;
                }
-               memmove(bp->ebuf+oc, p, n);
+               memmove(bp->ebuf+oc, p, (size_t)n);
                oc += n;
                c -= n;
                p += n;