style: drop unused variables and parameters

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
千川白浪andClaude Opus 5.5 committed 2026-12-03 21:31:11 -07:00
1 parent 0ed522656d
commit ab93899f45
10 files changed
+44 -51

No files matched your search

+3 -4
View File
@@ -24,10 +24,9 @@ import (
)
var (
allDomains = []string{"core", "vm", "wizard", "settings", "plugins", "native", "macos-glossary"}
goDomains = []string{"native", "macos-glossary", "core"}
feEagerDomains = []string{"core", "vm"}
feLazyDomains = []string{"wizard", "settings", "plugins"}
allDomains = []string{"core", "vm", "wizard", "settings", "plugins", "native", "macos-glossary"}
goDomains = []string{"native", "macos-glossary", "core"}
feLazyDomains = []string{"wizard", "settings", "plugins"}
)
type parsedEntry struct {
-3
View File
@@ -283,6 +283,3 @@ func suspendProgressPercent(p driver.SuspendProgress) (int, bool) {
}
return pct, true
}
// Keep context import used cleanly for future cancellation hooks.
var _ context.Context
+9 -9
View File
@@ -303,7 +303,7 @@ func (m *Manager) withConnMode(ctx context.Context, vmDir string, cancelIO bool,
return err
}
nested := m.hasLockScope(ctx, key)
_, release, err := m.acquire(ctx, vmDir)
release, err := m.acquire(ctx, vmDir)
if err != nil {
return err
}
@@ -347,7 +347,7 @@ func (m *Manager) withVM(ctx context.Context, vmDir string, operation func(conte
if m.hasLockScope(ctx, key) {
return operation(ctx)
}
_, release, err := m.acquire(ctx, vmDir)
release, err := m.acquire(ctx, vmDir)
if err != nil {
return err
}
@@ -358,19 +358,19 @@ func (m *Manager) withVM(ctx context.Context, vmDir string, operation func(conte
return operation(context.WithValue(ctx, lockScopeKey{}, scope))
}
func (m *Manager) acquire(ctx context.Context, vmDir string) (*vmLock, func(), error) {
func (m *Manager) acquire(ctx context.Context, vmDir string) (func(), error) {
if m == nil {
return nil, nil, errors.New("console manager is unavailable")
return nil, errors.New("console manager is unavailable")
}
if ctx == nil {
return nil, nil, errors.New("console context is unavailable")
return nil, errors.New("console context is unavailable")
}
key, err := lockKey(vmDir)
if err != nil {
return nil, nil, err
return nil, err
}
if m.hasLockScope(ctx, key) {
return &vmLock{}, func() {}, nil
return func() {}, nil
}
m.mu.Lock()
@@ -388,7 +388,7 @@ func (m *Manager) acquire(ctx context.Context, vmDir string) (*vmLock, func(), e
select {
case lock.semaphore <- struct{}{}:
var once sync.Once
return lock, func() {
return func() {
once.Do(func() {
<-lock.semaphore
m.release(key, lock)
@@ -396,7 +396,7 @@ func (m *Manager) acquire(ctx context.Context, vmDir string) (*vmLock, func(), e
}, nil
case <-ctx.Done():
m.release(key, lock)
return nil, nil, ctx.Err()
return nil, ctx.Err()
}
}
+18 -23
View File
@@ -54,27 +54,25 @@ var (
vcDrawText = user32.NewProc("DrawTextW")
vcFillRect = user32.NewProc("FillRect")
vcGetWindowTextW = user32.NewProc("GetWindowTextW")
vcInvalidateRect = user32.NewProc("InvalidateRect")
vcSetLayeredAttr = user32.NewProc("SetLayeredWindowAttributes")
vcSetWindowRgn = user32.NewProc("SetWindowRgn")
vcBeginPaint = user32.NewProc("BeginPaint")
vcEndPaint = user32.NewProc("EndPaint")
vcIsWindowEnabled = user32.NewProc("IsWindowEnabled")
vcMoveWindow = user32.NewProc("MoveWindow")
vcGetParent = user32.NewProc("GetParent")
vcSelectObj = vcGDI.NewProc("SelectObject")
vcStockObj = vcGDI.NewProc("GetStockObject")
vcDeleteObj = vcGDI.NewProc("DeleteObject")
vcSetDCBrushColor = vcGDI.NewProc("SetDCBrushColor")
vcSetDCPenColor = vcGDI.NewProc("SetDCPenColor")
vcSetTextColor = vcGDI.NewProc("SetTextColor")
vcSetBkMode = vcGDI.NewProc("SetBkMode")
vcCreateFontW = vcGDI.NewProc("CreateFontIndirectW")
vcCreateRoundRect = vcGDI.NewProc("CreateRoundRectRgn")
vcRoundRect = vcGDI.NewProc("RoundRect")
vcDwmSetWindowAttr = vcDWM.NewProc("DwmSetWindowAttribute")
vcRtlMoveMemory = vcKernel.NewProc("RtlMoveMemory")
vcSelectObj = vcGDI.NewProc("SelectObject")
vcStockObj = vcGDI.NewProc("GetStockObject")
vcDeleteObj = vcGDI.NewProc("DeleteObject")
vcSetDCBrushColor = vcGDI.NewProc("SetDCBrushColor")
vcSetDCPenColor = vcGDI.NewProc("SetDCPenColor")
vcSetTextColor = vcGDI.NewProc("SetTextColor")
vcSetBkMode = vcGDI.NewProc("SetBkMode")
vcCreateFontW = vcGDI.NewProc("CreateFontIndirectW")
vcCreateRoundRect = vcGDI.NewProc("CreateRoundRectRgn")
vcRoundRect = vcGDI.NewProc("RoundRect")
vcDwmSetWindowAttr = vcDWM.NewProc("DwmSetWindowAttribute")
vcRtlMoveMemory = vcKernel.NewProc("RtlMoveMemory")
)
type vcRect struct{ left, top, right, bottom int32 }
@@ -116,11 +114,11 @@ type vcLogFont struct {
}
type vcPalette struct {
surface, border, divider uintptr
text, text2, textDisabled uintptr
accent, accentPress uintptr
btnFill, btnPress, btnBorder uintptr
dangerText uintptr
surface, border, divider uintptr
text, text2, textDisabled uintptr
accent, accentPress uintptr
btnFill, btnPress, btnBorder uintptr
dangerText uintptr
}
func vcRGB(r, g, b uint8) uintptr {
@@ -327,7 +325,7 @@ func vcBuildDialogTemplate(title, body, left, right, cancel string, disableRight
style := uint16(0x5000) // WS_CHILD | WS_VISIBLE
var ctlStyle uint16
if class == clsButton {
style |= 1 // WS_TABSTOP
style |= 1 // WS_TABSTOP
ctlStyle = 0x0b // BS_OWNERDRAW
if disabled {
style |= 0x0800 // WS_DISABLED
@@ -599,6 +597,3 @@ func centerVMCloseDialog(hwnd, owner uintptr) {
procSetWindowPos.Call(hwnd, 0, uintptr(x), uintptr(y), 0, 0, 0x0215)
}
}
var _ = vcGetParent
var _ = vcInvalidateRect
+2 -2
View File
@@ -142,7 +142,7 @@ func (d *ReimsMacOSDriver) prepareStart(ctx context.Context, cfg config.Config,
if err := d.prepareOfflineHelper(cfg, cur, &in); err != nil {
return in, err
}
if err := d.prepareRecoveryBoot(ctx, cfg, c, name, cur.Directory, log); err != nil {
if err := d.prepareRecoveryBoot(ctx, c, name, cur.Directory, log); err != nil {
return in, err
}
if err := d.prepareGuestLang(ctx, cfg, active, cur.Directory); err != nil {
@@ -178,7 +178,7 @@ func (d *ReimsMacOSDriver) prepareOfflineHelper(cfg config.Config, cur reims.VMD
return nil
}
func (d *ReimsMacOSDriver) prepareRecoveryBoot(ctx context.Context, cfg config.Config, c *reims.Client, name, vmDir string, log io.Writer) error {
func (d *ReimsMacOSDriver) prepareRecoveryBoot(ctx context.Context, c *reims.Client, name, vmDir string, log io.Writer) error {
marker := startprep.ReadRecoveryMarker(vmDir)
if marker != "want" && marker != "restore" {
return nil
+1 -1
View File
@@ -153,7 +153,7 @@ func (t *translator) inbound(frame []byte) ([]byte, bool) {
return append([]byte(nil), frame...), true
}
multicast := frame[0]&1 != 0
deliver := multicast
var deliver bool
var multicastMAC net.HardwareAddr
switch binary.BigEndian.Uint16(frame[12:14]) {
case 0x0806:
+8 -5
View File
@@ -181,7 +181,7 @@ func (b *Broker) AuthorizeNetOrigin(pluginID, rawURL string) error {
}
for _, p := range info.Permissions {
if netPermissionMatches(p.Name, u) {
if !b.allowRate(pluginID, 120) {
if !b.allowRate(pluginID) {
b.Audit(pluginID, "RATE_LIMIT", "net:"+u.Host)
return fmt.Errorf("plugin %q exceeded Host API rate limit", pluginID)
}
@@ -242,7 +242,7 @@ func (b *Broker) Authorize(pluginID, perm string) error {
}
}
// Rate limit: max 120 Host API calls / second per plugin.
if !b.allowRate(pluginID, 120) {
if !b.allowRate(pluginID) {
b.Audit(pluginID, "RATE_LIMIT", perm)
return fmt.Errorf("plugin %q exceeded Host API rate limit", pluginID)
}
@@ -261,14 +261,17 @@ func (b *Broker) AllowRate(pluginID string) error {
if st := b.reg.StateOf(pluginID); st != StateActive && st != StateDegraded {
return fmt.Errorf("plugin %q is not active (state=%s)", pluginID, st)
}
if !b.allowRate(pluginID, 120) {
if !b.allowRate(pluginID) {
b.Audit(pluginID, "RATE_LIMIT", "i18n.getBundle")
return fmt.Errorf("plugin %q exceeded Host API rate limit", pluginID)
}
return nil
}
func (b *Broker) allowRate(pluginID string, limitPerSec int) bool {
// hostCallsPerSecond is how many Host API calls one plugin may make per second.
const hostCallsPerSecond = 120
func (b *Broker) allowRate(pluginID string) bool {
b.mu.Lock()
defer b.mu.Unlock()
now := time.Now()
@@ -277,7 +280,7 @@ func (b *Broker) allowRate(pluginID string, limitPerSec int) bool {
b.rates[pluginID] = &rateWindow{windowStart: now, count: 1}
return true
}
if rw.count >= limitPerSec {
if rw.count >= hostCallsPerSecond {
return false
}
rw.count++
+2 -2
View File
@@ -88,7 +88,7 @@ func RegisterAll(reg *plugin.Registry, cb HostCallbacks, desiredFn func(id strin
defs := []plugin.PluginDef{
defCore(ver),
defGuestTools(ver, cb, desiredFn),
defClipboard(ver, cb, desiredFn),
defClipboard(ver, desiredFn),
defInput(ver, cb, desiredFn),
defNpcapBridge(ver, cb, desiredFn),
defComputerUse(ver, desiredFn),
@@ -219,7 +219,7 @@ func defGuestTools(ver string, cb HostCallbacks, desiredFn func(string, bool) bo
}
}
func defClipboard(ver string, cb HostCallbacks, desiredFn func(string, bool) bool) plugin.PluginDef {
func defClipboard(ver string, desiredFn func(string, bool) bool) plugin.PluginDef {
minMB := 1.0
maxMB := 16.0
minFileMB := float64(guesttools.MinClipboardMaxFileMB)
-1
View File
@@ -108,7 +108,6 @@ type HookBus struct {
mu sync.RWMutex
handlers map[string][]*HookRegistration
seq uint64
// Zero-overhead counter for log.onLine (§8.1): checked with atomic load
// before constructing LogLineEvent objects.
+1 -1
View File
@@ -314,7 +314,7 @@ func (s *SidecarSupervisor) registerReverseHostAPI(conn *RPCConn) {
conn.Handle("host/audit", func(_ context.Context, raw json.RawMessage) (any, error) {
if broker != nil {
if !broker.allowRate(pid, 120) {
if !broker.allowRate(pid) {
return nil, fmt.Errorf("plugin %q exceeded audit rate limit", pid)
}
var req struct {