Skip to content

Commit 6bdbca4

Browse files
IDisposableCopilot
andcommitted
Fix copilot complaints
Co-authored-by: Copilot <[email protected]>
1 parent 78b3942 commit 6bdbca4

File tree

5 files changed

+14
-20
lines changed

5 files changed

+14
-20
lines changed

display.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func updateDisplay() {
7575
nativeInstance.UpdateLabelIfChanged("hdmi_status_label", "Disconnected")
7676
_, _ = nativeInstance.UIObjClearState("hdmi_status_label", "LV_STATE_CHECKED")
7777
}
78-
nativeInstance.UpdateLabelIfChanged("cloud_status_label", fmt.Sprintf("%d active", getActiveSessions()))
78+
nativeInstance.UpdateLabelIfChanged("cloud_status_label", fmt.Sprintf("%d active", int(getActiveSessions())))
7979

8080
if networkManager != nil && networkManager.IsUp() {
8181
nativeInstance.UISetVar("main_screen", "home_screen")

internal/usbgadget/hid_keyboard.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func (u *UsbGadget) DelayAutoReleaseWithDuration(resetDuration time.Duration) {
199199
}
200200
}
201201

202-
// note: lock must be freeed by caller
202+
// note: lock must be freed by caller
203203
func (u *UsbGadget) popAutoReleaseTimer(key byte) bool {
204204
u.kbdAutoReleaseLock.Lock()
205205
timer, ok := u.kbdAutoReleaseTimers[key]

internal/usbgadget/usbgadget.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,6 @@ func (u *UsbGadget) Close() error {
170170
u.kbdAutoReleaseTimers = make(map[byte]*time.Timer)
171171
u.kbdAutoReleaseLock.Unlock()
172172

173-
// Cancel keyboard state context
174-
if u.keyboardStateCancel != nil {
175-
u.keyboardStateCancel()
176-
u.keyboardStateCancel = nil
177-
}
178-
179173
// Close HID files
180174
if u.keyboardHidFile != nil {
181175
u.keyboardHidFile.Close()

ota.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func rpcTryUpdateComponents(params updateParams, includePreRelease bool, resetCo
194194

195195
func RunAutoUpdateCheck() {
196196
// initially wait for 15 minutes before starting auto-update checks
197-
// to avoid interfering with initial setup processesand to ensure
197+
// to avoid interfering with initial setup processes and to ensure
198198
// the system is stable before checking for updates
199199
ticker := time.NewTicker(15 * time.Minute)
200200
defer ticker.Stop()

usb_mass_storage.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ func initializeNBDDevice() error {
309309
nbdDevice = NewNBDDevice()
310310
if err := nbdDevice.Start(); err != nil {
311311
logger.Warn().Err(err).Msg("failed to start nbd device")
312-
return err
312+
return fmt.Errorf("failed to set ndb device: %w", err)
313313
}
314314

315315
logger.Debug().Msg("nbd device started")
@@ -318,7 +318,7 @@ func initializeNBDDevice() error {
318318
time.Sleep(1 * time.Second)
319319

320320
if err := setMassStorageImage("/dev/nbd0"); err != nil {
321-
return err
321+
return fmt.Errorf("failed to set mass storage image to /dev/nbd0: %w", err)
322322
}
323323

324324
logger.Info().Msg("usb mass storage mounted")
@@ -328,7 +328,7 @@ func initializeNBDDevice() error {
328328
func rpcMountWithStorage(filename string, mode VirtualMediaMode) error {
329329
filename, err := sanitizeFilename(filename)
330330
if err != nil {
331-
return err
331+
return fmt.Errorf("failed to sanitize filename %s: %w", filename, err)
332332
}
333333

334334
virtualMediaStateMutex.Lock()
@@ -341,15 +341,15 @@ func rpcMountWithStorage(filename string, mode VirtualMediaMode) error {
341341
fullPath := filepath.Join(imagesFolder, filename)
342342
fileInfo, err := os.Stat(fullPath)
343343
if err != nil {
344-
return err
344+
return fmt.Errorf("failed to get file info for %s: %w", fullPath, err)
345345
}
346346

347347
if err := setMassStorageMode(mode == CDROM); err != nil {
348-
return err
348+
return fmt.Errorf("failed to set mass storage mode %s: %w", mode, err)
349349
}
350350

351351
if err := setMassStorageImage(fullPath); err != nil {
352-
return err
352+
return fmt.Errorf("failed to set mass storage image to %s: %w", fullPath, err)
353353
}
354354
currentVirtualMediaState = &VirtualMediaState{
355355
Source: Storage,
@@ -434,18 +434,18 @@ func sanitizeFilename(filename string) (string, error) {
434434
func rpcDeleteStorageFile(filename string) error {
435435
sanitizedFilename, err := sanitizeFilename(filename)
436436
if err != nil {
437-
return err
437+
return fmt.Errorf("failed to sanitize filename %s: %w", filename, err)
438438
}
439439

440440
fullPath := filepath.Join(imagesFolder, sanitizedFilename)
441441

442442
if _, err := os.Stat(fullPath); os.IsNotExist(err) {
443-
return fmt.Errorf("file does not exist: %s", filename)
443+
return fmt.Errorf("file %s does not exist: %w", fullPath, err)
444444
}
445445

446446
err = os.Remove(fullPath)
447447
if err != nil {
448-
return fmt.Errorf("failed to delete file: %w", err)
448+
return fmt.Errorf("failed to delete file %s: %w", fullPath, err)
449449
}
450450

451451
return nil
@@ -461,7 +461,7 @@ const uploadIdPrefix = "upload_"
461461
func rpcStartStorageFileUpload(filename string, size int64) (*StorageFileUpload, error) {
462462
sanitizedFilename, err := sanitizeFilename(filename)
463463
if err != nil {
464-
return nil, err
464+
return nil, fmt.Errorf("failed to sanitize filename %s: %w", filename, err)
465465
}
466466

467467
filePath := path.Join(imagesFolder, sanitizedFilename)
@@ -479,7 +479,7 @@ func rpcStartStorageFileUpload(filename string, size int64) (*StorageFileUpload,
479479
uploadId := uploadIdPrefix + uuid.New().String()
480480
file, err := os.OpenFile(uploadPath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
481481
if err != nil {
482-
return nil, fmt.Errorf("failed to open file for upload: %v", err)
482+
return nil, fmt.Errorf("failed to open file %s for upload: %w", uploadPath, err)
483483
}
484484
pendingUploadsMutex.Lock()
485485
pendingUploads[uploadId] = pendingUpload{

0 commit comments

Comments
 (0)