Skip to content

Commit

Permalink
Drop error return parameter from matchAlias
Browse files Browse the repository at this point in the history
  • Loading branch information
anatol committed Sep 29, 2022
1 parent 046d77d commit 1d4a336
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
5 changes: 1 addition & 4 deletions init/luks.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,10 +451,7 @@ func loadRequiredCryptoModules(encryption string) error {

cryptoAliases := []string{"crypto-" + mode, "crypto-" + cipher}
for _, a := range cryptoAliases {
mods, err := matchAlias(a)
if err != nil {
return fmt.Errorf("unable to match modalias %s: %v", a, err)
}
mods := matchAlias(a)
if len(mods) == 0 {
debug("no match found for alias %s", a)
continue
Expand Down
13 changes: 5 additions & 8 deletions init/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"bufio"
"fmt"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -31,10 +30,7 @@ func loadModalias(alias string) error {
return nil
}

mods, err := matchAlias(alias)
if err != nil {
return fmt.Errorf("unable to match modalias %s: %v", alias, err)
}
mods := matchAlias(alias)
if len(mods) == 0 {
debug("no match found for alias %s", alias)
return nil
Expand Down Expand Up @@ -158,19 +154,20 @@ func loadModules(modules ...string) *sync.WaitGroup {
}

// returns all module names that match given alias
func matchAlias(tofind ...string) ([]string, error) {
func matchAlias(tofind ...string) []string {
var result []string
for _, a := range aliases {
for _, f := range tofind {
match, err := filepath.Match(a.pattern, f)
if err != nil {
return nil, err
warning("unable to use modalias %s", a.pattern)
continue
}
if match {
debug("modalias %v matched module %v", f, a.module)
result = append(result, a.module)
}
}
}
return result, nil
return result
}

0 comments on commit 1d4a336

Please sign in to comment.