Browse code

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

Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>

unclejack authored on 2017/03/30 18:04:42
Showing 4 changed files
... ...
@@ -145,7 +145,7 @@ func DetectCompression(source []byte) Compression {
145 145
 			logrus.Debug("Len too short")
146 146
 			continue
147 147
 		}
148
-		if bytes.Compare(m, source[:len(m)]) == 0 {
148
+		if bytes.Equal(m, source[:len(m)]) {
149 149
 			return compression
150 150
 		}
151 151
 	}
... ...
@@ -107,10 +107,7 @@ func handleTarTypeBlockCharFifo(hdr *tar.Header, path string) error {
107 107
 		mode |= syscall.S_IFIFO
108 108
 	}
109 109
 
110
-	if err := system.Mknod(path, mode, int(system.Mkdev(hdr.Devmajor, hdr.Devminor))); err != nil {
111
-		return err
112
-	}
113
-	return nil
110
+	return system.Mknod(path, mode, int(system.Mkdev(hdr.Devmajor, hdr.Devminor)))
114 111
 }
115 112
 
116 113
 func handleLChmod(hdr *tar.Header, path string, hdrInfo os.FileInfo) error {
... ...
@@ -267,7 +267,7 @@ func (info *FileInfo) addChanges(oldInfo *FileInfo, changes *[]Change) {
267 267
 	}
268 268
 
269 269
 	for name, newChild := range info.children {
270
-		oldChild, _ := oldChildren[name]
270
+		oldChild := oldChildren[name]
271 271
 		if oldChild != nil {
272 272
 			// change?
273 273
 			oldStat := oldChild.stat
... ...
@@ -279,7 +279,7 @@ func (info *FileInfo) addChanges(oldInfo *FileInfo, changes *[]Change) {
279 279
 			// breaks down is if some code intentionally hides a change by setting
280 280
 			// back mtime
281 281
 			if statDifferent(oldStat, newStat) ||
282
-				bytes.Compare(oldChild.capability, newChild.capability) != 0 {
282
+				!bytes.Equal(oldChild.capability, newChild.capability) {
283 283
 				change := Change{
284 284
 					Path: newChild.path(),
285 285
 					Kind: ChangeModify,
... ...
@@ -77,7 +77,7 @@ func TestChrootUntarWithHugeExcludesList(t *testing.T) {
77 77
 	options := &archive.TarOptions{}
78 78
 	//65534 entries of 64-byte strings ~= 4MB of environment space which should overflow
79 79
 	//on most systems when passed via environment or command line arguments
80
-	excludes := make([]string, 65534, 65534)
80
+	excludes := make([]string, 65534)
81 81
 	for i := 0; i < 65534; i++ {
82 82
 		excludes[i] = strings.Repeat(string(i), 64)
83 83
 	}