commit bdedd3ea2a8a5beb1c22f46ddfb63267f0a1b96a
parent b6b1b1994a1a761b65df60ab3b8ea9d2297d358c
Author: Matsuda Kenji <info@mtkn.jp>
Date: Fri, 5 Jan 2024 09:48:37 +0900
go vet
Diffstat:
8 files changed, 12 insertions(+), 64 deletions(-)
diff --git a/client/client_test.go b/client/client_test.go
@@ -152,7 +152,7 @@ func TestAuth(t *testing.T) {
&lib9p.RError{Tag: 0, Ename: errors.New("authentication not required.")}},
{"1",
&lib9p.TAuth{Tag: 0, Afid: 0, Uname: "glenda", Aname: ""},
- &lib9p.RAuth{Tag: 0, Aqid: lib9p.Qid{0, 1, 2}}},
+ &lib9p.RAuth{Tag: 0, Aqid: lib9p.Qid{Path:1}}},
}
for _, test := range tests {
func() {
@@ -213,7 +213,7 @@ func TestAttach(t *testing.T) {
}{
{"0",
&lib9p.TAttach{Fid: 0, Afid: lib9p.NOFID, Uname: "glenda", Aname: ""},
- &lib9p.RAttach{Qid: lib9p.Qid{1, 2, 3}}},
+ &lib9p.RAttach{Qid: lib9p.Qid{Path:2}}},
{"1",
&lib9p.TAttach{Fid: 0, Afid: lib9p.NOFID, Uname: "glenda", Aname: ""},
&lib9p.RError{Ename: errors.New("authentication required")}},
@@ -333,7 +333,7 @@ func TestWalk(t *testing.T) {
}{
{"0",
&lib9p.TWalk{Fid: 0, Newfid: 1, Wnames: []string{"a", "b", "c"}},
- &lib9p.RWalk{Qids: []lib9p.Qid{lib9p.Qid{1, 2, 3}, lib9p.Qid{2, 3, 4}, lib9p.Qid{3, 4, 5}}}},
+ &lib9p.RWalk{Qids: []lib9p.Qid{lib9p.Qid{Path:0}, lib9p.Qid{Path:1}, lib9p.Qid{Path:2}}}},
{"1",
&lib9p.TWalk{Fid: 0, Newfid: 2, Wnames: []string{"a", "b", "c"}},
&lib9p.RError{Ename: errors.New("not found")}},
@@ -397,7 +397,7 @@ func TestOpen(t *testing.T) {
}{
{"0",
&lib9p.TOpen{Fid: 0, Mode: lib9p.OREAD},
- &lib9p.ROpen{Qid: lib9p.Qid{1, 2, 3}, Iounit: 1000}},
+ &lib9p.ROpen{Qid: lib9p.Qid{Path:1}, Iounit: 1000}},
{"1",
&lib9p.TOpen{Fid: 0, Mode: lib9p.OWRITE},
&lib9p.RError{Ename: errors.New("permission denied")}},
@@ -462,7 +462,7 @@ func TestCreate(t *testing.T) {
}{
{"0",
&lib9p.TCreate{Fid: 0, Name: "file", Perm: 0666, Mode: lib9p.OREAD},
- &lib9p.RCreate{Qid: lib9p.Qid{1, 2, 3}, Iounit: 1000}},
+ &lib9p.RCreate{Qid: lib9p.Qid{Path:0}, Iounit: 1000}},
{"1",
&lib9p.TCreate{Fid: 0, Name: "file", Perm: 0777, Mode: lib9p.OWRITE},
&lib9p.RError{Ename: errors.New("permission denied")}},
diff --git a/client/conn_test.go b/client/conn_test.go
@@ -1,51 +0,0 @@
-package client
-/*
-import (
- "context"
- "io"
-
- "git.mtkn.jp/lib9p"
-)
-
-type Conn struct {
- S *lib9p.Server
- C *Client
- cr, sr *io.PipeReader
- cw, sw *io.PipeWriter
- cancel context.CancelFunc
-}
-
-// SetupTestConn setups a connection between a server and a client and
-// returns those.
-func SetupConn() *Conn {
- const (
- mSize = 8 * 1024
- uname = "kenji"
- )
- cr, sw := io.Pipe()
- sr, cw := io.Pipe()
- // TODO: fix the inconsistency of server and client api.
- s := lib9p.NewServer(Fsys)
- clnt := NewClient(mSize, uname, cr, cw)
- ctx, cancel := context.WithCancel(context.Background())
- go s.Serve(ctx, sr, sw)
- return &Conn{
- S: s,
- C: clnt,
- cr: cr,
- cw: cw,
- sr: sr,
- sw: sw,
- cancel: cancel,
- }
-}
-
-func (conn *Conn) Close() {
- conn.cancel()
- conn.C.Stop()
- conn.cw.Close()
- conn.cr.Close()
- conn.sw.Close()
- conn.sr.Close()
-}
-*/
-\ No newline at end of file
diff --git a/client/fid.go b/client/fid.go
@@ -15,9 +15,9 @@ type fid struct {
file *File
}
-func newClientFid(fidnum uint32) *fid {
+func newClientFid(id uint32) *fid {
return &fid{
- fid: fidnum,
+ fid: id,
omode: -1,
offset: 0,
}
diff --git a/client/file.go b/client/file.go
@@ -30,7 +30,7 @@ func (cf *File) Stat() (*lib9p.FileInfo, error) {
if err != nil {
return nil, err
}
- return &lib9p.FileInfo{*st}, nil
+ return &lib9p.FileInfo{Stat: *st}, nil
}
// Don't use closed file.
diff --git a/cmd/diskfs/main.go b/cmd/diskfs/main.go
@@ -87,7 +87,7 @@ L:
}
func runSignalHandler() context.Context {
- quit := make(chan os.Signal)
+ quit := make(chan os.Signal, 1)
signal.Notify(quit, os.Interrupt)
ctx, cancel := context.WithCancel(context.Background())
go func() {
diff --git a/cmd/numfs/main.go b/cmd/numfs/main.go
@@ -114,7 +114,7 @@ func (f *numFile) Stat() (*lib9p.FileInfo, error) {
stat.Uid = "kenji"
stat.Gid = "kenji"
stat.Muid = "kenji"
- return &lib9p.FileInfo{stat}, nil
+ return &lib9p.FileInfo{Stat: stat}, nil
}
func (f *numFile) Qid() lib9p.Qid {
diff --git a/diskfs/stat_unix.go b/diskfs/stat_unix.go
@@ -76,7 +76,7 @@ func (f *File) stat() (*lib9p.FileInfo, error) {
if err != nil {
return nil, fmt.Errorf("fiStat: %v", err)
}
- return &lib9p.FileInfo{*stat}, nil
+ return &lib9p.FileInfo{Stat: *stat}, nil
}
// wstat is the real implementation of File.WStat.
diff --git a/iofs/file.go b/iofs/file.go
@@ -48,7 +48,7 @@ func (f *File) Stat() (*lib9p.FileInfo, error) {
stat.Uid = ""
stat.Gid = ""
stat.Muid = ""
- return &lib9p.FileInfo{stat}, nil
+ return &lib9p.FileInfo{Stat: stat}, nil
}
func (f *File) Close() error {