lib9p

Go 9P library.
Log | Files | Refs | LICENSE

commit 3df539f8394d9564a7f618c4d9f9911a6b4766f8
parent fd8f465766d4ffac414de251ec99faae4336519b
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Fri, 19 Jan 2024 14:38:21 +0900

review

Diffstat:
Mclient/client.go | 11++++++-----
Mclient/file.go | 8++++----
Mclient/fs.go | 2+-
3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/client/client.go b/client/client.go @@ -105,7 +105,8 @@ func (c *Client) runErrorReporter(ctx context.Context) { // RunListener runs listener goroutine. // Listener reads byte array of 9P messages from r and make each of them into -// corresponding struct that implements lib9p.Msg, and sends it to the returned channel. +// corresponding struct that implements lib9p.Msg, +// and sends it to the returned channel. // Listener goroutine returns when ctx is canceled. // Listener goroutine reports errors to the client's errc channel. func (c *Client) runListener(ctx context.Context, r io.Reader) <-chan lib9p.Msg { @@ -154,8 +155,8 @@ func (c *Client) runListener(ctx context.Context, r io.Reader) <-chan lib9p.Msg } // RunSpeaker runs speaker goroutine. -// Speaker goroutine recieves 9P lib9p.Msgs from the returned channel, marshal them -// into byte arrays and sends them to w. +// Speaker goroutine recieves 9P lib9p.Msgs from the returned channel, +// marshal them into byte arrays and sends them to w. // It reports any errors to the clients errc channel. // It returnes when ctx is canceled. func (c *Client) runSpeaker(ctx context.Context, w io.Writer) chan<- lib9p.Msg { @@ -180,10 +181,10 @@ func (c *Client) runSpeaker(ctx context.Context, w io.Writer) chan<- lib9p.Msg { return tmsgc } -// RunMultiplexer runs multiplexer goroutines, +// RunMultiplexer runs two goroutines, // one for recieving Rmsg and another for sending Tmsg. // The goroutine for Tmsg recieves *req from the returned channel, -// and send the 9P lib9p.Msg to the speaker goroutine via tmsgc. +// and send the lib9p.Msg to the speaker goroutine via tmsgc. // The goroutine for Rmsg recieves *req from the Tmsg goroutine and waits for // the reply to the corresponding message from the listener goroutine via rmsgc. // After recieving the reply, it sets the *req.rmsg and sends it to the diff --git a/client/file.go b/client/file.go @@ -55,14 +55,14 @@ func (cf *File) Read(b []byte) (int, error) { if cf.fid.omode&3 != lib9p.OREAD && cf.fid.omode&3 != lib9p.ORDWR { return 0, lib9p.ErrPerm } - count := uint32(len(b)) + count := len(b) cur := 0 for count > 0 { var c uint32 - if count > cf.iounit { + if uint32(count) > cf.iounit { c = cf.iounit } else { - c = count + c = uint32(count) } tag, err := cf.fs.tPool.add() if err != nil { @@ -79,7 +79,7 @@ func (cf *File) Read(b []byte) (int, error) { if err != nil { return cur, err } - count -= c + count -= int(c) } if cur == 0 { return 0, io.EOF diff --git a/client/fs.go b/client/fs.go @@ -48,7 +48,7 @@ func (fsys *FS) OpenFile(name string, flag int) (lib9p.File, error) { // CleanPath cleans name. // It first call path.Clean(name) and then -// delete trailing ".." elements. +// delete leading ".." elements. func CleanPath(name string) string { name = path.Clean(name) for strings.HasPrefix(name, "../") {