Skip to content

Commit 0d0b568

Browse files
committed
Remove redundant deduplication of search paths for WSL
The GetDriverStorePaths function is implemented so as to remove duplicate driver store paths which means that the additional deduplication (which had a bug) can be removed. Signed-off-by: Evan Lezar <elezar@nvidia.com>
1 parent d59fd3d commit 0d0b568

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

pkg/nvcdi/driver-wsl.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,16 @@ func newWSLDriverDiscoverer(logger logger.Interface, driverRoot string, hookCrea
5454
if len(driverStorePaths) == 0 {
5555
return nil, fmt.Errorf("no driver store paths found")
5656
}
57+
if len(driverStorePaths) > 1 {
58+
logger.Warningf("Found multiple driver store paths: %v", driverStorePaths)
59+
}
5760
logger.Infof("Using WSL driver store paths: %v", driverStorePaths)
5861

5962
return newWSLDriverStoreDiscoverer(logger, driverRoot, hookCreator, ldconfigPath, driverStorePaths)
6063
}
6164

6265
// newWSLDriverStoreDiscoverer returns a Discoverer for WSL2 drivers in the driver store associated with a dxcore adapter.
63-
func newWSLDriverStoreDiscoverer(logger logger.Interface, driverRoot string, hookCreator discover.HookCreator, ldconfigPath string, driverStorePaths []string) (discover.Discover, error) {
64-
var searchPaths []string
65-
seen := make(map[string]bool)
66-
for _, path := range driverStorePaths {
67-
if seen[path] {
68-
continue
69-
}
70-
searchPaths = append(searchPaths, path)
71-
}
72-
if len(searchPaths) > 1 {
73-
logger.Warningf("Found multiple driver store paths: %v", searchPaths)
74-
}
66+
func newWSLDriverStoreDiscoverer(logger logger.Interface, driverRoot string, hookCreator discover.HookCreator, ldconfigPath string, searchPaths []string) (discover.Discover, error) {
7567
searchPaths = append(searchPaths, "/usr/lib/wsl/lib")
7668

7769
libraries := discover.NewMounts(

0 commit comments

Comments
 (0)