Fix "go tool vet -shadow=true" warnings
Among those one real bug.
This commit is contained in:
parent
bd1f17ca9f
commit
bd5405189e
@ -45,7 +45,8 @@ func BenchmarkStreamRead(t *testing.B) {
|
||||
if t.N > mb {
|
||||
// Grow file so we can satisfy the test
|
||||
//fmt.Printf("Growing file to %d MB... ", t.N)
|
||||
f2, err := os.OpenFile(fn, os.O_WRONLY|os.O_APPEND, 0666)
|
||||
var f2 *os.File
|
||||
f2, err = os.OpenFile(fn, os.O_WRONLY|os.O_APPEND, 0666)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
t.FailNow()
|
||||
|
@ -236,7 +236,8 @@ func (f *file) doWrite(data []byte, off int64) (uint32, fuse.Status) {
|
||||
if b.IsPartial() {
|
||||
// Read
|
||||
o, _ := b.PlaintextRange()
|
||||
oldData, status := f.doRead(o, f.contentEnc.PlainBS())
|
||||
var oldData []byte
|
||||
oldData, status = f.doRead(o, f.contentEnc.PlainBS())
|
||||
if status != fuse.OK {
|
||||
toggledlog.Warn.Printf("ino%d fh%d: RMW read failed: %s", f.ino, f.intFd(), status.String())
|
||||
return written, status
|
||||
|
@ -116,7 +116,8 @@ func (fs *FS) Create(path string, flags uint32, mode uint32, context *fuse.Conte
|
||||
// Handle long file name
|
||||
cName := filepath.Base(cPath)
|
||||
if nametransform.IsLongContent(cName) {
|
||||
dirfd, err := os.Open(filepath.Dir(cPath))
|
||||
var dirfd *os.File
|
||||
dirfd, err = os.Open(filepath.Dir(cPath))
|
||||
if err != nil {
|
||||
return nil, fuse.ToStatus(err)
|
||||
}
|
||||
@ -129,7 +130,8 @@ func (fs *FS) Create(path string, flags uint32, mode uint32, context *fuse.Conte
|
||||
}
|
||||
|
||||
// Create content
|
||||
fdRaw, err := syscall.Openat(int(dirfd.Fd()), cName, iflags|os.O_CREATE, mode)
|
||||
var fdRaw int
|
||||
fdRaw, err = syscall.Openat(int(dirfd.Fd()), cName, iflags|os.O_CREATE, mode)
|
||||
if err != nil {
|
||||
nametransform.DeleteLongName(dirfd, cName)
|
||||
return nil, fuse.ToStatus(err)
|
||||
@ -237,7 +239,8 @@ func (fs *FS) Readlink(path string, context *fuse.Context) (out string, status f
|
||||
}
|
||||
// Old filesystem: symlinks are encrypted like paths (CBC)
|
||||
if !fs.args.DirIV {
|
||||
target, err := fs.decryptPath(cTarget)
|
||||
var target string
|
||||
target, err = fs.decryptPath(cTarget)
|
||||
if err != nil {
|
||||
toggledlog.Warn.Printf("Readlink: CBC decryption failed: %v", err)
|
||||
return "", fuse.EIO
|
||||
@ -269,7 +272,8 @@ func (fs *FS) Unlink(path string, context *fuse.Context) (code fuse.Status) {
|
||||
|
||||
cName := filepath.Base(cPath)
|
||||
if nametransform.IsLongContent(cName) {
|
||||
dirfd, err := os.Open(filepath.Dir(cPath))
|
||||
var dirfd *os.File
|
||||
dirfd, err = os.Open(filepath.Dir(cPath))
|
||||
if err != nil {
|
||||
return fuse.ToStatus(err)
|
||||
}
|
||||
@ -303,7 +307,8 @@ func (fs *FS) Symlink(target string, linkName string, context *fuse.Context) (co
|
||||
// Before v0.5, symlinks were encrypted like paths (CBC)
|
||||
// TODO drop compatibility and simplify code?
|
||||
if !fs.args.DirIV {
|
||||
cTarget, err := fs.encryptPath(target)
|
||||
var cTarget string
|
||||
cTarget, err = fs.encryptPath(target)
|
||||
if err != nil {
|
||||
toggledlog.Warn.Printf("Symlink: BUG: we should not get an error here: %v", err)
|
||||
return fuse.ToStatus(err)
|
||||
@ -318,7 +323,8 @@ func (fs *FS) Symlink(target string, linkName string, context *fuse.Context) (co
|
||||
// Handle long file name
|
||||
cName := filepath.Base(cPath)
|
||||
if nametransform.IsLongContent(cName) {
|
||||
dirfd, err := os.Open(filepath.Dir(cPath))
|
||||
var dirfd *os.File
|
||||
dirfd, err = os.Open(filepath.Dir(cPath))
|
||||
if err != nil {
|
||||
return fuse.ToStatus(err)
|
||||
}
|
||||
|
@ -56,7 +56,8 @@ func (fs *FS) Mkdir(newPath string, mode uint32, context *fuse.Context) (code fu
|
||||
// Handle long file name
|
||||
cName := filepath.Base(cPath)
|
||||
if nametransform.IsLongContent(cName) {
|
||||
dirfd, err := os.Open(filepath.Dir(cPath))
|
||||
var dirfd *os.File
|
||||
dirfd, err = os.Open(filepath.Dir(cPath))
|
||||
if err != nil {
|
||||
return fuse.ToStatus(err)
|
||||
}
|
||||
|
6
main.go
6
main.go
@ -224,7 +224,8 @@ func main() {
|
||||
// "-cpuprofile"
|
||||
if args.cpuprofile != "" {
|
||||
toggledlog.Info.Printf("Writing CPU profile to %s", args.cpuprofile)
|
||||
f, err := os.Create(args.cpuprofile)
|
||||
var f *os.File
|
||||
f, err = os.Create(args.cpuprofile)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(ERREXIT_INIT)
|
||||
@ -235,7 +236,8 @@ func main() {
|
||||
// "-memprofile"
|
||||
if args.memprofile != "" {
|
||||
toggledlog.Info.Printf("Writing mem profile to %s", args.memprofile)
|
||||
f, err := os.Create(args.memprofile)
|
||||
var f *os.File
|
||||
f, err = os.Create(args.memprofile)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(ERREXIT_INIT)
|
||||
|
Loading…
Reference in New Issue
Block a user