Skip to content

Commit

Permalink
Fix lint warning
Browse files Browse the repository at this point in the history
Signed-off-by: Lei Jitang <leijitang@huawei.com>
  • Loading branch information
coolljt0725 committed Sep 30, 2016
1 parent a8bafa4 commit 2c1c223
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
17 changes: 6 additions & 11 deletions image/change.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,6 @@ func (c changesByPath) Less(i, j int) bool { return c[i].Path < c[j].Path }
func (c changesByPath) Len() int { return len(c) }
func (c changesByPath) Swap(i, j int) { c[j], c[i] = c[i], c[j] }

// Gnu tar and the go tar writer don't have sub-second mtime
// precision, which is problematic when we apply changes via tar
// files, we handle this by comparing for exact times, *or* same
// second count and either a or b having exactly 0 nanoseconds
func sameFsTime(a, b time.Time) bool {
return a == b ||
(a.Unix() == b.Unix() &&
(a.Nanosecond() == 0 || b.Nanosecond() == 0))
}

func sameFsTimeSpec(a, b syscall.Timespec) bool {
return a.Sec == b.Sec &&
(a.Nsec == b.Nsec || a.Nsec == 0 || b.Nsec == 0)
Expand Down Expand Up @@ -218,7 +208,12 @@ func ChangesDirs(newDir, oldDir string) ([]Change, error) {
if err != nil {
return nil, err
}
defer os.Remove(emptyDir)
defer func() {
err := os.Remove(emptyDir)
if err != nil {
logrus.Debugf("failed to remove tmp dir: %v", err)
}
}()
oldDir = emptyDir
}
oldRoot, newRoot, err := collectFileInfoForChanges(oldDir, newDir)
Expand Down
10 changes: 1 addition & 9 deletions image/change_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func walkchunk(path string, fi os.FileInfo, dir string, root *FileInfo) error {

// Walk a subtree rooted at the same path in both trees being iterated. For
// example, /oci/overlay/1234/a/b/c/d and /oci/overlay/8888/a/b/c/d
func (w *filewalker) walk(path string, i1, i2 os.FileInfo) (err error) {
func (w *filewalker) walk(path string, i1, i2 os.FileInfo) (retErr error) {
// Register these nodes with the return trees, unless we're still at the
// (already-created) roots:
if path != "/" {
Expand Down Expand Up @@ -315,11 +315,3 @@ func statDifferent(oldStat *utils.StatT, newStat *utils.StatT) bool {
func (info *FileInfo) isDir() bool {
return info.parent == nil || info.stat.Mode()&syscall.S_IFDIR != 0
}

func getIno(fi os.FileInfo) uint64 {
return uint64(fi.Sys().(*syscall.Stat_t).Ino)
}

func hasHardlinks(fi os.FileInfo) bool {
return fi.Sys().(*syscall.Stat_t).Nlink > 1
}
1 change: 1 addition & 0 deletions image/layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"path/filepath"
)

// CreateLayer create layer from filesystem changeset
func CreateLayer(child, parent, dest string) error {
arch, err := Diff(child, parent)
if err != nil {
Expand Down

0 comments on commit 2c1c223

Please sign in to comment.