Browse Source

pkg/{chroot,}archive: clean up a few small issues

Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
unclejack 8 years ago
parent
commit
087f7307a6

+ 1 - 1
pkg/archive/archive.go

@@ -145,7 +145,7 @@ func DetectCompression(source []byte) Compression {
 			logrus.Debug("Len too short")
 			continue
 		}
-		if bytes.Compare(m, source[:len(m)]) == 0 {
+		if bytes.Equal(m, source[:len(m)]) {
 			return compression
 		}
 	}

+ 1 - 4
pkg/archive/archive_unix.go

@@ -107,10 +107,7 @@ func handleTarTypeBlockCharFifo(hdr *tar.Header, path string) error {
 		mode |= syscall.S_IFIFO
 	}
 
-	if err := system.Mknod(path, mode, int(system.Mkdev(hdr.Devmajor, hdr.Devminor))); err != nil {
-		return err
-	}
-	return nil
+	return system.Mknod(path, mode, int(system.Mkdev(hdr.Devmajor, hdr.Devminor)))
 }
 
 func handleLChmod(hdr *tar.Header, path string, hdrInfo os.FileInfo) error {

+ 2 - 2
pkg/archive/changes.go

@@ -267,7 +267,7 @@ func (info *FileInfo) addChanges(oldInfo *FileInfo, changes *[]Change) {
 	}
 
 	for name, newChild := range info.children {
-		oldChild, _ := oldChildren[name]
+		oldChild := oldChildren[name]
 		if oldChild != nil {
 			// change?
 			oldStat := oldChild.stat
@@ -279,7 +279,7 @@ func (info *FileInfo) addChanges(oldInfo *FileInfo, changes *[]Change) {
 			// breaks down is if some code intentionally hides a change by setting
 			// back mtime
 			if statDifferent(oldStat, newStat) ||
-				bytes.Compare(oldChild.capability, newChild.capability) != 0 {
+				!bytes.Equal(oldChild.capability, newChild.capability) {
 				change := Change{
 					Path: newChild.path(),
 					Kind: ChangeModify,

+ 1 - 1
pkg/chrootarchive/archive_test.go

@@ -77,7 +77,7 @@ func TestChrootUntarWithHugeExcludesList(t *testing.T) {
 	options := &archive.TarOptions{}
 	//65534 entries of 64-byte strings ~= 4MB of environment space which should overflow
 	//on most systems when passed via environment or command line arguments
-	excludes := make([]string, 65534, 65534)
+	excludes := make([]string, 65534)
 	for i := 0; i < 65534; i++ {
 		excludes[i] = strings.Repeat(string(i), 64)
 	}