make linter happy

This commit is contained in:
Siyuan Miao 2025-05-18 22:26:06 +02:00
parent 2ecc105a1c
commit 8fd8a70af5
3 changed files with 3 additions and 54 deletions

View File

@ -1,30 +0,0 @@
package usbgadget
// var ethernetConfig = gadgetConfigItem{
// order: 3100,
// device: "ecm.usb0",
// path: []string{"functions", "ecm.usb0"},
// configPath: []string{"ecm.usb0"},
// attrs: gadgetAttributes{
// "host_addr": "12:34:56:78:90:AB",
// "dev_addr": "12:34:56:78:90:AC",
// },
// }
var rndisConfig = gadgetConfigItem{
// https://stackoverflow.com/questions/12154087/rndis-composite-device-cannot-start
// it has to be the first or second function, so give it a high priority here :-(
order: 990,
device: "rndis.usb0",
path: []string{"functions", "rndis.usb0"},
configPath: []string{"rndis.usb0"},
// osDescAttrs: gadgetAttributes{
// "use": "1",
// "b_vendor_code": "0xcd",
// "qw_sign": "MSFT100",
// },
// featureDescAttrs: gadgetAttributes{
// "compatible_id": "RNDIS",
// "subcompatible_id": "5162001",
// },
}

View File

@ -1,12 +1,12 @@
package usbgadget
import (
"fmt"
"errors"
)
func (u *UsbGadget) logWarn(msg string, err error) error {
if err == nil {
err = fmt.Errorf(msg)
err = errors.New(msg)
}
if u.strictMode {
return err
@ -17,7 +17,7 @@ func (u *UsbGadget) logWarn(msg string, err error) error {
func (u *UsbGadget) logError(msg string, err error) error {
if err == nil {
err = fmt.Errorf(msg)
err = errors.New(msg)
}
if u.strictMode {
return err

View File

@ -3,7 +3,6 @@ package usbgadget
import (
"bytes"
"fmt"
"os"
"path/filepath"
"strconv"
"strings"
@ -22,26 +21,6 @@ func joinPath(basePath string, paths []string) string {
return filepath.Join(pathArr...)
}
func ensureSymlink(linkPath string, target string) error {
if _, err := os.Lstat(linkPath); err == nil {
currentTarget, err := os.Readlink(linkPath)
if err != nil || currentTarget != target {
err = os.Remove(linkPath)
if err != nil {
return fmt.Errorf("failed to remove existing symlink %s: %w", linkPath, err)
}
}
} else if !os.IsNotExist(err) {
return fmt.Errorf("failed to check if symlink exists: %w", err)
}
if err := os.Symlink(target, linkPath); err != nil {
return fmt.Errorf("failed to create symlink from %s to %s: %w", linkPath, target, err)
}
return nil
}
func hexToDecimal(hex string) (int64, error) {
decimal, err := strconv.ParseInt(hex, 16, 64)
if err != nil {