treewide: remove unnecessary types and conversions

Change-Id: Ifcaa9ceeec243b3646c9b6e0a6fad7ef2db8fd90
Reviewed-on: https://review.monogon.dev/c/monogon/+/2954
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
Tested-by: Jenkins CI
diff --git a/metropolis/node/core/cluster/cluster_bootstrap.go b/metropolis/node/core/cluster/cluster_bootstrap.go
index 690af00..312874d 100644
--- a/metropolis/node/core/cluster/cluster_bootstrap.go
+++ b/metropolis/node/core/cluster/cluster_bootstrap.go
@@ -90,13 +90,13 @@
 	if err != nil {
 		return fmt.Errorf("could not generate node keypair: %w", err)
 	}
-	supervisor.Logger(ctx).Infof("Bootstrapping: node public key: %s", hex.EncodeToString([]byte(pub)))
+	supervisor.Logger(ctx).Infof("Bootstrapping: node public key: %s", hex.EncodeToString(pub))
 
 	jpub, jpriv, err := ed25519.GenerateKey(rand.Reader)
 	if err != nil {
 		return fmt.Errorf("could not generate join keypair: %w", err)
 	}
-	supervisor.Logger(ctx).Infof("Bootstrapping: node public join key: %s", hex.EncodeToString([]byte(jpub)))
+	supervisor.Logger(ctx).Infof("Bootstrapping: node public join key: %s", hex.EncodeToString(jpub))
 
 	directory := &cpb.ClusterDirectory{
 		Nodes: []*cpb.ClusterDirectory_Node{
diff --git a/metropolis/node/core/cluster/cluster_register.go b/metropolis/node/core/cluster/cluster_register.go
index 61cea56..1bda9a9 100644
--- a/metropolis/node/core/cluster/cluster_register.go
+++ b/metropolis/node/core/cluster/cluster_register.go
@@ -120,7 +120,7 @@
 	if err != nil {
 		return fmt.Errorf("could not generate join keypair: %w", err)
 	}
-	supervisor.Logger(ctx).Infof("Registering: join public key: %s", hex.EncodeToString([]byte(jpub)))
+	supervisor.Logger(ctx).Infof("Registering: join public key: %s", hex.EncodeToString(jpub))
 
 	// Register this node.
 	//
diff --git a/metropolis/node/core/network/main.go b/metropolis/node/core/network/main.go
index 7426ee4..b40bc98 100644
--- a/metropolis/node/core/network/main.go
+++ b/metropolis/node/core/network/main.go
@@ -130,7 +130,7 @@
 // nftables)
 func nfifname(n string) []byte {
 	b := make([]byte, 16)
-	copy(b, []byte(n+"\x00"))
+	copy(b, n+"\x00")
 	return b
 }
 
diff --git a/metropolis/node/core/update/update.go b/metropolis/node/core/update/update.go
index ce0d021..ad4ad43 100644
--- a/metropolis/node/core/update/update.go
+++ b/metropolis/node/core/update/update.go
@@ -409,7 +409,7 @@
 	if err != nil {
 		return fmt.Errorf("failed to list EFI variables: %w", err)
 	}
-	var validBootEntryIdx int = -1
+	var validBootEntryIdx = -1
 	for _, varName := range varNames {
 		m := bootVarRegexp.FindStringSubmatch(varName)
 		if m == nil {
diff --git a/metropolis/pkg/fat32/dos83.go b/metropolis/pkg/fat32/dos83.go
index 4956468..650df96 100644
--- a/metropolis/pkg/fat32/dos83.go
+++ b/metropolis/pkg/fat32/dos83.go
@@ -38,10 +38,10 @@
 		dosParts := validDOSName.FindStringSubmatch(nameUpper)
 		if dosParts != nil {
 			// Name is pass-through
-			copy(i.dosName[:8], []byte(dosParts[1]))
+			copy(i.dosName[:8], dosParts[1])
 			if len(dosParts[2]) > 0 {
 				// Skip the dot, it is implicit
-				copy(i.dosName[8:], []byte(dosParts[2][1:]))
+				copy(i.dosName[8:], dosParts[2][1:])
 			}
 			if taken[i.dosName] {
 				// Mapping is unique, complain about the actual file name, not
diff --git a/metropolis/pkg/fsquota/fsquota.go b/metropolis/pkg/fsquota/fsquota.go
index 0d49592..1cdcd54 100644
--- a/metropolis/pkg/fsquota/fsquota.go
+++ b/metropolis/pkg/fsquota/fsquota.go
@@ -56,7 +56,7 @@
 		return err
 	}
 
-	var lastID uint32 = attrs.ProjectID
+	var lastID = attrs.ProjectID
 	if lastID == 0 {
 		// No project/quota exists for this directory, assign a new project
 		// quota.
diff --git a/metropolis/pkg/fsquota/fsquota_test.go b/metropolis/pkg/fsquota/fsquota_test.go
index c842b63..243dbf6 100644
--- a/metropolis/pkg/fsquota/fsquota_test.go
+++ b/metropolis/pkg/fsquota/fsquota_test.go
@@ -90,7 +90,7 @@
 		testdata := make([]byte, 1024)
 		var bytesWritten int
 		for {
-			n, err := testfile.Write([]byte(testdata))
+			n, err := testfile.Write(testdata)
 			if err != nil {
 				if pathErr, ok := err.(*os.PathError); ok {
 					if pathErr.Err == syscall.ENOSPC {
diff --git a/metropolis/pkg/kmod/modinfo.go b/metropolis/pkg/kmod/modinfo.go
index adaf5d1..f75e761 100644
--- a/metropolis/pkg/kmod/modinfo.go
+++ b/metropolis/pkg/kmod/modinfo.go
@@ -69,7 +69,7 @@
 			MODE_PRE  = 1
 			MODE_POST = 2
 		)
-		var state int = MODE_IDLE
+		var state = MODE_IDLE
 		for _, token := range tokens {
 			switch token {
 			case "pre:":
diff --git a/metropolis/pkg/logtree/logtree.go b/metropolis/pkg/logtree/logtree.go
index 968a5a9..a773b7b 100644
--- a/metropolis/pkg/logtree/logtree.go
+++ b/metropolis/pkg/logtree/logtree.go
@@ -108,10 +108,10 @@
 //
 // For example, a traversal of foo.bar.baz will cause .next() to return the
 // following on each invocation:
-//  - part: foo, full: foo
-//  - part: bar, full: foo.bar
-//  - part: baz, full: foo.bar.baz
-//  - part: "",  full: foo.bar.baz
+//   - part: foo, full: foo
+//   - part: bar, full: foo.bar
+//   - part: baz, full: foo.bar.baz
+//   - part: "",  full: foo.bar.baz
 func (t *nodeTraversal) next() (part string, full DN) {
 	if len(t.left) == 0 {
 		return "", t.want
@@ -150,7 +150,7 @@
 		mu := &cur.mu
 		mu.Lock()
 		if _, ok := cur.children[part]; !ok {
-			cur.children[part] = newNode(n.tree, DN(full))
+			cur.children[part] = newNode(n.tree, full)
 		}
 		cur = cur.children[part]
 		mu.Unlock()
diff --git a/metropolis/pkg/verity/encoder.go b/metropolis/pkg/verity/encoder.go
index e0124e2..a1c0ca1 100644
--- a/metropolis/pkg/verity/encoder.go
+++ b/metropolis/pkg/verity/encoder.go
@@ -212,8 +212,8 @@
 
 	// Get the padding size by substracting current offset from a hash block
 	// size.
-	co := int(binary.Size(sb))
-	pbc := int(sb.hashBlockSize) - int(co)
+	co := binary.Size(sb)
+	pbc := int(sb.hashBlockSize) - co
 	if pbc <= 0 {
 		return int64(co), fmt.Errorf("hash device block size smaller than dm-verity superblock")
 	}
@@ -326,8 +326,8 @@
 		t.HashDevicePath,
 		strconv.FormatUint(uint64(t.superblock.dataBlockSize), 10),
 		strconv.FormatUint(uint64(t.superblock.hashBlockSize), 10),
-		strconv.FormatUint(uint64(t.superblock.dataBlocks), 10),
-		strconv.FormatInt(int64(t.HashStart), 10),
+		strconv.FormatUint(t.superblock.dataBlocks, 10),
+		strconv.FormatInt(t.HashStart, 10),
 		t.superblock.algorithmName(),
 		hex.EncodeToString(t.rootHash),
 		hex.EncodeToString(t.superblock.salt()),
diff --git a/metropolis/test/launch/launch.go b/metropolis/test/launch/launch.go
index 93e45a6..953025d 100644
--- a/metropolis/test/launch/launch.go
+++ b/metropolis/test/launch/launch.go
@@ -90,7 +90,7 @@
 func IdentityPortMap(ports []uint16) PortMap {
 	portMap := make(PortMap)
 	for _, port := range ports {
-		portMap[port] = uint16(port)
+		portMap[port] = port
 	}
 	return portMap
 }
diff --git a/metropolis/test/nanoswitch/nanoswitch.go b/metropolis/test/nanoswitch/nanoswitch.go
index b491c7b..3f4fd93 100644
--- a/metropolis/test/nanoswitch/nanoswitch.go
+++ b/metropolis/test/nanoswitch/nanoswitch.go
@@ -196,7 +196,7 @@
 // nftables)
 func nfifname(n string) []byte {
 	b := make([]byte, 16)
-	copy(b, []byte(n+"\x00"))
+	copy(b, n+"\x00")
 	return b
 }