Remove unneeded conversion
Those are the cases where the value being converted is already of that type (checked to be that way for all os/arch combinations). Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
parent
29a197522e
commit
b7fb12e894
|
|
@ -67,8 +67,8 @@ func layers(flags *mflag.FlagSet, action string, m storage.Store, args []string)
|
|||
for _, layer := range layers {
|
||||
if listLayersTree {
|
||||
node := treeNode{
|
||||
left: string(layer.Parent),
|
||||
right: string(layer.ID),
|
||||
left: layer.Parent,
|
||||
right: layer.ID,
|
||||
notes: []string{},
|
||||
}
|
||||
if node.left == "" {
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ func supportsIdmappedLowerLayers(home string) (bool, error) {
|
|||
}
|
||||
defer cleanupFunc()
|
||||
|
||||
if err := idmap.CreateIDMappedMount(lowerDir, lowerMappedDir, int(pid)); err != nil {
|
||||
if err := idmap.CreateIDMappedMount(lowerDir, lowerMappedDir, pid); err != nil {
|
||||
return false, fmt.Errorf("create mapped mount: %w", err)
|
||||
}
|
||||
defer func() {
|
||||
|
|
|
|||
|
|
@ -492,7 +492,7 @@ func parseOptions(options []string) (*overlayOptions, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
o.quota.Inodes = uint64(inodes)
|
||||
o.quota.Inodes = inodes
|
||||
case "imagestore", "additionalimagestore":
|
||||
logrus.Debugf("overlay: imagestore=%s", val)
|
||||
// Additional read only image stores to use for lower paths
|
||||
|
|
@ -1163,7 +1163,7 @@ func (d *Driver) parseStorageOpt(storageOpt map[string]string, driver *Driver) e
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
driver.options.quota.Inodes = uint64(inodes)
|
||||
driver.options.quota.Inodes = inodes
|
||||
default:
|
||||
return fmt.Errorf("unknown option %s", key)
|
||||
}
|
||||
|
|
@ -1551,7 +1551,7 @@ func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountO
|
|||
permsKnown := false
|
||||
st, err := os.Stat(filepath.Join(dir, nameWithSuffix("diff", diffN)))
|
||||
if err == nil {
|
||||
perms = os.FileMode(st.Mode())
|
||||
perms = st.Mode()
|
||||
permsKnown = true
|
||||
}
|
||||
for err == nil {
|
||||
|
|
@ -1566,7 +1566,7 @@ func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountO
|
|||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
idmappedMountProcessPid = int(pid)
|
||||
idmappedMountProcessPid = pid
|
||||
defer cleanupFunc()
|
||||
}
|
||||
|
||||
|
|
@ -1638,7 +1638,7 @@ func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountO
|
|||
lower = path.Join(p, d.name, l)
|
||||
if st2, err2 := os.Stat(lower); err2 == nil {
|
||||
if !permsKnown {
|
||||
perms = os.FileMode(st2.Mode())
|
||||
perms = st2.Mode()
|
||||
permsKnown = true
|
||||
}
|
||||
break
|
||||
|
|
@ -1659,7 +1659,7 @@ func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountO
|
|||
}
|
||||
} else {
|
||||
if !permsKnown {
|
||||
perms = os.FileMode(st.Mode())
|
||||
perms = st.Mode()
|
||||
permsKnown = true
|
||||
}
|
||||
lower = newpath
|
||||
|
|
@ -2505,7 +2505,7 @@ func (d *Driver) UpdateLayerIDMap(id string, toContainer, toHost *idtools.IDMapp
|
|||
perms = *d.options.forceMask
|
||||
} else {
|
||||
if err == nil {
|
||||
perms = os.FileMode(st.Mode())
|
||||
perms = st.Mode()
|
||||
}
|
||||
}
|
||||
for err == nil {
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ func (d *dedupFiles) dedup(src, dst string, fiDst fs.FileInfo) (uint64, error) {
|
|||
}
|
||||
err = unix.IoctlFileDedupeRange(int(srcFile.Fd()), &value)
|
||||
if err == nil {
|
||||
return uint64(value.Info[0].Bytes_deduped), nil
|
||||
return value.Info[0].Bytes_deduped, nil
|
||||
}
|
||||
|
||||
if errors.Is(err, unix.ENOTSUP) {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ func NewListOptsRef(values *[]string, validator ValidatorFctType) *ListOpts {
|
|||
}
|
||||
|
||||
func (opts *ListOpts) String() string {
|
||||
return fmt.Sprintf("%v", []string((*opts.values)))
|
||||
return fmt.Sprintf("%v", *opts.values)
|
||||
}
|
||||
|
||||
// Set validates if needed the input value and adds it to the
|
||||
|
|
@ -150,7 +150,7 @@ func (opts *MapOpts) GetAll() map[string]string {
|
|||
}
|
||||
|
||||
func (opts *MapOpts) String() string {
|
||||
return fmt.Sprintf("%v", map[string]string((opts.values)))
|
||||
return fmt.Sprintf("%v", opts.values)
|
||||
}
|
||||
|
||||
// Type returns a string name for this Option type
|
||||
|
|
|
|||
|
|
@ -1406,7 +1406,7 @@ func remapIDs(readIDMappings, writeIDMappings *idtools.IDMappings, chownOpts *id
|
|||
} else if runtime.GOOS == darwin {
|
||||
uid, gid = hdr.Uid, hdr.Gid
|
||||
if xstat, ok := hdr.PAXRecords[PaxSchilyXattr+idtools.ContainersOverrideXattr]; ok {
|
||||
attrs := strings.Split(string(xstat), ":")
|
||||
attrs := strings.Split(xstat, ":")
|
||||
if len(attrs) >= 3 {
|
||||
val, err := strconv.ParseUint(attrs[0], 10, 32)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ func (bf *bloomFilter) writeTo(writer io.Writer) error {
|
|||
if err := binary.Write(writer, binary.LittleEndian, uint64(len(bf.bitArray))); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := binary.Write(writer, binary.LittleEndian, uint32(bf.k)); err != nil {
|
||||
if err := binary.Write(writer, binary.LittleEndian, bf.k); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := binary.Write(writer, binary.LittleEndian, bf.bitArray); err != nil {
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ func FuzzReadCache(f *testing.F) {
|
|||
dest = nil
|
||||
|
||||
f.Fuzz(func(t *testing.T, orig []byte) {
|
||||
cacheRead, err := readCacheFileFromMemory([]byte(orig))
|
||||
cacheRead, err := readCacheFileFromMemory(orig)
|
||||
if err != nil || cacheRead == nil {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ func readEstargzChunkedManifest(blobStream ImageSourceSeekable, blobSize int64,
|
|||
return nil, 0, fmt.Errorf("parse ToC offset: %w", err)
|
||||
}
|
||||
|
||||
size := int64(blobSize - footerSize - tocOffset)
|
||||
size := blobSize - footerSize - tocOffset
|
||||
// set a reasonable limit
|
||||
if size > maxTocSize {
|
||||
// Not errFallbackCanConvert: we would still use too much memory.
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ func escaped(val []byte, escape int) string {
|
|||
}
|
||||
|
||||
var result string
|
||||
for _, c := range []byte(val) {
|
||||
for _, c := range val {
|
||||
hexEscape := false
|
||||
var special string
|
||||
|
||||
|
|
|
|||
|
|
@ -234,7 +234,7 @@ func WriteZstdChunkedManifest(dest io.Writer, outMetadata map[string]string, off
|
|||
Offset: manifestOffset,
|
||||
LengthCompressed: uint64(len(compressedManifest)),
|
||||
LengthUncompressed: uint64(len(manifest)),
|
||||
OffsetTarSplit: uint64(tarSplitOffset),
|
||||
OffsetTarSplit: tarSplitOffset,
|
||||
LengthCompressedTarSplit: uint64(len(tarSplitData.Data)),
|
||||
LengthUncompressedTarSplit: uint64(tarSplitData.UncompressedSize),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1011,7 +1011,7 @@ func mergeMissingChunks(missingParts []missingPart, target int) []missingPart {
|
|||
!missingParts[prevIndex].Hole && !missingParts[i].Hole &&
|
||||
len(missingParts[prevIndex].Chunks) == 1 && len(missingParts[i].Chunks) == 1 &&
|
||||
missingParts[prevIndex].Chunks[0].File.Name == missingParts[i].Chunks[0].File.Name {
|
||||
missingParts[prevIndex].SourceChunk.Length += uint64(gap) + missingParts[i].SourceChunk.Length
|
||||
missingParts[prevIndex].SourceChunk.Length += gap + missingParts[i].SourceChunk.Length
|
||||
missingParts[prevIndex].Chunks[0].CompressedSize += missingParts[i].Chunks[0].CompressedSize
|
||||
missingParts[prevIndex].Chunks[0].UncompressedSize += missingParts[i].Chunks[0].UncompressedSize
|
||||
} else {
|
||||
|
|
@ -1069,7 +1069,7 @@ func mergeMissingChunks(missingParts []missingPart, target int) []missingPart {
|
|||
} else {
|
||||
gap := getGap(missingParts, i)
|
||||
prev := &newMissingParts[len(newMissingParts)-1]
|
||||
prev.SourceChunk.Length += uint64(gap) + missingParts[i].SourceChunk.Length
|
||||
prev.SourceChunk.Length += gap + missingParts[i].SourceChunk.Length
|
||||
prev.Hole = false
|
||||
prev.OriginFile = nil
|
||||
if gap > 0 {
|
||||
|
|
@ -1761,7 +1761,7 @@ func (c *chunkedDiffer) ApplyDiff(dest string, options *archive.TarOptions, diff
|
|||
|
||||
// the file is missing, attempt to find individual chunks.
|
||||
for _, chunk := range r.chunks {
|
||||
compressedSize := int64(chunk.EndOffset - chunk.Offset)
|
||||
compressedSize := chunk.EndOffset - chunk.Offset
|
||||
size := remainingSize
|
||||
if chunk.ChunkSize > 0 {
|
||||
size = chunk.ChunkSize
|
||||
|
|
|
|||
|
|
@ -42,13 +42,11 @@ func Usage(dir string) (usage *DiskUsage, err error) {
|
|||
|
||||
// Check inode to only count the sizes of files with multiple hard links once.
|
||||
inode := fileInfo.Sys().(*syscall.Stat_t).Ino
|
||||
// inode is not a uint64 on all platforms. Cast it to avoid issues.
|
||||
if _, exists := data[uint64(inode)]; exists {
|
||||
if _, exists := data[inode]; exists {
|
||||
return nil
|
||||
}
|
||||
|
||||
// inode is not a uint64 on all platforms. Cast it to avoid issues.
|
||||
data[uint64(inode)] = struct{}{}
|
||||
data[inode] = struct{}{}
|
||||
// Ignore directory sizes
|
||||
if entry.IsDir() {
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ func TestAtomicWriteToFile(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("Error statting file: %v", err)
|
||||
}
|
||||
if expected := os.FileMode(testMode); st.Mode() != expected {
|
||||
if expected := testMode; st.Mode() != expected {
|
||||
t.Fatalf("Mode mismatched, expected %o, got %o", expected, st.Mode())
|
||||
}
|
||||
}
|
||||
|
|
@ -131,7 +131,7 @@ func TestAtomicWriteSetCommit(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("Error statting file: %v", err)
|
||||
}
|
||||
if expected := os.FileMode(testMode); st.Mode() != expected {
|
||||
if expected := testMode; st.Mode() != expected {
|
||||
t.Fatalf("Mode mismatched, expected %o, got %o", expected, st.Mode())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ func FindLoopDeviceFor(file *os.File) *os.File {
|
|||
}
|
||||
|
||||
dev, inode, err := getLoopbackBackingFile(file)
|
||||
if err == nil && dev == uint64(targetDevice) && inode == targetInode {
|
||||
if err == nil && dev == targetDevice && inode == targetInode {
|
||||
return file
|
||||
}
|
||||
file.Close()
|
||||
|
|
|
|||
Loading…
Reference in New Issue