2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-24 21:57:41 +00:00

Replace lots of unused parameters with _

The parameters are required by the implemented function signature or interface.
This commit is contained in:
Michael Eischer 2023-05-18 19:27:38 +02:00
parent d1a5ec7839
commit 472bf5184f
19 changed files with 30 additions and 30 deletions

View File

@ -1181,7 +1181,7 @@ type emptySaveBackend struct {
restic.Backend restic.Backend
} }
func (b *emptySaveBackend) Save(ctx context.Context, h restic.Handle, rd restic.RewindReader) error { func (b *emptySaveBackend) Save(ctx context.Context, h restic.Handle, _ restic.RewindReader) error {
return b.Backend.Save(ctx, h, restic.NewByteReader([]byte{}, nil)) return b.Backend.Save(ctx, h, restic.NewByteReader([]byte{}, nil))
} }
@ -2202,7 +2202,7 @@ type writeToOnly struct {
rd io.Reader rd io.Reader
} }
func (r *writeToOnly) Read(p []byte) (n int, err error) { func (r *writeToOnly) Read(_ []byte) (n int, err error) {
return 0, fmt.Errorf("should have called WriteTo instead") return 0, fmt.Errorf("should have called WriteTo instead")
} }

View File

@ -22,7 +22,7 @@ type saveFail struct {
failAt int32 failAt int32
} }
func (b *saveFail) SaveBlob(_ context.Context, t restic.BlobType, buf []byte, id restic.ID, storeDuplicates bool) (restic.ID, bool, int, error) { func (b *saveFail) SaveBlob(_ context.Context, _ restic.BlobType, _ []byte, id restic.ID, _ bool) (restic.ID, bool, int, error) {
val := atomic.AddInt32(&b.cnt, 1) val := atomic.AddInt32(&b.cnt, 1)
if val == b.failAt { if val == b.failAt {
return restic.ID{}, false, 0, errTest return restic.ID{}, false, 0, errTest

View File

@ -12,7 +12,7 @@ import (
"golang.org/x/sync/errgroup" "golang.org/x/sync/errgroup"
) )
func treeSaveHelper(_ context.Context, t restic.BlobType, buf *Buffer, cb func(res SaveBlobResponse)) { func treeSaveHelper(_ context.Context, _ restic.BlobType, buf *Buffer, cb func(res SaveBlobResponse)) {
cb(SaveBlobResponse{ cb(SaveBlobResponse{
id: restic.NewRandomID(), id: restic.NewRandomID(),
known: false, known: false,

View File

@ -154,7 +154,7 @@ type mockReader struct {
closed bool closed bool
} }
func (rd *mockReader) Read(p []byte) (n int, err error) { func (rd *mockReader) Read(_ []byte) (n int, err error) {
return 0, nil return 0, nil
} }
func (rd *mockReader) Close() error { func (rd *mockReader) Close() error {

View File

@ -322,7 +322,7 @@ func (k *Key) Seal(dst, nonce, plaintext, additionalData []byte) []byte {
// //
// Even if the function fails, the contents of dst, up to its capacity, // Even if the function fails, the contents of dst, up to its capacity,
// may be overwritten. // may be overwritten.
func (k *Key) Open(dst, nonce, ciphertext, additionalData []byte) ([]byte, error) { func (k *Key) Open(dst, nonce, ciphertext, _ []byte) ([]byte, error) {
if !k.Valid() { if !k.Valid() {
return nil, errors.New("invalid key") return nil, errors.New("invalid key")
} }

View File

@ -35,7 +35,7 @@ var _ FS = &Reader{}
// VolumeName returns leading volume name, for the Reader file system it's // VolumeName returns leading volume name, for the Reader file system it's
// always the empty string. // always the empty string.
func (fs *Reader) VolumeName(path string) string { func (fs *Reader) VolumeName(_ string) string {
return "" return ""
} }
@ -76,7 +76,7 @@ func (fs *Reader) fi() os.FileInfo {
// (O_RDONLY etc.) and perm, (0666 etc.) if applicable. If successful, // (O_RDONLY etc.) and perm, (0666 etc.) if applicable. If successful,
// methods on the returned File can be used for I/O. // methods on the returned File can be used for I/O.
// If there is an error, it will be of type *os.PathError. // If there is an error, it will be of type *os.PathError.
func (fs *Reader) OpenFile(name string, flag int, perm os.FileMode) (f File, err error) { func (fs *Reader) OpenFile(name string, flag int, _ os.FileMode) (f File, err error) {
if flag & ^(O_RDONLY|O_NOFOLLOW) != 0 { if flag & ^(O_RDONLY|O_NOFOLLOW) != 0 {
return nil, pathError("open", name, return nil, pathError("open", name,
fmt.Errorf("invalid combination of flags 0x%x", flag)) fmt.Errorf("invalid combination of flags 0x%x", flag))
@ -149,7 +149,7 @@ func (fs *Reader) Separator() string {
} }
// IsAbs reports whether the path is absolute. For the Reader, this is always the case. // IsAbs reports whether the path is absolute. For the Reader, this is always the case.
func (fs *Reader) IsAbs(p string) bool { func (fs *Reader) IsAbs(_ string) bool {
return true return true
} }
@ -236,11 +236,11 @@ func (f fakeFile) Fd() uintptr {
return 0 return 0
} }
func (f fakeFile) Readdirnames(n int) ([]string, error) { func (f fakeFile) Readdirnames(_ int) ([]string, error) {
return nil, pathError("readdirnames", f.name, os.ErrInvalid) return nil, pathError("readdirnames", f.name, os.ErrInvalid)
} }
func (f fakeFile) Readdir(n int) ([]os.FileInfo, error) { func (f fakeFile) Readdir(_ int) ([]os.FileInfo, error) {
return nil, pathError("readdir", f.name, os.ErrInvalid) return nil, pathError("readdir", f.name, os.ErrInvalid)
} }
@ -248,7 +248,7 @@ func (f fakeFile) Seek(int64, int) (int64, error) {
return 0, pathError("seek", f.name, os.ErrInvalid) return 0, pathError("seek", f.name, os.ErrInvalid)
} }
func (f fakeFile) Read(p []byte) (int, error) { func (f fakeFile) Read(_ []byte) (int, error) {
return 0, pathError("read", f.name, os.ErrInvalid) return 0, pathError("read", f.name, os.ErrInvalid)
} }

View File

@ -34,7 +34,7 @@ func HasSufficientPrivilegesForVSS() error {
// NewVssSnapshot creates a new vss snapshot. If creating the snapshots doesn't // NewVssSnapshot creates a new vss snapshot. If creating the snapshots doesn't
// finish within the timeout an error is returned. // finish within the timeout an error is returned.
func NewVssSnapshot( func NewVssSnapshot(
volume string, timeoutInSeconds uint, msgError ErrorHandler) (VssSnapshot, error) { _ string, _ uint, _ ErrorHandler) (VssSnapshot, error) {
return VssSnapshot{}, errors.New("VSS snapshots are only supported on windows") return VssSnapshot{}, errors.New("VSS snapshots are only supported on windows")
} }

View File

@ -66,7 +66,7 @@ func (f *file) Attr(_ context.Context, a *fuse.Attr) error {
} }
func (f *file) Open(_ context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error) { func (f *file) Open(_ context.Context, _ *fuse.OpenRequest, _ *fuse.OpenResponse) (fs.Handle, error) {
debug.Log("open file %v with %d blobs", f.node.Name, len(f.node.Content)) debug.Log("open file %v with %d blobs", f.node.Name, len(f.node.Content))
var bytes uint64 var bytes uint64

View File

@ -24,7 +24,7 @@ func newLink(root *Root, inode uint64, node *restic.Node) (*link, error) {
return &link{root: root, inode: inode, node: node}, nil return &link{root: root, inode: inode, node: node}, nil
} }
func (l *link) Readlink(_ context.Context, req *fuse.ReadlinkRequest) (string, error) { func (l *link) Readlink(_ context.Context, _ *fuse.ReadlinkRequest) (string, error) {
return l.node.LinkTarget, nil return l.node.LinkTarget, nil
} }

View File

@ -20,7 +20,7 @@ func newOther(root *Root, inode uint64, node *restic.Node) (*other, error) {
return &other{root: root, inode: inode, node: node}, nil return &other{root: root, inode: inode, node: node}, nil
} }
func (l *other) Readlink(_ context.Context, req *fuse.ReadlinkRequest) (string, error) { func (l *other) Readlink(_ context.Context, _ *fuse.ReadlinkRequest) (string, error) {
return l.node.LinkTarget, nil return l.node.LinkTarget, nil
} }

View File

@ -134,7 +134,7 @@ func newSnapshotLink(root *Root, inode uint64, target string, snapshot *restic.S
} }
// Readlink // Readlink
func (l *snapshotLink) Readlink(_ context.Context, req *fuse.ReadlinkRequest) (string, error) { func (l *snapshotLink) Readlink(_ context.Context, _ *fuse.ReadlinkRequest) (string, error) {
return l.target, nil return l.target, nil
} }

View File

@ -166,7 +166,7 @@ func (r ForbiddenRepo) LoadBlob(context.Context, restic.BlobType, restic.ID, []b
return nil, errors.New("should not be called") return nil, errors.New("should not be called")
} }
func (r ForbiddenRepo) LookupBlobSize(id restic.ID, tpe restic.BlobType) (uint, bool) { func (r ForbiddenRepo) LookupBlobSize(_ restic.ID, _ restic.BlobType) (uint, bool) {
return 0, false return 0, false
} }

View File

@ -136,7 +136,7 @@ func y(d time.Time, _ int) int {
} }
// always returns a unique number for d. // always returns a unique number for d.
func always(d time.Time, nr int) int { func always(_ time.Time, nr int) int {
return nr return nr
} }

View File

@ -73,9 +73,9 @@ type printerMock struct {
filesFinished, filesTotal, allBytesWritten, allBytesTotal uint64 filesFinished, filesTotal, allBytesWritten, allBytesTotal uint64
} }
func (p *printerMock) Update(filesFinished, filesTotal, allBytesWritten, allBytesTotal uint64, duration time.Duration) { func (p *printerMock) Update(_, _, _, _ uint64, _ time.Duration) {
} }
func (p *printerMock) Finish(filesFinished, filesTotal, allBytesWritten, allBytesTotal uint64, duration time.Duration) { func (p *printerMock) Finish(filesFinished, filesTotal, allBytesWritten, allBytesTotal uint64, _ time.Duration) {
p.filesFinished = filesFinished p.filesFinished = filesFinished
p.filesTotal = filesTotal p.filesTotal = filesTotal
p.allBytesWritten = allBytesWritten p.allBytesWritten = allBytesWritten

View File

@ -4,7 +4,7 @@
package selfupdate package selfupdate
// Remove the target binary. // Remove the target binary.
func removeResticBinary(dir, target string) error { func removeResticBinary(_, _ string) error {
// removed on rename on this platform // removed on rename on this platform
return nil return nil
} }

View File

@ -72,13 +72,13 @@ func (b *TextProgress) Update(total, processed Counter, errors uint, currentFile
// ScannerError is the error callback function for the scanner, it prints the // ScannerError is the error callback function for the scanner, it prints the
// error in verbose mode and returns nil. // error in verbose mode and returns nil.
func (b *TextProgress) ScannerError(item string, err error) error { func (b *TextProgress) ScannerError(_ string, err error) error {
b.V("scan: %v\n", err) b.V("scan: %v\n", err)
return nil return nil
} }
// Error is the error callback function for the archiver, it prints the error and returns nil. // Error is the error callback function for the archiver, it prints the error and returns nil.
func (b *TextProgress) Error(item string, err error) error { func (b *TextProgress) Error(_ string, err error) error {
b.E("error: %v\n", err) b.E("error: %v\n", err)
return nil return nil
} }
@ -126,7 +126,7 @@ func (b *TextProgress) Reset() {
} }
// Finish prints the finishing messages. // Finish prints the finishing messages.
func (b *TextProgress) Finish(snapshotID restic.ID, start time.Time, summary *Summary, dryRun bool) { func (b *TextProgress) Finish(_ restic.ID, start time.Time, summary *Summary, dryRun bool) {
b.P("\n") b.P("\n")
b.P("Files: %5d new, %5d changed, %5d unmodified\n", summary.Files.New, summary.Files.Changed, summary.Files.Unchanged) b.P("Files: %5d new, %5d changed, %5d unmodified\n", summary.Files.New, summary.Files.Changed, summary.Files.Unchanged)
b.P("Dirs: %5d new, %5d changed, %5d unmodified\n", summary.Dirs.New, summary.Dirs.Changed, summary.Dirs.Unchanged) b.P("Dirs: %5d new, %5d changed, %5d unmodified\n", summary.Dirs.New, summary.Dirs.Changed, summary.Dirs.Unchanged)

View File

@ -25,7 +25,7 @@ const mockFinishDuration = 42 * time.Second
func (p *mockPrinter) Update(filesFinished, filesTotal, allBytesWritten, allBytesTotal uint64, duration time.Duration) { func (p *mockPrinter) Update(filesFinished, filesTotal, allBytesWritten, allBytesTotal uint64, duration time.Duration) {
p.trace = append(p.trace, printerTraceEntry{filesFinished, filesTotal, allBytesWritten, allBytesTotal, duration, false}) p.trace = append(p.trace, printerTraceEntry{filesFinished, filesTotal, allBytesWritten, allBytesTotal, duration, false})
} }
func (p *mockPrinter) Finish(filesFinished, filesTotal, allBytesWritten, allBytesTotal uint64, duration time.Duration) { func (p *mockPrinter) Finish(filesFinished, filesTotal, allBytesWritten, allBytesTotal uint64, _ time.Duration) {
p.trace = append(p.trace, printerTraceEntry{filesFinished, filesTotal, allBytesWritten, allBytesTotal, mockFinishDuration, true}) p.trace = append(p.trace, printerTraceEntry{filesFinished, filesTotal, allBytesWritten, allBytesTotal, mockFinishDuration, true})
} }

View File

@ -15,7 +15,7 @@ const (
// posixClearCurrentLine removes all characters from the current line and resets the // posixClearCurrentLine removes all characters from the current line and resets the
// cursor position to the first column. // cursor position to the first column.
func posixClearCurrentLine(wr io.Writer, fd uintptr) { func posixClearCurrentLine(wr io.Writer, _ uintptr) {
// clear current line // clear current line
_, err := wr.Write([]byte(posixControlMoveCursorHome + posixControlClearLine)) _, err := wr.Write([]byte(posixControlMoveCursorHome + posixControlClearLine))
if err != nil { if err != nil {
@ -25,7 +25,7 @@ func posixClearCurrentLine(wr io.Writer, fd uintptr) {
} }
// posixMoveCursorUp moves the cursor to the line n lines above the current one. // posixMoveCursorUp moves the cursor to the line n lines above the current one.
func posixMoveCursorUp(wr io.Writer, fd uintptr, n int) { func posixMoveCursorUp(wr io.Writer, _ uintptr, n int) {
data := []byte(posixControlMoveCursorHome) data := []byte(posixControlMoveCursorHome)
data = append(data, bytes.Repeat([]byte(posixControlMoveCursorUp), n)...) data = append(data, bytes.Repeat([]byte(posixControlMoveCursorUp), n)...)
_, err := wr.Write(data) _, err := wr.Write(data)

View File

@ -45,7 +45,7 @@ var (
// windowsClearCurrentLine removes all characters from the current line and // windowsClearCurrentLine removes all characters from the current line and
// resets the cursor position to the first column. // resets the cursor position to the first column.
func windowsClearCurrentLine(wr io.Writer, fd uintptr) { func windowsClearCurrentLine(_ io.Writer, fd uintptr) {
var info windows.ConsoleScreenBufferInfo var info windows.ConsoleScreenBufferInfo
windows.GetConsoleScreenBufferInfo(windows.Handle(fd), &info) windows.GetConsoleScreenBufferInfo(windows.Handle(fd), &info)
@ -61,7 +61,7 @@ func windowsClearCurrentLine(wr io.Writer, fd uintptr) {
} }
// windowsMoveCursorUp moves the cursor to the line n lines above the current one. // windowsMoveCursorUp moves the cursor to the line n lines above the current one.
func windowsMoveCursorUp(wr io.Writer, fd uintptr, n int) { func windowsMoveCursorUp(_ io.Writer, fd uintptr, n int) {
var info windows.ConsoleScreenBufferInfo var info windows.ConsoleScreenBufferInfo
windows.GetConsoleScreenBufferInfo(windows.Handle(fd), &info) windows.GetConsoleScreenBufferInfo(windows.Handle(fd), &info)