treewide: cleanup function receiver names
Change-Id: I0575175ea249a2bd39b4b7769e49a9995fae6f6d
Reviewed-on: https://review.monogon.dev/c/monogon/+/2959
Tested-by: Jenkins CI
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
diff --git a/metropolis/node/build/mkerofs/main.go b/metropolis/node/build/mkerofs/main.go
index 9cacc59..ac0042a 100644
--- a/metropolis/node/build/mkerofs/main.go
+++ b/metropolis/node/build/mkerofs/main.go
@@ -128,7 +128,7 @@
// pathRef gets the entrySpec at the leaf of the given path, inferring
// directories if necessary
-func (s *entrySpec) pathRef(p string) *entrySpec {
+func (spec *entrySpec) pathRef(p string) *entrySpec {
// This block gets a path array starting at the root of the filesystem. The
// root folder is the zero-length array.
pathParts := strings.Split(path.Clean("./"+p), "/")
@@ -136,7 +136,7 @@
pathParts = pathParts[1:]
}
- entryRef := s
+ entryRef := spec
for _, part := range pathParts {
childRef, ok := entryRef.children[part]
if !ok {
diff --git a/metropolis/node/core/rpc/resolver/watcher.go b/metropolis/node/core/rpc/resolver/watcher.go
index 121d731..d2715b6 100644
--- a/metropolis/node/core/rpc/resolver/watcher.go
+++ b/metropolis/node/core/rpc/resolver/watcher.go
@@ -109,16 +109,16 @@
}
}
-func (r *clientWatcher) ResolveNow(_ resolver.ResolveNowOptions) {
+func (w *clientWatcher) ResolveNow(_ resolver.ResolveNowOptions) {
// No-op. The clientWatcher's watcher runs as fast as possible.
}
-func (r *clientWatcher) Close() {
+func (w *clientWatcher) Close() {
select {
- case <-r.resolver.ctx.Done():
- case r.resolver.reqC <- &request{
+ case <-w.resolver.ctx.Done():
+ case w.resolver.reqC <- &request{
unsub: &requestUnsubscribe{
- id: r.subscription.id,
+ id: w.subscription.id,
},
}:
}
diff --git a/metropolis/pkg/gpt/gpt.go b/metropolis/pkg/gpt/gpt.go
index fb011c6..58c0527 100644
--- a/metropolis/pkg/gpt/gpt.go
+++ b/metropolis/pkg/gpt/gpt.go
@@ -201,8 +201,8 @@
// It writes the placement information (FirstBlock, LastBlock) back to p.
// By default, AddPartition aligns FirstBlock to 1MiB boundaries, but this can
// be overridden using WithAlignment.
-func (g *Table) AddPartition(p *Partition, size int64, options ...AddOption) error {
- blockSize := g.b.BlockSize()
+func (gpt *Table) AddPartition(p *Partition, size int64, options ...AddOption) error {
+ blockSize := gpt.b.BlockSize()
var opts addOptions
// Align to 1MiB or the block size, whichever is bigger
opts.alignment = 1 * 1024 * 1024
@@ -219,7 +219,7 @@
p.ID = uuid.New()
}
- fs, _, err := g.GetFreeSpaces()
+ fs, _, err := gpt.GetFreeSpaces()
if err != nil {
return fmt.Errorf("unable to determine free space: %v", err)
}
@@ -247,7 +247,7 @@
end := freeInt[1]
freeBlocks := end - start
// Align start properly
- alignTo := (opts.alignment / blockSize)
+ alignTo := opts.alignment / blockSize
// Go doesn't implement the euclidean modulus, thus this construction
// is necessary.
paddingBlocks := ((alignTo - start) % alignTo) % alignTo
@@ -269,7 +269,7 @@
}
newPartPos := -1
if !opts.keepEmptyEntries {
- for i, part := range g.Partitions {
+ for i, part := range gpt.Partitions {
if part.IsUnused() {
newPartPos = i
break
@@ -277,11 +277,11 @@
}
}
if newPartPos == -1 {
- g.Partitions = append(g.Partitions, p)
+ gpt.Partitions = append(gpt.Partitions, p)
} else {
- g.Partitions[newPartPos] = p
+ gpt.Partitions[newPartPos] = p
}
- p.Section = blockdev.NewSection(g.b, int64(p.FirstBlock), int64(p.LastBlock)+1)
+ p.Section = blockdev.NewSection(gpt.b, int64(p.FirstBlock), int64(p.LastBlock)+1)
return nil
}
}
@@ -291,18 +291,18 @@
// FirstUsableBlock returns the first usable (i.e. a partition can start there)
// block.
-func (g *Table) FirstUsableBlock() int64 {
- blockSize := g.b.BlockSize()
+func (gpt *Table) FirstUsableBlock() int64 {
+ blockSize := gpt.b.BlockSize()
partitionEntryBlocks := (16384 + blockSize - 1) / blockSize
return 2 + partitionEntryBlocks
}
// LastUsableBlock returns the last usable (i.e. a partition can end there)
// block. This block is inclusive.
-func (g *Table) LastUsableBlock() int64 {
- blockSize := g.b.BlockSize()
+func (gpt *Table) LastUsableBlock() int64 {
+ blockSize := gpt.b.BlockSize()
partitionEntryBlocks := (16384 + blockSize - 1) / blockSize
- return g.b.BlockCount() - (2 + partitionEntryBlocks)
+ return gpt.b.BlockCount() - (2 + partitionEntryBlocks)
}
// GetFreeSpaces returns a slice of tuples, each containing a half-closed
@@ -315,7 +315,7 @@
//
// Note that the most common use cases for this function are covered by
// AddPartition, you're encouraged to use it instead.
-func (g *Table) GetFreeSpaces() ([][2]int64, bool, error) {
+func (gpt *Table) GetFreeSpaces() ([][2]int64, bool, error) {
// This implements an efficient algorithm for finding free intervals given
// a set of potentially overlapping occupying intervals. It uses O(n*log n)
// time for n being the amount of intervals, i.e. partitions. It uses O(n)
@@ -324,7 +324,7 @@
// of its cyclomatic complexity and O(n*log n) is tiny for even very big
// partition tables.
- blockCount := g.b.BlockCount()
+ blockCount := gpt.b.BlockCount()
// startBlocks contains the start blocks (inclusive) of all occupied
// intervals.
@@ -335,13 +335,13 @@
// Reserve the primary GPT interval including the protective MBR.
startBlocks = append(startBlocks, 0)
- endBlocks = append(endBlocks, g.FirstUsableBlock())
+ endBlocks = append(endBlocks, gpt.FirstUsableBlock())
// Reserve the alternate GPT interval (needs +1 for exclusive interval)
- startBlocks = append(startBlocks, g.LastUsableBlock()+1)
+ startBlocks = append(startBlocks, gpt.LastUsableBlock()+1)
endBlocks = append(endBlocks, blockCount)
- for i, part := range g.Partitions {
+ for i, part := range gpt.Partitions {
if part.IsUnused() {
continue
}
diff --git a/metropolis/pkg/scsi/scsi.go b/metropolis/pkg/scsi/scsi.go
index e2d236e..f09bf44 100644
--- a/metropolis/pkg/scsi/scsi.go
+++ b/metropolis/pkg/scsi/scsi.go
@@ -220,11 +220,11 @@
}
// String returns the textual representation of this ASK
-func (s AdditionalSenseCode) String() string {
- if str, ok := additionalSenseCodeDesc[s]; ok {
+func (a AdditionalSenseCode) String() string {
+ if str, ok := additionalSenseCodeDesc[a]; ok {
return str
}
- return fmt.Sprintf("unknown additional sense code %xh %xh", s.ASK(), s.ASKQ())
+ return fmt.Sprintf("unknown additional sense code %xh %xh", a.ASK(), a.ASKQ())
}
// FixedError is one type of error returned by a SCSI CHECK_CONDITION.