all: remove now-unnecessary unreachable panics

Take advantage of the new terminating statement rule.

R=golang-dev, r, gri
CC=golang-dev
https://golang.org/cl/7712044
This commit is contained in:
Brad Fitzpatrick 2013-03-11 14:16:55 -07:00
parent 5f91a62a3c
commit e15c0ac693
32 changed files with 1 additions and 39 deletions

View file

@ -723,7 +723,6 @@ func (w *Walker) varValueType(vi interface{}) (string, error) {
default:
return "", fmt.Errorf("unknown const value type %T", vi)
}
panic("unreachable")
}
// resolveName finds a top-level node named name and returns the node

View file

@ -1291,7 +1291,6 @@ func (b *builder) runOut(dir string, desc string, cmdargs ...interface{}) ([]byt
return buf.Bytes(), err
}
panic("unreachable")
}
// mkdir makes the named directory.

View file

@ -274,7 +274,6 @@ func (b *Reader) ReadSlice(delim byte) (line []byte, err error) {
return b.buf, ErrBufferFull
}
}
panic("not reached")
}
// ReadLine is a low-level line-reading primitive. Most callers should use

View file

@ -169,7 +169,6 @@ func (s *Scanner) Scan() bool {
}
s.end += n
}
panic("not reached")
}
// advance consumes n bytes of the buffer. It reports whether the advance was legal.

View file

@ -54,8 +54,6 @@ func (t huffmanTree) Decode(br *bitReader) (v uint16) {
nodeIndex = node.right
}
}
panic("unreachable")
}
// newHuffmanTree builds a Huffman tree from a slice containing the code

View file

@ -158,7 +158,6 @@ func (b *syncBuffer) Read(p []byte) (n int, err error) {
}
<-b.ready
}
panic("unreachable")
}
func (b *syncBuffer) signal() {

View file

@ -263,7 +263,6 @@ func (f *decompressor) Read(b []byte) (int, error) {
}
f.step(f)
}
panic("unreachable")
}
func (f *decompressor) Close() error {
@ -495,7 +494,6 @@ func (f *decompressor) huffmanBlock() {
return
}
}
panic("unreached")
}
// copyHist copies f.copyLen bytes from f.hist (f.copyDist bytes ago) to itself.

View file

@ -99,5 +99,4 @@ func offsetCode(off uint32) uint32 {
default:
return offsetCodes[off>>14] + 28
}
panic("unreachable")
}

View file

@ -121,7 +121,6 @@ func (d *decoder) Read(b []byte) (int, error) {
}
d.decode()
}
panic("unreachable")
}
// decode decompresses bytes from r and leaves them in d.toRead.

View file

@ -144,8 +144,6 @@ GeneratePrimes:
params.G = g
return
}
panic("unreachable")
}
// GenerateKey generates a public&private key pair. The Parameters of the

View file

@ -51,6 +51,4 @@ func ParsePKCS8PrivateKey(der []byte) (key interface{}, err error) {
default:
return nil, fmt.Errorf("crypto/x509: PKCS#8 wrapping contained private key with unknown algorithm: %v", privKey.Algo.Algorithm)
}
panic("unreachable")
}

View file

@ -729,7 +729,6 @@ func parsePublicKey(algo PublicKeyAlgorithm, keyData *publicKeyInfo) (interface{
default:
return nil, nil
}
panic("unreachable")
}
func parseCertificate(in *certificate) (*Certificate, error) {

View file

@ -296,5 +296,4 @@ func (d *decoder) Read(p []byte) (n int, err error) {
nn, d.readErr = d.r.Read(d.buf[d.nbuf:])
d.nbuf += nn
}
panic("unreachable")
}

View file

@ -120,7 +120,6 @@ func ReadUvarint(r io.ByteReader) (uint64, error) {
x |= uint64(b&0x7f) << s
s += 7
}
panic("unreachable")
}
// ReadVarint reads an encoded signed integer from r and returns it as an int64.

View file

@ -171,7 +171,6 @@ func (r *Reader) ReadAll() (records [][]string, err error) {
}
records = append(records, record)
}
panic("unreachable")
}
// readRune reads one rune from r, folding \r\n to \n and keeping track

View file

@ -739,6 +739,7 @@ func (d *decodeState) valueInterface() interface{} {
switch d.scanWhile(scanSkipSpace) {
default:
d.error(errPhase)
panic("unreachable")
case scanBeginArray:
return d.arrayInterface()
case scanBeginObject:
@ -746,7 +747,6 @@ func (d *decodeState) valueInterface() interface{} {
case scanBeginLiteral:
return d.literalInterface()
}
panic("unreachable")
}
// arrayInterface is like array but returns []interface{}.

View file

@ -493,7 +493,6 @@ Loop:
return true, nil
}
}
panic("unreachable")
}
// Skip reads tokens until it has consumed the end element
@ -517,5 +516,4 @@ func (d *Decoder) Skip() error {
return nil
}
}
panic("unreachable")
}

View file

@ -89,8 +89,6 @@ func expectedErrors(t *testing.T, filename string, src []byte) map[token.Pos]str
prev = pos
}
}
panic("unreachable")
}
// compareErrors compares the map of expected error messages with the list

View file

@ -71,7 +71,6 @@ func tText(c context, s []byte) (context, int) {
}
k = j
}
panic("unreachable")
}
var elementContentType = [...]state{

View file

@ -304,7 +304,6 @@ func (d *decoder) readExtension() error {
return err
}
}
panic("unreachable")
}
func (d *decoder) readGraphicControl() error {

View file

@ -144,7 +144,6 @@ func (devNull) ReadFrom(r io.Reader) (n int64, err error) {
return
}
}
panic("unreachable")
}
// Discard is an io.Writer on which all Write calls succeed

View file

@ -43,7 +43,6 @@ func (r *Rand) ExpFloat64() float64 {
return x
}
}
panic("unreachable")
}
var ke = [256]uint32{

View file

@ -63,7 +63,6 @@ func (r *Rand) NormFloat64() float64 {
return x
}
}
panic("unreachable")
}
var kn = [128]uint32{

View file

@ -265,7 +265,6 @@ func (r *Reader) NextPart() (*Part, error) {
return nil, fmt.Errorf("multipart: unexpected line in Next(): %q", line)
}
panic("unreachable")
}
// isFinalBoundary returns whether line is the final boundary line

View file

@ -280,7 +280,6 @@ func dialTimeoutRace(net, addr string, timeout time.Duration) (Conn, error) {
case p := <-ch:
return p.Conn, p.error
}
panic("unreachable")
}
type stringAddr struct {

View file

@ -51,7 +51,6 @@ func pedanticReadAll(r io.Reader) (b []byte, err error) {
return b, err
}
}
panic("unreachable")
}
func TestClient(t *testing.T) {

View file

@ -267,5 +267,4 @@ func Serve(l net.Listener, handler http.Handler) error {
c := newChild(rw, handler)
go c.serve()
}
panic("unreachable")
}

View file

@ -1337,7 +1337,6 @@ func (srv *Server) Serve(l net.Listener) error {
}
go c.serve()
}
panic("not reached")
}
// ListenAndServe listens on the TCP network address addr

View file

@ -349,7 +349,6 @@ func (t *Transport) getIdleConn(cm *connectMethod) (pconn *persistConn) {
return
}
}
panic("unreachable")
}
func (t *Transport) setReqConn(r *Request, pc *persistConn) {

View file

@ -399,12 +399,10 @@ func (WriteFailCodec) WriteRequest(*Request, interface{}) error {
func (WriteFailCodec) ReadResponseHeader(*Response) error {
select {}
panic("unreachable")
}
func (WriteFailCodec) ReadResponseBody(interface{}) error {
select {}
panic("unreachable")
}
func (WriteFailCodec) Close() error {

View file

@ -489,7 +489,6 @@ func (r *Reader) ReadMIMEHeader() (MIMEHeader, error) {
return m, err
}
}
panic("unreachable")
}
// CanonicalMIMEHeaderKey returns the canonical format of the

View file

@ -198,7 +198,6 @@ func (f *File) write(b []byte) (n int, err error) {
return n, err
}
panic("not reached")
}
// pwrite writes len(b) bytes to the File starting at byte offset off.