Commit 6c025f46 by Ian Lance Taylor

libgo: Remove more os.Error cases.

From Rainer Orth.

From-SVN: r182060
parent 0173c67b
...@@ -13,13 +13,13 @@ import ( ...@@ -13,13 +13,13 @@ import (
type pollster struct { type pollster struct {
readFds, writeFds, repeatFds *syscall.FdSet readFds, writeFds, repeatFds *syscall.FdSet
maxFd int maxFd int
readyReadFds, readyWriteFds *syscall.FdSet readyReadFds, readyWriteFds *syscall.FdSet
nReady int nReady int
lastFd int lastFd int
} }
func newpollster() (p *pollster, err os.Error) { func newpollster() (p *pollster, err error) {
p = new(pollster) p = new(pollster)
p.readFds = new(syscall.FdSet) p.readFds = new(syscall.FdSet)
p.writeFds = new(syscall.FdSet) p.writeFds = new(syscall.FdSet)
...@@ -32,7 +32,7 @@ func newpollster() (p *pollster, err os.Error) { ...@@ -32,7 +32,7 @@ func newpollster() (p *pollster, err os.Error) {
return p, nil return p, nil
} }
func (p *pollster) AddFD(fd int, mode int, repeat bool) (bool, os.Error) { func (p *pollster) AddFD(fd int, mode int, repeat bool) (bool, error) {
// pollServer is locked. // pollServer is locked.
if mode == 'r' { if mode == 'r' {
...@@ -75,7 +75,7 @@ func (p *pollster) DelFD(fd int, mode int) { ...@@ -75,7 +75,7 @@ func (p *pollster) DelFD(fd int, mode int) {
// We don't worry about maxFd here. // We don't worry about maxFd here.
} }
func (p *pollster) WaitFD(s *pollServer, nsec int64) (fd int, mode int, err os.Error) { func (p *pollster) WaitFD(s *pollServer, nsec int64) (fd int, mode int, err error) {
if p.nReady == 0 { if p.nReady == 0 {
var timeout *syscall.Timeval var timeout *syscall.Timeval
var tv syscall.Timeval var tv syscall.Timeval
...@@ -94,7 +94,7 @@ func (p *pollster) WaitFD(s *pollServer, nsec int64) (fd int, mode int, err os.E ...@@ -94,7 +94,7 @@ func (p *pollster) WaitFD(s *pollServer, nsec int64) (fd int, mode int, err os.E
tmpWriteFds = *p.writeFds tmpWriteFds = *p.writeFds
s.Unlock() s.Unlock()
n, e = syscall.Select(p.maxFd + 1, &tmpReadFds, &tmpWriteFds, nil, timeout) n, e = syscall.Select(p.maxFd+1, &tmpReadFds, &tmpWriteFds, nil, timeout)
s.Lock() s.Lock()
if e != syscall.EINTR { if e != syscall.EINTR {
...@@ -115,7 +115,7 @@ func (p *pollster) WaitFD(s *pollServer, nsec int64) (fd int, mode int, err os.E ...@@ -115,7 +115,7 @@ func (p *pollster) WaitFD(s *pollServer, nsec int64) (fd int, mode int, err os.E
} }
flag := false flag := false
for i := p.lastFd; i < p.maxFd + 1; i++ { for i := p.lastFd; i < p.maxFd+1; i++ {
if syscall.FDIsSet(i, p.readyReadFds) { if syscall.FDIsSet(i, p.readyReadFds) {
flag = true flag = true
mode = 'r' mode = 'r'
...@@ -139,6 +139,6 @@ func (p *pollster) WaitFD(s *pollServer, nsec int64) (fd int, mode int, err os.E ...@@ -139,6 +139,6 @@ func (p *pollster) WaitFD(s *pollServer, nsec int64) (fd int, mode int, err os.E
return -1, 0, nil return -1, 0, nil
} }
func (p *pollster) Close() os.Error { func (p *pollster) Close() error {
return nil return nil
} }
...@@ -8,7 +8,7 @@ package os ...@@ -8,7 +8,7 @@ package os
import "syscall" import "syscall"
func Hostname() (name string, err Error) { func Hostname() (name string, err error) {
var u syscall.Utsname var u syscall.Utsname
if errno := syscall.Uname(&u); errno != 0 { if errno := syscall.Uname(&u); errno != 0 {
return "", NewSyscallError("uname", errno) return "", NewSyscallError("uname", errno)
......
...@@ -10,11 +10,10 @@ package syslog ...@@ -10,11 +10,10 @@ package syslog
import ( import (
"fmt" "fmt"
"os"
"syscall" "syscall"
) )
func unixSyslog() (conn serverConn, err os.Error) { func unixSyslog() (conn serverConn, err error) {
return libcConn(0), nil return libcConn(0), nil
} }
...@@ -22,16 +21,16 @@ type libcConn int ...@@ -22,16 +21,16 @@ type libcConn int
func syslog_c(int, *byte) func syslog_c(int, *byte)
func (libcConn) writeBytes(p Priority, prefix string, b []byte) (int, os.Error) { func (libcConn) writeBytes(p Priority, prefix string, b []byte) (int, error) {
syslog_c(int(p), syscall.StringBytePtr(fmt.Sprintf("%s: %s", prefix, b))) syslog_c(int(p), syscall.StringBytePtr(fmt.Sprintf("%s: %s", prefix, b)))
return len(b), nil return len(b), nil
} }
func (libcConn) writeString(p Priority, prefix string, s string) (int, os.Error) { func (libcConn) writeString(p Priority, prefix string, s string) (int, error) {
syslog_c(int(p), syscall.StringBytePtr(fmt.Sprintf("%s: %s", prefix, s))) syslog_c(int(p), syscall.StringBytePtr(fmt.Sprintf("%s: %s", prefix, s)))
return len(s), nil return len(s), nil
} }
func (libcConn) close() os.Error { func (libcConn) close() error {
return nil return nil
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment