mirror of
https://github.com/golang/go
synced 2024-11-25 00:07:56 -07:00
fix "declared and not used" errors in non-test code.
R=r DELTA=112 (6 added, 57 deleted, 49 changed) OCL=34610 CL=34610
This commit is contained in:
parent
b198b994a1
commit
28eba4877b
@ -63,7 +63,7 @@ echo $alphabet | testit cat "" $alphabet
|
|||||||
echo $alphabet | testit cat_rot13 "--rot13" $rot13
|
echo $alphabet | testit cat_rot13 "--rot13" $rot13
|
||||||
echo $rot13 | testit cat_rot13 "--rot13" $alphabet
|
echo $rot13 | testit cat_rot13 "--rot13" $alphabet
|
||||||
|
|
||||||
testit sortmain "" "Sunday Monday Tuesday Thursday Friday"
|
testit sortmain "" "Sunday Monday Tuesday Wednesday Thursday Friday Saturday"
|
||||||
|
|
||||||
testit print "" "18446744073709551615 -1 18446744073709551615 {77 Sunset Strip} [1 2 3 4] 18446744073709551615 {77 Sunset Strip} [1 2 3 4] 18446744073709551615 {77 Sunset Strip} [1 2 3 4]"
|
testit print "" "18446744073709551615 -1 18446744073709551615 {77 Sunset Strip} [1 2 3 4] 18446744073709551615 {77 Sunset Strip} [1 2 3 4] 18446744073709551615 {77 Sunset Strip} [1 2 3 4]"
|
||||||
testit print_string "" "77 Sunset Strip"
|
testit print_string "" "77 Sunset Strip"
|
||||||
|
@ -49,7 +49,7 @@ func days() {
|
|||||||
Thursday := day{ 4, "THU", "Thursday" };
|
Thursday := day{ 4, "THU", "Thursday" };
|
||||||
Friday := day{ 5, "FRI", "Friday" };
|
Friday := day{ 5, "FRI", "Friday" };
|
||||||
Saturday := day{ 6, "SAT", "Saturday" };
|
Saturday := day{ 6, "SAT", "Saturday" };
|
||||||
data := []*day{&Tuesday, &Thursday, &Sunday, &Monday, &Friday};
|
data := []*day{&Tuesday, &Thursday, &Wednesday, &Sunday, &Monday, &Friday, &Saturday};
|
||||||
a := dayArray{data};
|
a := dayArray{data};
|
||||||
sort.Sort(&a);
|
sort.Sort(&a);
|
||||||
if !sort.IsSorted(&a) {
|
if !sort.IsSorted(&a) {
|
||||||
|
@ -95,11 +95,10 @@ func (ignoreWriter) Write(b []byte) (n int, err os.Error) {
|
|||||||
func (tr *Reader) skipUnread() {
|
func (tr *Reader) skipUnread() {
|
||||||
nr := tr.nb + tr.pad; // number of bytes to skip
|
nr := tr.nb + tr.pad; // number of bytes to skip
|
||||||
|
|
||||||
var n int64;
|
|
||||||
if sr, ok := tr.r.(io.Seeker); ok {
|
if sr, ok := tr.r.(io.Seeker); ok {
|
||||||
n, tr.err = sr.Seek(nr, 1);
|
_, tr.err = sr.Seek(nr, 1);
|
||||||
} else {
|
} else {
|
||||||
n, tr.err = io.Copyn(tr.r, ignoreWriter{}, nr);
|
_, tr.err = io.Copyn(tr.r, ignoreWriter{}, nr);
|
||||||
}
|
}
|
||||||
tr.nb, tr.pad = 0, 0;
|
tr.nb, tr.pad = 0, 0;
|
||||||
}
|
}
|
||||||
@ -116,14 +115,13 @@ func (tr *Reader) verifyChecksum(header []byte) bool {
|
|||||||
|
|
||||||
func (tr *Reader) readHeader() *Header {
|
func (tr *Reader) readHeader() *Header {
|
||||||
header := make([]byte, blockSize);
|
header := make([]byte, blockSize);
|
||||||
var n int;
|
if _, tr.err = io.ReadFull(tr.r, header); tr.err != nil {
|
||||||
if n, tr.err = io.ReadFull(tr.r, header); tr.err != nil {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Two blocks of zero bytes marks the end of the archive.
|
// Two blocks of zero bytes marks the end of the archive.
|
||||||
if bytes.Equal(header, zeroBlock[0:blockSize]) {
|
if bytes.Equal(header, zeroBlock[0:blockSize]) {
|
||||||
if n, tr.err = io.ReadFull(tr.r, header); tr.err != nil {
|
if _, tr.err = io.ReadFull(tr.r, header); tr.err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if !bytes.Equal(header, zeroBlock[0:blockSize]) {
|
if !bytes.Equal(header, zeroBlock[0:blockSize]) {
|
||||||
|
@ -109,7 +109,7 @@ func (tw *Writer) WriteHeader(hdr *Header) os.Error {
|
|||||||
s := slicer(header);
|
s := slicer(header);
|
||||||
|
|
||||||
// TODO(dsymonds): handle names longer than 100 chars
|
// TODO(dsymonds): handle names longer than 100 chars
|
||||||
nr := bytes.Copy(s.next(100), strings.Bytes(hdr.Name));
|
bytes.Copy(s.next(100), strings.Bytes(hdr.Name));
|
||||||
|
|
||||||
tw.octal(s.next(8), hdr.Mode); // 100:108
|
tw.octal(s.next(8), hdr.Mode); // 100:108
|
||||||
tw.octal(s.next(8), hdr.Uid); // 108:116
|
tw.octal(s.next(8), hdr.Uid); // 108:116
|
||||||
@ -136,8 +136,7 @@ func (tw *Writer) WriteHeader(hdr *Header) os.Error {
|
|||||||
return tw.err
|
return tw.err
|
||||||
}
|
}
|
||||||
|
|
||||||
var n int;
|
_, tw.err = tw.w.Write(header);
|
||||||
n, tw.err = tw.w.Write(header);
|
|
||||||
|
|
||||||
return tw.err
|
return tw.err
|
||||||
}
|
}
|
||||||
@ -169,8 +168,7 @@ func (tw *Writer) Close() os.Error {
|
|||||||
|
|
||||||
// trailer: two zero blocks
|
// trailer: two zero blocks
|
||||||
for i := 0; i < 2; i++ {
|
for i := 0; i < 2; i++ {
|
||||||
var n int;
|
_, tw.err = tw.w.Write(zeroBlock);
|
||||||
n, tw.err = tw.w.Write(zeroBlock);
|
|
||||||
if tw.err != nil {
|
if tw.err != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,6 @@ func TestEncoder(t *testing.T) {
|
|||||||
func TestEncoderBuffering(t *testing.T) {
|
func TestEncoderBuffering(t *testing.T) {
|
||||||
input := strings.Bytes(bigtest.decoded);
|
input := strings.Bytes(bigtest.decoded);
|
||||||
for bs := 1; bs <= 12; bs++ {
|
for bs := 1; bs <= 12; bs++ {
|
||||||
buf := make([]byte, bs);
|
|
||||||
bb := &bytes.Buffer{};
|
bb := &bytes.Buffer{};
|
||||||
encoder := NewEncoder(StdEncoding, bb);
|
encoder := NewEncoder(StdEncoding, bb);
|
||||||
for pos := 0; pos < len(input); pos += bs {
|
for pos := 0; pos < len(input); pos += bs {
|
||||||
|
@ -65,7 +65,7 @@ func explode(s []byte, n int) [][]byte {
|
|||||||
n = len(s);
|
n = len(s);
|
||||||
}
|
}
|
||||||
a := make([][]byte, n);
|
a := make([][]byte, n);
|
||||||
var size, rune int;
|
var size int;
|
||||||
na := 0;
|
na := 0;
|
||||||
for len(s) > 0 {
|
for len(s) > 0 {
|
||||||
if na+1 >= n {
|
if na+1 >= n {
|
||||||
@ -73,7 +73,7 @@ func explode(s []byte, n int) [][]byte {
|
|||||||
na++;
|
na++;
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
rune, size = utf8.DecodeRune(s);
|
_, size = utf8.DecodeRune(s);
|
||||||
a[na] = s[0:size];
|
a[na] = s[0:size];
|
||||||
s = s[size:len(s)];
|
s = s[size:len(s)];
|
||||||
na++;
|
na++;
|
||||||
|
@ -138,8 +138,7 @@ func (z *Inflater) readHeader(save bool) os.Error {
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
data := make([]byte, n);
|
data := make([]byte, n);
|
||||||
var nn int;
|
if _, err = io.ReadFull(z.r, data); err != nil {
|
||||||
if nn, err = io.ReadFull(z.r, data); err != nil {
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
if save {
|
if save {
|
||||||
|
@ -211,7 +211,6 @@ func TestUnlink(t *testing.T) {
|
|||||||
s10 := r10.Move(6);
|
s10 := r10.Move(6);
|
||||||
|
|
||||||
sum10 := sumN(10);
|
sum10 := sumN(10);
|
||||||
sum6 := sumN(6);
|
|
||||||
|
|
||||||
verify(t, r10, 10, sum10);
|
verify(t, r10, 10, sum10);
|
||||||
verify(t, s10, 10, sum10);
|
verify(t, s10, 10, sum10);
|
||||||
|
@ -124,8 +124,7 @@ func (p *parser) parseRuleName() (string, bool) {
|
|||||||
func (p *parser) parseString() string {
|
func (p *parser) parseString() string {
|
||||||
s := "";
|
s := "";
|
||||||
if p.tok == token.STRING {
|
if p.tok == token.STRING {
|
||||||
var err os.Error;
|
s, _ = strconv.Unquote(string(p.lit));
|
||||||
s, err = strconv.Unquote(string(p.lit));
|
|
||||||
// Unquote may fail with an error, but only if the scanner found
|
// Unquote may fail with an error, but only if the scanner found
|
||||||
// an illegal string in the first place. In this case the error
|
// an illegal string in the first place. In this case the error
|
||||||
// has already been reported.
|
// has already been reported.
|
||||||
|
@ -72,8 +72,7 @@ func (p *parser) parseToken() *Token {
|
|||||||
pos := p.pos;
|
pos := p.pos;
|
||||||
value := "";
|
value := "";
|
||||||
if p.tok == token.STRING {
|
if p.tok == token.STRING {
|
||||||
var err os.Error;
|
value, _ = strconv.Unquote(string(p.lit));
|
||||||
value, err = strconv.Unquote(string(p.lit));
|
|
||||||
// Unquote may fail with an error, but only if the scanner found
|
// Unquote may fail with an error, but only if the scanner found
|
||||||
// an illegal string in the first place. In this case the error
|
// an illegal string in the first place. In this case the error
|
||||||
// has already been reported.
|
// has already been reported.
|
||||||
|
@ -351,7 +351,6 @@ func TestStdErrorHander(t *testing.T) {
|
|||||||
"@ @ @" // original file, line 1 again
|
"@ @ @" // original file, line 1 again
|
||||||
;
|
;
|
||||||
|
|
||||||
var s Scanner;
|
|
||||||
v := NewErrorVector();
|
v := NewErrorVector();
|
||||||
nerrors := Tokenize("File1", strings.Bytes(src), v, 0,
|
nerrors := Tokenize("File1", strings.Bytes(src), v, 0,
|
||||||
func (pos token.Position, tok token.Token, litb []byte) bool {
|
func (pos token.Position, tok token.Token, litb []byte) bool {
|
||||||
|
@ -93,7 +93,6 @@ func verifyInt(i int64, t *testing.T) {
|
|||||||
|
|
||||||
// Test basic encode/decode routines for signed integers
|
// Test basic encode/decode routines for signed integers
|
||||||
func TestIntCodec(t *testing.T) {
|
func TestIntCodec(t *testing.T) {
|
||||||
var b = new(bytes.Buffer);
|
|
||||||
for u := uint64(0); ; u = (u+1) * 7 {
|
for u := uint64(0); ; u = (u+1) * 7 {
|
||||||
// Do positive and negative values
|
// Do positive and negative values
|
||||||
i := int64(u);
|
i := int64(u);
|
||||||
@ -191,9 +190,6 @@ func TestScalarEncInstructions(t *testing.T) {
|
|||||||
// int16
|
// int16
|
||||||
{
|
{
|
||||||
b.Reset();
|
b.Reset();
|
||||||
v := int16(17);
|
|
||||||
pv := &v;
|
|
||||||
ppv := &pv;
|
|
||||||
data := struct { a int16 } { 17 };
|
data := struct { a int16 } { 17 };
|
||||||
instr := &encInstr{ encInt16, 6, 0, 0 };
|
instr := &encInstr{ encInt16, 6, 0, 0 };
|
||||||
state := newencoderState(b);
|
state := newencoderState(b);
|
||||||
|
@ -75,8 +75,7 @@ func (dec *Decoder) Decode(e interface{}) os.Error {
|
|||||||
dec.state.b = bytes.NewBuffer(dec.buf[0:nbytes]);
|
dec.state.b = bytes.NewBuffer(dec.buf[0:nbytes]);
|
||||||
|
|
||||||
// Read the data
|
// Read the data
|
||||||
var n int;
|
_, dec.state.err = io.ReadFull(dec.r, dec.buf[0:nbytes]);
|
||||||
n, dec.state.err = io.ReadFull(dec.r, dec.buf[0:nbytes]);
|
|
||||||
if dec.state.err != nil {
|
if dec.state.err != nil {
|
||||||
if dec.state.err == os.EOF {
|
if dec.state.err == os.EOF {
|
||||||
dec.state.err = io.ErrUnexpectedEOF;
|
dec.state.err = io.ErrUnexpectedEOF;
|
||||||
|
@ -64,7 +64,6 @@ func TestReregistration(t *testing.T) {
|
|||||||
func TestArrayType(t *testing.T) {
|
func TestArrayType(t *testing.T) {
|
||||||
var a3 [3]int;
|
var a3 [3]int;
|
||||||
a3int := getTypeUnlocked("foo", reflect.Typeof(a3));
|
a3int := getTypeUnlocked("foo", reflect.Typeof(a3));
|
||||||
var newa3 [3]int;
|
|
||||||
newa3int := getTypeUnlocked("bar", reflect.Typeof(a3));
|
newa3int := getTypeUnlocked("bar", reflect.Typeof(a3));
|
||||||
if a3int != newa3int {
|
if a3int != newa3int {
|
||||||
t.Errorf("second registration of [3]int creates new type");
|
t.Errorf("second registration of [3]int creates new type");
|
||||||
|
@ -431,8 +431,7 @@ func (cr *chunkedReader) Read(b []uint8) (n int, err os.Error) {
|
|||||||
if cr.n == 0 && cr.err == nil {
|
if cr.n == 0 && cr.err == nil {
|
||||||
// end of chunk (CRLF)
|
// end of chunk (CRLF)
|
||||||
b := make([]byte, 2);
|
b := make([]byte, 2);
|
||||||
var nb int;
|
if _, cr.err = io.ReadFull(cr.r, b); cr.err == nil {
|
||||||
if nb, cr.err = io.ReadFull(cr.r, b); cr.err == nil {
|
|
||||||
if b[0] != '\r' || b[1] != '\n' {
|
if b[0] != '\r' || b[1] != '\n' {
|
||||||
cr.err = os.NewError("malformed chunked encoding");
|
cr.err = os.NewError("malformed chunked encoding");
|
||||||
}
|
}
|
||||||
|
@ -62,9 +62,8 @@ func TestParseForm(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestQuery(t *testing.T) {
|
func TestQuery(t *testing.T) {
|
||||||
var err os.Error;
|
|
||||||
req := &Request{ Method: "GET" };
|
req := &Request{ Method: "GET" };
|
||||||
req.Url, err = ParseURL("http://www.google.com/search?q=foo&q=bar");
|
req.Url, _ = ParseURL("http://www.google.com/search?q=foo&q=bar");
|
||||||
if q := req.FormValue("q"); q != "foo" {
|
if q := req.FormValue("q"); q != "foo" {
|
||||||
t.Errorf(`req.FormValue("q") = %q, want "foo"`, q);
|
t.Errorf(`req.FormValue("q") = %q, want "foo"`, q);
|
||||||
}
|
}
|
||||||
|
@ -316,11 +316,10 @@ func (b *_JsonBuilder) Key(k string) Builder {
|
|||||||
// If StringToJson encounters a syntax error, it returns with
|
// If StringToJson encounters a syntax error, it returns with
|
||||||
// ok set to false and errtok set to a fragment of the offending syntax.
|
// ok set to false and errtok set to a fragment of the offending syntax.
|
||||||
func StringToJson(s string) (json Json, ok bool, errtok string) {
|
func StringToJson(s string) (json Json, ok bool, errtok string) {
|
||||||
var errindx int;
|
|
||||||
var j Json;
|
var j Json;
|
||||||
b := new(_JsonBuilder);
|
b := new(_JsonBuilder);
|
||||||
b.ptr = &j;
|
b.ptr = &j;
|
||||||
ok, errindx, errtok = Parse(s, b);
|
ok, _, errtok = Parse(s, b);
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, false, errtok
|
return nil, false, errtok
|
||||||
}
|
}
|
||||||
|
@ -248,10 +248,8 @@ func (b *_StructBuilder) Key(k string) Builder {
|
|||||||
// On a syntax error, it returns with ok set to false and errtok
|
// On a syntax error, it returns with ok set to false and errtok
|
||||||
// set to the offending token.
|
// set to the offending token.
|
||||||
func Unmarshal(s string, val interface{}) (ok bool, errtok string) {
|
func Unmarshal(s string, val interface{}) (ok bool, errtok string) {
|
||||||
var errindx int;
|
|
||||||
var val1 interface{};
|
|
||||||
b := &_StructBuilder{ reflect.NewValue(val) };
|
b := &_StructBuilder{ reflect.NewValue(val) };
|
||||||
ok, errindx, errtok = Parse(s, b);
|
ok, _, errtok = Parse(s, b);
|
||||||
if !ok {
|
if !ok {
|
||||||
return false, errtok
|
return false, errtok
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,6 @@ func LookupHost(name string) (cname string, addrs []string, err os.Error) {
|
|||||||
rname += ".";
|
rname += ".";
|
||||||
}
|
}
|
||||||
// Can try as ordinary name.
|
// Can try as ordinary name.
|
||||||
var dnserr *DNSError;
|
|
||||||
addrs, err = tryOneName(cfg, rname);
|
addrs, err = tryOneName(cfg, rname);
|
||||||
if err == nil {
|
if err == nil {
|
||||||
cname = rname;
|
cname = rname;
|
||||||
@ -264,7 +263,6 @@ func LookupHost(name string) (cname string, addrs []string, err os.Error) {
|
|||||||
if rname[len(rname)-1] != '.' {
|
if rname[len(rname)-1] != '.' {
|
||||||
rname += "."
|
rname += "."
|
||||||
}
|
}
|
||||||
var dnserr *DNSError;
|
|
||||||
addrs, err = tryOneName(cfg, rname);
|
addrs, err = tryOneName(cfg, rname);
|
||||||
if err == nil {
|
if err == nil {
|
||||||
cname = rname;
|
cname = rname;
|
||||||
|
@ -326,7 +326,6 @@ func socket(net, laddr, raddr string, f, p, t int, la, ra syscall.Sockaddr) (fd
|
|||||||
// Allow reuse of recently-used addresses.
|
// Allow reuse of recently-used addresses.
|
||||||
syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1);
|
syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1);
|
||||||
|
|
||||||
var r int64;
|
|
||||||
if la != nil {
|
if la != nil {
|
||||||
e = syscall.Bind(s, la);
|
e = syscall.Bind(s, la);
|
||||||
if e != 0 {
|
if e != 0 {
|
||||||
|
@ -49,7 +49,6 @@ func Getwd() (string, Error) {
|
|||||||
// General algorithm: find name in parent
|
// General algorithm: find name in parent
|
||||||
// and then find name of parent. Each iteration
|
// and then find name of parent. Each iteration
|
||||||
// adds /name to the beginning of pwd.
|
// adds /name to the beginning of pwd.
|
||||||
elem := make([]string, 0, 16);
|
|
||||||
pwd = "";
|
pwd = "";
|
||||||
for parent := "..";; parent = "../" + parent {
|
for parent := "..";; parent = "../" + parent {
|
||||||
if len(parent) >= 1024 { // Sanity check
|
if len(parent) >= 1024 { // Sanity check
|
||||||
|
@ -125,7 +125,6 @@ func Join(dir, file string) string {
|
|||||||
// in the final slash-separated element of path;
|
// in the final slash-separated element of path;
|
||||||
// it is empty if there is no dot.
|
// it is empty if there is no dot.
|
||||||
func Ext(path string) string {
|
func Ext(path string) string {
|
||||||
dot := -1;
|
|
||||||
for i := len(path)-1; i >= 0 && path[i] != '/'; i-- {
|
for i := len(path)-1; i >= 0 && path[i] != '/'; i-- {
|
||||||
if path[i] == '.' {
|
if path[i] == '.' {
|
||||||
return path[i:len(path)];
|
return path[i:len(path)];
|
||||||
|
@ -84,7 +84,6 @@ func valueToString(val Value) string {
|
|||||||
return str;
|
return str;
|
||||||
case *MapValue:
|
case *MapValue:
|
||||||
t := typ.(*MapType);
|
t := typ.(*MapType);
|
||||||
v := val;
|
|
||||||
str = t.String();
|
str = t.String();
|
||||||
str += "{";
|
str += "{";
|
||||||
str += "<can't iterate on maps>";
|
str += "<can't iterate on maps>";
|
||||||
|
@ -16,7 +16,6 @@ type addr unsafe.Pointer
|
|||||||
// TODO: This will have to go away when
|
// TODO: This will have to go away when
|
||||||
// the new gc goes in.
|
// the new gc goes in.
|
||||||
func memmove(adst, asrc addr, n uintptr) {
|
func memmove(adst, asrc addr, n uintptr) {
|
||||||
var p uintptr; // dummy for sizeof
|
|
||||||
dst := uintptr(adst);
|
dst := uintptr(adst);
|
||||||
src := uintptr(asrc);
|
src := uintptr(asrc);
|
||||||
switch {
|
switch {
|
||||||
@ -680,7 +679,6 @@ func (v *ChanValue) recv(b *bool) Value {
|
|||||||
panic("recv on send-only channel");
|
panic("recv on send-only channel");
|
||||||
}
|
}
|
||||||
ch := *(**byte)(v.addr);
|
ch := *(**byte)(v.addr);
|
||||||
newval := MakeZero(t.Elem());
|
|
||||||
x := MakeZero(t.Elem());
|
x := MakeZero(t.Elem());
|
||||||
chanrecv(ch, (*byte)(x.getAddr()), b);
|
chanrecv(ch, (*byte)(x.getAddr()), b);
|
||||||
return x;
|
return x;
|
||||||
|
@ -972,11 +972,11 @@ func (re *Regexp) allMatches(s string, b []byte, n int, deliver func(int, int))
|
|||||||
// after a previous match, so ignore it.
|
// after a previous match, so ignore it.
|
||||||
accept = false;
|
accept = false;
|
||||||
}
|
}
|
||||||
var rune, width int;
|
var width int;
|
||||||
if b == nil {
|
if b == nil {
|
||||||
rune, width = utf8.DecodeRuneInString(s[pos:end]);
|
_, width = utf8.DecodeRuneInString(s[pos:end]);
|
||||||
} else {
|
} else {
|
||||||
rune, width = utf8.DecodeRune(b[pos:end]);
|
_, width = utf8.DecodeRune(b[pos:end]);
|
||||||
}
|
}
|
||||||
if width > 0 {
|
if width > 0 {
|
||||||
pos += width;
|
pos += width;
|
||||||
|
@ -46,7 +46,7 @@ func (client *Client) send(c *Call) {
|
|||||||
if client.shutdown != nil {
|
if client.shutdown != nil {
|
||||||
c.Error = client.shutdown;
|
c.Error = client.shutdown;
|
||||||
client.mutex.Unlock();
|
client.mutex.Unlock();
|
||||||
doNotBlock := c.Done <- c;
|
_ = c.Done <- c; // do not block
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
c.seq = client.seq;
|
c.seq = client.seq;
|
||||||
@ -87,14 +87,14 @@ func (client *Client) input() {
|
|||||||
c.Error = os.ErrorString(response.Error);
|
c.Error = os.ErrorString(response.Error);
|
||||||
// We don't want to block here. It is the caller's responsibility to make
|
// We don't want to block here. It is the caller's responsibility to make
|
||||||
// sure the channel has enough buffer space. See comment in Go().
|
// sure the channel has enough buffer space. See comment in Go().
|
||||||
doNotBlock := c.Done <- c;
|
_ = c.Done <- c; // do not block
|
||||||
}
|
}
|
||||||
// Terminate pending calls.
|
// Terminate pending calls.
|
||||||
client.mutex.Lock();
|
client.mutex.Lock();
|
||||||
client.shutdown = err;
|
client.shutdown = err;
|
||||||
for seq, call := range client.pending {
|
for seq, call := range client.pending {
|
||||||
call.Error = err;
|
call.Error = err;
|
||||||
doNotBlock := call.Done <- call;
|
_ = call.Done <- call; // do not block
|
||||||
}
|
}
|
||||||
client.mutex.Unlock();
|
client.mutex.Unlock();
|
||||||
log.Stderr("client protocol error:", err);
|
log.Stderr("client protocol error:", err);
|
||||||
@ -161,7 +161,7 @@ func (client *Client) Go(serviceMethod string, args interface{}, reply interface
|
|||||||
c.Done = done;
|
c.Done = done;
|
||||||
if client.shutdown != nil {
|
if client.shutdown != nil {
|
||||||
c.Error = client.shutdown;
|
c.Error = client.shutdown;
|
||||||
doNotBlock := c.Done <- c;
|
_ = c.Done <- c; // do not block
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
client.send(c);
|
client.send(c);
|
||||||
|
@ -338,7 +338,6 @@ func (server *serverType) input(conn io.ReadWriteCloser) {
|
|||||||
sendResponse(sending, req, invalidRequest, enc, s);
|
sendResponse(sending, req, invalidRequest, enc, s);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
method := mtype.method;
|
|
||||||
// Decode the argument value.
|
// Decode the argument value.
|
||||||
argv := _new(mtype.argType);
|
argv := _new(mtype.argType);
|
||||||
replyv := _new(mtype.replyType);
|
replyv := _new(mtype.replyType);
|
||||||
|
@ -30,7 +30,6 @@ var shifttests = []shiftTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDecimalShift(t *testing.T) {
|
func TestDecimalShift(t *testing.T) {
|
||||||
ok := true;
|
|
||||||
for i := 0; i < len(shifttests); i++ {
|
for i := 0; i < len(shifttests); i++ {
|
||||||
test := &shifttests[i];
|
test := &shifttests[i];
|
||||||
s := NewDecimal(test.i).Shift(test.shift).String();
|
s := NewDecimal(test.i).Shift(test.shift).String();
|
||||||
|
@ -228,7 +228,6 @@ func forkExec(argv0 string, argv []string, envv []string, traceme bool, dir stri
|
|||||||
(pid int, err int)
|
(pid int, err int)
|
||||||
{
|
{
|
||||||
var p [2]int;
|
var p [2]int;
|
||||||
var r1 int;
|
|
||||||
var n int;
|
var n int;
|
||||||
var err1 uintptr;
|
var err1 uintptr;
|
||||||
var wstatus WaitStatus;
|
var wstatus WaitStatus;
|
||||||
@ -254,11 +253,10 @@ func forkExec(argv0 string, argv []string, envv []string, traceme bool, dir stri
|
|||||||
if err = Pipe(&p); err != 0 {
|
if err = Pipe(&p); err != 0 {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
var val int;
|
if _, err = fcntl(p[0], F_SETFD, FD_CLOEXEC); err != 0 {
|
||||||
if val, err = fcntl(p[0], F_SETFD, FD_CLOEXEC); err != 0 {
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if val, err = fcntl(p[1], F_SETFD, FD_CLOEXEC); err != 0 {
|
if _, err = fcntl(p[1], F_SETFD, FD_CLOEXEC); err != 0 {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,6 @@ func tRunner(t *T, test *Test) {
|
|||||||
// of gotest.
|
// of gotest.
|
||||||
func Main(tests []Test) {
|
func Main(tests []Test) {
|
||||||
flag.Parse();
|
flag.Parse();
|
||||||
args := flag.Args();
|
|
||||||
ok := true;
|
ok := true;
|
||||||
if len(tests) == 0 {
|
if len(tests) == 0 {
|
||||||
println("testing: warning: no tests to run");
|
println("testing: warning: no tests to run");
|
||||||
|
@ -25,7 +25,6 @@ import (
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
func ticker(ns int64, c chan int64) {
|
func ticker(ns int64, c chan int64) {
|
||||||
var tv syscall.Timeval;
|
|
||||||
now := Nanoseconds();
|
now := Nanoseconds();
|
||||||
when := now;
|
when := now;
|
||||||
for {
|
for {
|
||||||
@ -44,6 +43,9 @@ func ticker(ns int64, c chan int64) {
|
|||||||
Sleep(when - now);
|
Sleep(when - now);
|
||||||
now = Nanoseconds();
|
now = Nanoseconds();
|
||||||
c <- now;
|
c <- now;
|
||||||
|
if closed(c) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +94,6 @@ func parseinfo(bytes []byte) (zt []zonetime, ok bool) {
|
|||||||
if p = d.read(16); len(p) != 16 || p[0] != 0 && p[0] != '2' {
|
if p = d.read(16); len(p) != 16 || p[0] != 0 && p[0] != '2' {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
vers := p[0];
|
|
||||||
|
|
||||||
// six big-endian 32-bit integers:
|
// six big-endian 32-bit integers:
|
||||||
// number of UTC/local indicators
|
// number of UTC/local indicators
|
||||||
@ -213,12 +212,11 @@ func setupZone() {
|
|||||||
// $TZ="foo" means use /usr/share/zoneinfo/foo.
|
// $TZ="foo" means use /usr/share/zoneinfo/foo.
|
||||||
|
|
||||||
tz, err := os.Getenverror("TZ");
|
tz, err := os.Getenverror("TZ");
|
||||||
var ok bool;
|
|
||||||
switch {
|
switch {
|
||||||
case err == os.ENOENV:
|
case err == os.ENOENV:
|
||||||
zones, ok = readinfofile("/etc/localtime");
|
zones, _ = readinfofile("/etc/localtime");
|
||||||
case len(tz) > 0:
|
case len(tz) > 0:
|
||||||
zones, ok = readinfofile(zoneDir + tz);
|
zones, _ = readinfofile(zoneDir + tz);
|
||||||
case len(tz) == 0:
|
case len(tz) == 0:
|
||||||
// do nothing: use UTC
|
// do nothing: use UTC
|
||||||
}
|
}
|
||||||
|
@ -199,15 +199,13 @@ func FullRuneInString(s string) bool {
|
|||||||
|
|
||||||
// DecodeRune unpacks the first UTF-8 encoding in p and returns the rune and its width in bytes.
|
// DecodeRune unpacks the first UTF-8 encoding in p and returns the rune and its width in bytes.
|
||||||
func DecodeRune(p []byte) (rune, size int) {
|
func DecodeRune(p []byte) (rune, size int) {
|
||||||
var short bool;
|
rune, size, _ = decodeRuneInternal(p);
|
||||||
rune, size, short = decodeRuneInternal(p);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DecodeRuneInString is like DecodeRune but its input is a string.
|
// DecodeRuneInString is like DecodeRune but its input is a string.
|
||||||
func DecodeRuneInString(s string) (rune, size int) {
|
func DecodeRuneInString(s string) (rune, size int) {
|
||||||
var short bool;
|
rune, size, _ = decodeRuneInStringInternal(s);
|
||||||
rune, size, short = decodeRuneInStringInternal(s);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,6 @@ func print(m map[string] int) {
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
in = bufio.NewReader(os.Stdin);
|
in = bufio.NewReader(os.Stdin);
|
||||||
buf := new(bytes.Buffer);
|
|
||||||
three := strings.Bytes(">THREE ");
|
three := strings.Bytes(">THREE ");
|
||||||
for {
|
for {
|
||||||
line, err := in.ReadSlice('\n');
|
line, err := in.ReadSlice('\n');
|
||||||
|
@ -85,7 +85,6 @@ var substs = [] Subst {
|
|||||||
func countMatches(pat string, bytes []byte) int {
|
func countMatches(pat string, bytes []byte) int {
|
||||||
re := compile(pat);
|
re := compile(pat);
|
||||||
n := 0;
|
n := 0;
|
||||||
pos := 0;
|
|
||||||
for {
|
for {
|
||||||
e := re.Execute(bytes);
|
e := re.Execute(bytes);
|
||||||
if len(e) == 0 {
|
if len(e) == 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user