mirror of
https://github.com/golang/go
synced 2024-11-21 18:34:44 -07:00
changes &x -> x[0:] for array to slice conversion
R=gri CC=golang-dev https://golang.org/cl/1326042
This commit is contained in:
parent
7ee6d44e4f
commit
bb84f4b5d2
@ -1035,7 +1035,7 @@ func isTextFile(path string) bool {
|
||||
defer f.Close()
|
||||
|
||||
var buf [1024]byte
|
||||
n, err := f.Read(&buf)
|
||||
n, err := f.Read(buf[0:])
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ func (b *Buffer) grow(n int) int {
|
||||
if len(b.buf)+n > cap(b.buf) {
|
||||
var buf []byte
|
||||
if b.buf == nil && n <= len(b.bootstrap) {
|
||||
buf = &b.bootstrap
|
||||
buf = b.bootstrap[0:]
|
||||
} else {
|
||||
// not enough space anywhere
|
||||
buf = make([]byte, 2*cap(b.buf)+n)
|
||||
@ -181,7 +181,7 @@ func (b *Buffer) WriteRune(r int) (n int, err os.Error) {
|
||||
b.WriteByte(byte(r))
|
||||
return 1, nil
|
||||
}
|
||||
n = utf8.EncodeRune(r, &b.runeBytes)
|
||||
n = utf8.EncodeRune(r, b.runeBytes[0:])
|
||||
b.Write(b.runeBytes[0:n])
|
||||
return n, nil
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ var initDecoderTests = []*InitDecoderTest{
|
||||
|
||||
// Static Huffman codes (RFC 1951 section 3.2.6)
|
||||
&InitDecoderTest{
|
||||
&fixedHuffmanBits,
|
||||
fixedHuffmanBits[0:],
|
||||
fixedHuffmanDecoder,
|
||||
true,
|
||||
},
|
||||
|
@ -126,7 +126,7 @@ func (w *huffmanBitWriter) flushBits() {
|
||||
w.bytes[n] = byte(bits)
|
||||
w.bytes[n+1] = byte(bits >> 8)
|
||||
if n += 2; n >= len(w.bytes) {
|
||||
_, w.err = w.w.Write(&w.bytes)
|
||||
_, w.err = w.w.Write(w.bytes[0:])
|
||||
n = 0
|
||||
}
|
||||
w.nbytes = n
|
||||
|
@ -290,7 +290,7 @@ func (f *decompressor) readHuffman() os.Error {
|
||||
for i := nclen; i < len(codeOrder); i++ {
|
||||
f.codebits[codeOrder[i]] = 0
|
||||
}
|
||||
if !f.h1.init(&f.codebits) {
|
||||
if !f.h1.init(f.codebits[0:]) {
|
||||
return CorruptInputError(f.roffset)
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ func testFileLevel(t *testing.T, fn string, level int) {
|
||||
defer zlibw.Close()
|
||||
var b [1024]byte
|
||||
for {
|
||||
n, err0 := raw.Read(&b)
|
||||
n, err0 := raw.Read(b[0:])
|
||||
if err0 != nil && err0 != os.EOF {
|
||||
t.Errorf("%s (level=%d): %v", fn, level, err0)
|
||||
return
|
||||
|
@ -67,7 +67,7 @@ func TestECBEncrypter(t *testing.T) {
|
||||
for frag := 0; frag < 2; frag++ {
|
||||
c := &IncCipher{block, 0, true}
|
||||
b.Reset()
|
||||
r := bytes.NewBuffer(&plain)
|
||||
r := bytes.NewBuffer(plain[0:])
|
||||
w := NewECBEncrypter(c, b)
|
||||
|
||||
// copy plain into w in increasingly large chunks: 1, 1, 2, 4, 8, ...
|
||||
@ -100,7 +100,7 @@ func TestECBEncrypter(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
|
||||
if string(data) != string(&crypt) {
|
||||
if string(data) != string(crypt[0:]) {
|
||||
t.Errorf("block=%d frag=%d: want %x got %x", block, frag, data, crypt)
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ func testXorWriter(t *testing.T, maxio int) {
|
||||
for frag := 0; frag < 2; frag++ {
|
||||
test := fmt.Sprintf("block=%d frag=%d maxio=%d", block, frag, maxio)
|
||||
b.Reset()
|
||||
r := bytes.NewBuffer(&plain)
|
||||
r := bytes.NewBuffer(plain[0:])
|
||||
s := newIncStream(block)
|
||||
w := newXorWriter(s, b)
|
||||
|
||||
|
@ -5,11 +5,11 @@
|
||||
package blowfish
|
||||
|
||||
func expandKey(key []byte, c *Cipher) {
|
||||
copy(&c.p, &p)
|
||||
copy(&c.s0, &s0)
|
||||
copy(&c.s1, &s1)
|
||||
copy(&c.s2, &s2)
|
||||
copy(&c.s3, &s3)
|
||||
copy(c.p[0:], p[0:])
|
||||
copy(c.s0[0:], s0[0:])
|
||||
copy(c.s1[0:], s1[0:])
|
||||
copy(c.s2[0:], s2[0:])
|
||||
copy(c.s3[0:], s3[0:])
|
||||
|
||||
j := 0
|
||||
for i := 0; i < 18; i++ {
|
||||
|
@ -71,9 +71,9 @@ func (c *Cipher) Decrypt(src, dst []byte) {
|
||||
// Reset zeros the key data, so that it will no longer
|
||||
// appear in the process's memory.
|
||||
func (c *Cipher) Reset() {
|
||||
zero(&c.p)
|
||||
zero(&c.s0)
|
||||
zero(&c.s1)
|
||||
zero(&c.s2)
|
||||
zero(&c.s3)
|
||||
zero(c.p[0:])
|
||||
zero(c.s0[0:])
|
||||
zero(c.s1[0:])
|
||||
zero(c.s2[0:])
|
||||
zero(c.s3[0:])
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ func (d *digest) Write(p []byte) (nn int, err os.Error) {
|
||||
}
|
||||
d.nx += n
|
||||
if d.nx == _Chunk {
|
||||
_Block(d, &d.x)
|
||||
_Block(d, d.x[0:])
|
||||
d.nx = 0
|
||||
}
|
||||
p = p[n:]
|
||||
|
@ -60,7 +60,7 @@ func (d *digest) Write(p []byte) (nn int, err os.Error) {
|
||||
}
|
||||
d.nx += n
|
||||
if d.nx == _Chunk {
|
||||
_Block(d, &d.x)
|
||||
_Block(d, d.x[0:])
|
||||
d.nx = 0
|
||||
}
|
||||
p = p[n:]
|
||||
|
@ -81,15 +81,15 @@ func (r *reader) Read(b []byte) (n int, err os.Error) {
|
||||
|
||||
for len(b) > 0 {
|
||||
if r.budget == 0 {
|
||||
_, err := io.ReadFull(r.entropy, &r.seed)
|
||||
_, err := io.ReadFull(r.entropy, r.seed[0:])
|
||||
if err != nil {
|
||||
return n - len(b), err
|
||||
}
|
||||
_, err = io.ReadFull(r.entropy, &r.key)
|
||||
_, err = io.ReadFull(r.entropy, r.key[0:])
|
||||
if err != nil {
|
||||
return n - len(b), err
|
||||
}
|
||||
r.cipher, err = aes.NewCipher(&r.key)
|
||||
r.cipher, err = aes.NewCipher(r.key[0:])
|
||||
if err != nil {
|
||||
return n - len(b), err
|
||||
}
|
||||
@ -112,17 +112,17 @@ func (r *reader) Read(b []byte) (n int, err os.Error) {
|
||||
r.time[5] = byte(ns >> 16)
|
||||
r.time[6] = byte(ns >> 8)
|
||||
r.time[7] = byte(ns)
|
||||
r.cipher.Encrypt(&r.time, &r.time)
|
||||
r.cipher.Encrypt(r.time[0:], r.time[0:])
|
||||
for i := 0; i < aes.BlockSize; i++ {
|
||||
r.dst[i] = r.time[i] ^ r.seed[i]
|
||||
}
|
||||
r.cipher.Encrypt(&r.dst, &r.dst)
|
||||
r.cipher.Encrypt(r.dst[0:], r.dst[0:])
|
||||
for i := 0; i < aes.BlockSize; i++ {
|
||||
r.seed[i] = r.time[i] ^ r.dst[i]
|
||||
}
|
||||
r.cipher.Encrypt(&r.seed, &r.seed)
|
||||
r.cipher.Encrypt(r.seed[0:], r.seed[0:])
|
||||
|
||||
m := copy(b, &r.dst)
|
||||
m := copy(b, r.dst[0:])
|
||||
b = b[m:]
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ func (d *digest) Write(p []byte) (nn int, err os.Error) {
|
||||
}
|
||||
d.nx += n
|
||||
if d.nx == BlockSize {
|
||||
_Block(d, &d.x)
|
||||
_Block(d, d.x[0:])
|
||||
d.nx = 0
|
||||
}
|
||||
p = p[n:]
|
||||
|
@ -62,7 +62,7 @@ func (d *digest) Write(p []byte) (nn int, err os.Error) {
|
||||
}
|
||||
d.nx += n
|
||||
if d.nx == _Chunk {
|
||||
_Block(d, &d.x)
|
||||
_Block(d, d.x[0:])
|
||||
d.nx = 0
|
||||
}
|
||||
p = p[n:]
|
||||
|
@ -104,7 +104,7 @@ func (d *digest) Write(p []byte) (nn int, err os.Error) {
|
||||
}
|
||||
d.nx += n
|
||||
if d.nx == _Chunk {
|
||||
_Block(d, &d.x)
|
||||
_Block(d, d.x[0:])
|
||||
d.nx = 0
|
||||
}
|
||||
p = p[n:]
|
||||
|
@ -104,7 +104,7 @@ func (d *digest) Write(p []byte) (nn int, err os.Error) {
|
||||
}
|
||||
d.nx += n
|
||||
if d.nx == _Chunk {
|
||||
_Block(d, &d.x)
|
||||
_Block(d, d.x[0:])
|
||||
d.nx = 0
|
||||
}
|
||||
p = p[n:]
|
||||
|
@ -171,7 +171,7 @@ func (hc *halfConn) decrypt(b *block) (bool, alert) {
|
||||
remoteMAC := payload[n:]
|
||||
|
||||
hc.mac.Reset()
|
||||
hc.mac.Write(&hc.seq)
|
||||
hc.mac.Write(hc.seq[0:])
|
||||
hc.incSeq()
|
||||
hc.mac.Write(b.data)
|
||||
|
||||
@ -188,7 +188,7 @@ func (hc *halfConn) encrypt(b *block) (bool, alert) {
|
||||
// mac
|
||||
if hc.mac != nil {
|
||||
hc.mac.Reset()
|
||||
hc.mac.Write(&hc.seq)
|
||||
hc.mac.Write(hc.seq[0:])
|
||||
hc.incSeq()
|
||||
hc.mac.Write(b.data)
|
||||
mac := hc.mac.Sum()
|
||||
|
@ -166,7 +166,7 @@ func NewFile(r io.ReaderAt) (*File, os.Error) {
|
||||
sr := io.NewSectionReader(r, 0, 1<<63-1)
|
||||
// Read and decode ELF identifier
|
||||
var ident [16]uint8
|
||||
if _, err := r.ReadAt(&ident, 0); err != nil {
|
||||
if _, err := r.ReadAt(ident[0:], 0); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if ident[0] != '\x7f' || ident[1] != 'E' || ident[2] != 'L' || ident[3] != 'F' {
|
||||
|
@ -117,7 +117,7 @@ func (e *encoder) Write(p []byte) (n int, err os.Error) {
|
||||
if e.nbuf < 4 {
|
||||
return
|
||||
}
|
||||
nout := Encode(&e.out, &e.buf)
|
||||
nout := Encode(e.out[0:], e.buf[0:])
|
||||
if _, e.err = e.w.Write(e.out[0:nout]); e.err != nil {
|
||||
return n, e.err
|
||||
}
|
||||
@ -132,7 +132,7 @@ func (e *encoder) Write(p []byte) (n int, err os.Error) {
|
||||
}
|
||||
nn -= nn % 4
|
||||
if nn > 0 {
|
||||
nout := Encode(&e.out, p[0:nn])
|
||||
nout := Encode(e.out[0:], p[0:nn])
|
||||
if _, e.err = e.w.Write(e.out[0:nout]); e.err != nil {
|
||||
return n, e.err
|
||||
}
|
||||
@ -155,7 +155,7 @@ func (e *encoder) Write(p []byte) (n int, err os.Error) {
|
||||
func (e *encoder) Close() os.Error {
|
||||
// If there's anything left in the buffer, flush it out
|
||||
if e.err == nil && e.nbuf > 0 {
|
||||
nout := Encode(&e.out, e.buf[0:e.nbuf])
|
||||
nout := Encode(e.out[0:], e.buf[0:e.nbuf])
|
||||
e.nbuf = 0
|
||||
_, e.err = e.w.Write(e.out[0:nout])
|
||||
}
|
||||
@ -275,10 +275,10 @@ func (d *decoder) Read(p []byte) (n int, err os.Error) {
|
||||
// Decode leftover input from last read.
|
||||
var nn, nsrc, ndst int
|
||||
if d.nbuf > 0 {
|
||||
ndst, nsrc, d.err = Decode(&d.outbuf, d.buf[0:d.nbuf], d.readErr != nil)
|
||||
ndst, nsrc, d.err = Decode(d.outbuf[0:], d.buf[0:d.nbuf], d.readErr != nil)
|
||||
if ndst > 0 {
|
||||
d.out = d.outbuf[0:ndst]
|
||||
d.nbuf = copy(&d.buf, d.buf[nsrc:d.nbuf])
|
||||
d.nbuf = copy(d.buf[0:], d.buf[nsrc:d.nbuf])
|
||||
continue // copy out and return
|
||||
}
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ func (e *encoder) Write(p []byte) (n int, err os.Error) {
|
||||
if e.nbuf < 3 {
|
||||
return
|
||||
}
|
||||
e.enc.Encode(&e.out, &e.buf)
|
||||
e.enc.Encode(e.out[0:], e.buf[0:])
|
||||
if _, e.err = e.w.Write(e.out[0:4]); e.err != nil {
|
||||
return n, e.err
|
||||
}
|
||||
@ -147,7 +147,7 @@ func (e *encoder) Write(p []byte) (n int, err os.Error) {
|
||||
}
|
||||
nn -= nn % 3
|
||||
if nn > 0 {
|
||||
e.enc.Encode(&e.out, p[0:nn])
|
||||
e.enc.Encode(e.out[0:], p[0:nn])
|
||||
if _, e.err = e.w.Write(e.out[0 : nn/3*4]); e.err != nil {
|
||||
return n, e.err
|
||||
}
|
||||
@ -170,7 +170,7 @@ func (e *encoder) Write(p []byte) (n int, err os.Error) {
|
||||
func (e *encoder) Close() os.Error {
|
||||
// If there's anything left in the buffer, flush it out
|
||||
if e.err == nil && e.nbuf > 0 {
|
||||
e.enc.Encode(&e.out, e.buf[0:e.nbuf])
|
||||
e.enc.Encode(e.out[0:], e.buf[0:e.nbuf])
|
||||
e.nbuf = 0
|
||||
_, e.err = e.w.Write(e.out[0:4])
|
||||
}
|
||||
@ -301,7 +301,7 @@ func (d *decoder) Read(p []byte) (n int, err os.Error) {
|
||||
nr := d.nbuf / 4 * 4
|
||||
nw := d.nbuf / 4 * 3
|
||||
if nw > len(p) {
|
||||
nw, d.end, d.err = d.enc.decode(&d.outbuf, d.buf[0:nr])
|
||||
nw, d.end, d.err = d.enc.decode(d.outbuf[0:], d.buf[0:nr])
|
||||
d.out = d.outbuf[0:nw]
|
||||
n = copy(p, d.out)
|
||||
d.out = d.out[n:]
|
||||
|
@ -177,7 +177,7 @@ func (e *encoder) Write(p []byte) (n int, err os.Error) {
|
||||
if e.nbuf < 52 {
|
||||
return
|
||||
}
|
||||
nout := Encode(&e.out, &e.buf)
|
||||
nout := Encode(e.out[0:], e.buf[0:])
|
||||
if _, e.err = e.w.Write(e.out[0:nout]); e.err != nil {
|
||||
return n, e.err
|
||||
}
|
||||
@ -191,7 +191,7 @@ func (e *encoder) Write(p []byte) (n int, err os.Error) {
|
||||
nn = len(p) / 52 * 52
|
||||
}
|
||||
if nn > 0 {
|
||||
nout := Encode(&e.out, p[0:nn])
|
||||
nout := Encode(e.out[0:], p[0:nn])
|
||||
if _, e.err = e.w.Write(e.out[0:nout]); e.err != nil {
|
||||
return n, e.err
|
||||
}
|
||||
@ -212,7 +212,7 @@ func (e *encoder) Write(p []byte) (n int, err os.Error) {
|
||||
func (e *encoder) Close() os.Error {
|
||||
// If there's anything left in the buffer, flush it out
|
||||
if e.err == nil && e.nbuf > 0 {
|
||||
nout := Encode(&e.out, e.buf[0:e.nbuf])
|
||||
nout := Encode(e.out[0:], e.buf[0:e.nbuf])
|
||||
e.nbuf = 0
|
||||
_, e.err = e.w.Write(e.out[0:nout])
|
||||
}
|
||||
@ -265,12 +265,12 @@ func (d *decoder) Read(p []byte) (n int, err os.Error) {
|
||||
if nl < 0 {
|
||||
continue
|
||||
}
|
||||
nn, d.err = Decode(&d.outbuf, d.buf[0:nl+1])
|
||||
nn, d.err = Decode(d.outbuf[0:], d.buf[0:nl+1])
|
||||
if e, ok := d.err.(CorruptInputError); ok {
|
||||
d.err = CorruptInputError(int64(e) + d.off)
|
||||
}
|
||||
d.out = d.outbuf[0:nn]
|
||||
d.nbuf = copy(&d.buf, d.buf[nl+1:d.nbuf])
|
||||
d.nbuf = copy(d.buf[0:], d.buf[nl+1:d.nbuf])
|
||||
d.off += int64(nl + 1)
|
||||
}
|
||||
panic("unreacahable")
|
||||
|
@ -95,7 +95,7 @@ func Run(argv0 string, argv, envv []string, dir string, stdin, stdout, stderr in
|
||||
}
|
||||
|
||||
// Run command.
|
||||
p.Pid, err = os.ForkExec(argv0, argv, envv, dir, &fd)
|
||||
p.Pid, err = os.ForkExec(argv0, argv, envv, dir, fd[0:])
|
||||
if err != nil {
|
||||
goto Error
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ func (f *fmt) fmt_boolean(v bool) {
|
||||
// integer; interprets prec but not wid. Once formatted, result is sent to pad()
|
||||
// and then flags are cleared.
|
||||
func (f *fmt) integer(a int64, base uint64, signedness bool, digits string) {
|
||||
var buf []byte = &f.intbuf
|
||||
var buf []byte = f.intbuf[0:]
|
||||
negative := signedness == signed && a < 0
|
||||
if negative {
|
||||
a = -a
|
||||
|
@ -201,7 +201,7 @@ func (p *pp) add(c int) {
|
||||
if c < utf8.RuneSelf {
|
||||
p.buf.WriteByte(byte(c))
|
||||
} else {
|
||||
w := utf8.EncodeRune(c, &p.runeBuf)
|
||||
w := utf8.EncodeRune(c, p.runeBuf[0:])
|
||||
p.buf.Write(p.runeBuf[0:w])
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ func (r readRune) ReadRune() (rune int, size int, err os.Error) {
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
if !utf8.FullRune(&r.buf) {
|
||||
if !utf8.FullRune(r.buf[0:]) {
|
||||
continue
|
||||
}
|
||||
if c, w := utf8.DecodeRune(r.buf[0:size]); w == size {
|
||||
|
@ -709,7 +709,7 @@ func (p *printer) writeWhitespace(n int) {
|
||||
fallthrough
|
||||
default:
|
||||
data[0] = byte(ch)
|
||||
p.write(&data)
|
||||
p.write(data[0:])
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ func serveFileInternal(c *Conn, r *Request, name string, redirect bool) {
|
||||
} else {
|
||||
// read first chunk to decide between utf-8 text and binary
|
||||
var buf [1024]byte
|
||||
n, _ := io.ReadFull(f, &buf)
|
||||
n, _ := io.ReadFull(f, buf[0:])
|
||||
b := buf[0:n]
|
||||
if isText(b) {
|
||||
c.SetHeader("Content-Type", "text-plain; charset=utf-8")
|
||||
|
@ -248,8 +248,8 @@ func (s *pollServer) Run() {
|
||||
}
|
||||
if fd == s.pr.Fd() {
|
||||
// Drain our wakeup pipe.
|
||||
for nn, _ := s.pr.Read(&scratch); nn > 0; {
|
||||
nn, _ = s.pr.Read(&scratch)
|
||||
for nn, _ := s.pr.Read(scratch[0:]); nn > 0; {
|
||||
nn, _ = s.pr.Read(scratch[0:])
|
||||
}
|
||||
// Read from channels
|
||||
for fd, ok := <-s.cr; ok; fd, ok = <-s.cr {
|
||||
@ -271,7 +271,7 @@ func (s *pollServer) Run() {
|
||||
|
||||
var wakeupbuf [1]byte
|
||||
|
||||
func (s *pollServer) Wakeup() { s.pw.Write(&wakeupbuf) }
|
||||
func (s *pollServer) Wakeup() { s.pw.Write(wakeupbuf[0:]) }
|
||||
|
||||
func (s *pollServer) WaitRead(fd *netFD) {
|
||||
s.cr <- fd
|
||||
|
@ -46,7 +46,7 @@ func (p *pollster) AddFD(fd int, mode int, repeat bool) os.Error {
|
||||
}
|
||||
syscall.SetKevent(ev, fd, kmode, flags)
|
||||
|
||||
n, e := syscall.Kevent(p.kq, &events, &events, nil)
|
||||
n, e := syscall.Kevent(p.kq, events[0:], events[0:], nil)
|
||||
if e != 0 {
|
||||
return os.NewSyscallError("kevent", e)
|
||||
}
|
||||
@ -72,7 +72,7 @@ func (p *pollster) DelFD(fd int, mode int) {
|
||||
// EV_RECEIPT - generate fake EV_ERROR as result of add,
|
||||
// rather than waiting for real event
|
||||
syscall.SetKevent(ev, fd, kmode, syscall.EV_DELETE|syscall.EV_RECEIPT)
|
||||
syscall.Kevent(p.kq, &events, &events, nil)
|
||||
syscall.Kevent(p.kq, events[0:], events[0:], nil)
|
||||
}
|
||||
|
||||
func (p *pollster) WaitFD(nsec int64) (fd int, mode int, err os.Error) {
|
||||
@ -84,7 +84,7 @@ func (p *pollster) WaitFD(nsec int64) (fd int, mode int, err os.Error) {
|
||||
}
|
||||
*t = syscall.NsecToTimespec(nsec)
|
||||
}
|
||||
nn, e := syscall.Kevent(p.kq, nil, &p.eventbuf, t)
|
||||
nn, e := syscall.Kevent(p.kq, nil, p.eventbuf[0:], t)
|
||||
if e != 0 {
|
||||
if e == syscall.EINTR {
|
||||
continue
|
||||
|
@ -113,9 +113,9 @@ func (p *pollster) WaitFD(nsec int64) (fd int, mode int, err os.Error) {
|
||||
if nsec > 0 {
|
||||
msec = int((nsec + 1e6 - 1) / 1e6)
|
||||
}
|
||||
n, e := syscall.EpollWait(p.epfd, &evarray, msec)
|
||||
n, e := syscall.EpollWait(p.epfd, evarray[0:], msec)
|
||||
for e == syscall.EAGAIN || e == syscall.EINTR {
|
||||
n, e = syscall.EpollWait(p.epfd, &evarray, msec)
|
||||
n, e = syscall.EpollWait(p.epfd, evarray[0:], msec)
|
||||
}
|
||||
if e != 0 {
|
||||
return -1, 0, os.NewSyscallError("epoll_wait", e)
|
||||
|
@ -103,9 +103,9 @@ func getip(fd int, remote bool) (ip []byte, port int, ok bool) {
|
||||
}
|
||||
switch sa := sa.(type) {
|
||||
case *syscall.SockaddrInet4:
|
||||
return &sa.Addr, sa.Port, true
|
||||
return sa.Addr[0:], sa.Port, true
|
||||
case *syscall.SockaddrInet6:
|
||||
return &sa.Addr, sa.Port, true
|
||||
return sa.Addr[0:], sa.Port, true
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ func runEcho(fd io.ReadWriter, done chan<- int) {
|
||||
var buf [1024]byte
|
||||
|
||||
for {
|
||||
n, err := fd.Read(&buf)
|
||||
n, err := fd.Read(buf[0:])
|
||||
if err != nil || n == 0 {
|
||||
break
|
||||
}
|
||||
@ -74,7 +74,7 @@ func connect(t *testing.T, network, addr string, isEmpty bool) {
|
||||
t.Fatalf("fd.Write(%q) = %d, %v", b, n, err1)
|
||||
}
|
||||
|
||||
n, err1 = fd.Read(&b1)
|
||||
n, err1 = fd.Read(b1[0:])
|
||||
if n != len(b) || err1 != nil {
|
||||
t.Fatalf("fd.Read() = %d, %v (want %d, nil)", n, err1, len(b))
|
||||
}
|
||||
@ -126,7 +126,7 @@ func runPacket(t *testing.T, network, addr string, listening chan<- string, done
|
||||
c.SetReadTimeout(10e6) // 10ms
|
||||
var buf [1000]byte
|
||||
for {
|
||||
n, addr, err := c.ReadFrom(&buf)
|
||||
n, addr, err := c.ReadFrom(buf[0:])
|
||||
if e, ok := err.(Error); ok && e.Timeout() {
|
||||
if done <- 1 {
|
||||
break
|
||||
|
@ -155,9 +155,9 @@ func (e *UnknownSocketError) String() string {
|
||||
func sockaddrToString(sa syscall.Sockaddr) (name string, err os.Error) {
|
||||
switch a := sa.(type) {
|
||||
case *syscall.SockaddrInet4:
|
||||
return joinHostPort(IP(&a.Addr).String(), itoa(a.Port)), nil
|
||||
return joinHostPort(IP(a.Addr[0:]).String(), itoa(a.Port)), nil
|
||||
case *syscall.SockaddrInet6:
|
||||
return joinHostPort(IP(&a.Addr).String(), itoa(a.Port)), nil
|
||||
return joinHostPort(IP(a.Addr[0:]).String(), itoa(a.Port)), nil
|
||||
case *syscall.SockaddrUnix:
|
||||
return a.Name, nil
|
||||
}
|
||||
|
@ -23,9 +23,9 @@ func testTimeout(t *testing.T, network, addr string, readFrom bool) {
|
||||
var n int
|
||||
var err1 os.Error
|
||||
if readFrom {
|
||||
n, _, err1 = fd.(PacketConn).ReadFrom(&b)
|
||||
n, _, err1 = fd.(PacketConn).ReadFrom(b[0:])
|
||||
} else {
|
||||
n, err1 = fd.Read(&b)
|
||||
n, err1 = fd.Read(b[0:])
|
||||
}
|
||||
t1 := time.Nanoseconds()
|
||||
what := "Read"
|
||||
|
@ -57,7 +57,7 @@ func (file *File) Readdirnames(count int) (names []string, err Error) {
|
||||
continue
|
||||
}
|
||||
bytes := (*[len(dirent.Name)]byte)(unsafe.Pointer(&dirent.Name[0]))
|
||||
var name = string(bytes[0:clen(bytes)])
|
||||
var name = string(bytes[0:clen(bytes[0:])])
|
||||
if name == "." || name == ".." { // Useless names
|
||||
continue
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ func Pipe() (r *File, w *File, err Error) {
|
||||
|
||||
// See ../syscall/exec.go for description of lock.
|
||||
syscall.ForkLock.RLock()
|
||||
e := syscall.Pipe(&p)
|
||||
e := syscall.Pipe(p[0:])
|
||||
if e != 0 {
|
||||
syscall.ForkLock.RUnlock()
|
||||
return nil, nil, NewSyscallError("pipe", e)
|
||||
@ -418,7 +418,7 @@ func Chtimes(name string, atime_ns int64, mtime_ns int64) Error {
|
||||
var utimes [2]syscall.Timeval
|
||||
utimes[0] = syscall.NsecToTimeval(atime_ns)
|
||||
utimes[1] = syscall.NsecToTimeval(mtime_ns)
|
||||
if e := syscall.Utimes(name, &utimes); e != 0 {
|
||||
if e := syscall.Utimes(name, utimes[0:]); e != 0 {
|
||||
return &PathError{"chtimes", name, Errno(e)}
|
||||
}
|
||||
return nil
|
||||
|
@ -42,7 +42,7 @@ func size(name string, t *testing.T) int64 {
|
||||
var buf [100]byte
|
||||
len := 0
|
||||
for {
|
||||
n, e := file.Read(&buf)
|
||||
n, e := file.Read(buf[0:])
|
||||
len += n
|
||||
if e == EOF {
|
||||
break
|
||||
|
@ -16,7 +16,7 @@ func Hostname() (name string, err Error) {
|
||||
defer f.Close()
|
||||
|
||||
var buf [512]byte // Enough for a DNS name.
|
||||
n, err := f.Read(&buf)
|
||||
n, err := f.Read(buf[0:])
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ func ParseGitBinary(raw []byte) (Diff, os.Error) {
|
||||
return nil, err
|
||||
}
|
||||
var buf [1]byte
|
||||
m, err := z.Read(&buf)
|
||||
m, err := z.Read(buf[0:])
|
||||
if m != 0 || err != os.EOF {
|
||||
return nil, os.NewError("Git binary literal longer than expected")
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ var strings = [...]string{"", "Hello", "foo", "bar", "foo", "f00", "%*&^*&^&", "
|
||||
|
||||
func TestSortIntArray(t *testing.T) {
|
||||
data := ints
|
||||
a := IntArray(&data)
|
||||
a := IntArray(data[0:])
|
||||
Sort(a)
|
||||
if !IsSorted(a) {
|
||||
t.Errorf("sorted %v", ints)
|
||||
@ -28,7 +28,7 @@ func TestSortIntArray(t *testing.T) {
|
||||
|
||||
func TestSortFloatArray(t *testing.T) {
|
||||
data := floats
|
||||
a := FloatArray(&data)
|
||||
a := FloatArray(data[0:])
|
||||
Sort(a)
|
||||
if !IsSorted(a) {
|
||||
t.Errorf("sorted %v", floats)
|
||||
@ -38,7 +38,7 @@ func TestSortFloatArray(t *testing.T) {
|
||||
|
||||
func TestSortStringArray(t *testing.T) {
|
||||
data := strings
|
||||
a := StringArray(&data)
|
||||
a := StringArray(data[0:])
|
||||
Sort(a)
|
||||
if !IsSorted(a) {
|
||||
t.Errorf("sorted %v", strings)
|
||||
@ -48,8 +48,8 @@ func TestSortStringArray(t *testing.T) {
|
||||
|
||||
func TestSortInts(t *testing.T) {
|
||||
data := ints
|
||||
SortInts(&data)
|
||||
if !IntsAreSorted(&data) {
|
||||
SortInts(data[0:])
|
||||
if !IntsAreSorted(data[0:]) {
|
||||
t.Errorf("sorted %v", ints)
|
||||
t.Errorf(" got %v", data)
|
||||
}
|
||||
@ -57,8 +57,8 @@ func TestSortInts(t *testing.T) {
|
||||
|
||||
func TestSortFloats(t *testing.T) {
|
||||
data := floats
|
||||
SortFloats(&data)
|
||||
if !FloatsAreSorted(&data) {
|
||||
SortFloats(data[0:])
|
||||
if !FloatsAreSorted(data[0:]) {
|
||||
t.Errorf("sorted %v", floats)
|
||||
t.Errorf(" got %v", data)
|
||||
}
|
||||
@ -66,8 +66,8 @@ func TestSortFloats(t *testing.T) {
|
||||
|
||||
func TestSortStrings(t *testing.T) {
|
||||
data := strings
|
||||
SortStrings(&data)
|
||||
if !StringsAreSorted(&data) {
|
||||
SortStrings(data[0:])
|
||||
if !StringsAreSorted(data[0:]) {
|
||||
t.Errorf("sorted %v", strings)
|
||||
t.Errorf(" got %v", data)
|
||||
}
|
||||
|
@ -244,7 +244,7 @@ func forkExec(argv0 string, argv []string, envv []string, traceme bool, dir stri
|
||||
ForkLock.Lock()
|
||||
|
||||
// Allocate child status pipe close on exec.
|
||||
if err = Pipe(&p); err != 0 {
|
||||
if err = Pipe(p[0:]); err != 0 {
|
||||
goto error
|
||||
}
|
||||
if _, err = fcntl(p[0], F_SETFD, FD_CLOEXEC); err != 0 {
|
||||
|
@ -68,7 +68,7 @@ const ImplementsGetwd = true
|
||||
//sys Getcwd(buf []byte) (n int, errno int)
|
||||
func Getwd() (wd string, errno int) {
|
||||
var buf [PathMax]byte
|
||||
n, err := Getcwd(&buf)
|
||||
n, err := Getcwd(buf[0:])
|
||||
if err != 0 {
|
||||
return "", err
|
||||
}
|
||||
@ -442,7 +442,7 @@ func ptracePeek(req int, pid int, addr uintptr, out []byte) (count int, errno in
|
||||
if errno != 0 {
|
||||
return n, errno
|
||||
}
|
||||
copied := copy(out, &buf)
|
||||
copied := copy(out, buf[0:])
|
||||
n += copied
|
||||
out = out[copied:]
|
||||
}
|
||||
@ -497,7 +497,7 @@ func ptracePoke(pokeReq int, peekReq int, pid int, addr uintptr, data []byte) (c
|
||||
if errno != 0 {
|
||||
return n, errno
|
||||
}
|
||||
copy(&buf, data)
|
||||
copy(buf[0:], data)
|
||||
word := *((*uintptr)(unsafe.Pointer(&buf[0])))
|
||||
errno = ptrace(pokeReq, pid, addr+uintptr(n), word)
|
||||
if errno != 0 {
|
||||
|
@ -16,7 +16,7 @@ func runSyslog(c net.PacketConn, done chan<- string) {
|
||||
var buf [4096]byte
|
||||
var rcvd string = ""
|
||||
for {
|
||||
n, _, err := c.ReadFrom(&buf)
|
||||
n, _, err := c.ReadFrom(buf[0:])
|
||||
if err != nil || n == 0 {
|
||||
break
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ func (b *Writer) writePadding(textw, cellw int, useTabs bool) {
|
||||
}
|
||||
|
||||
// padding is done with non-tab characters
|
||||
b.writeN(&b.padbytes, cellw-textw)
|
||||
b.writeN(b.padbytes[0:], cellw-textw)
|
||||
}
|
||||
|
||||
|
||||
|
@ -78,7 +78,7 @@ func TestEncodeRune(t *testing.T) {
|
||||
m := utf8map[i]
|
||||
b := makeBytes(m.str)
|
||||
var buf [10]byte
|
||||
n := EncodeRune(m.rune, &buf)
|
||||
n := EncodeRune(m.rune, buf[0:])
|
||||
b1 := buf[0:n]
|
||||
if !bytes.Equal(b, b1) {
|
||||
t.Errorf("EncodeRune(%#04x) = %q want %q", m.rune, b1, b)
|
||||
|
Loading…
Reference in New Issue
Block a user