From 0d0b56816e3af4cea366e2585aa39b0b523e80d4 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Tue, 3 Jun 2025 23:29:14 +0200 Subject: [PATCH] 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 --- pkg/nvcdi/driver-wsl.go | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/pkg/nvcdi/driver-wsl.go b/pkg/nvcdi/driver-wsl.go index e382cb9d..944ed08a 100644 --- a/pkg/nvcdi/driver-wsl.go +++ b/pkg/nvcdi/driver-wsl.go @@ -54,24 +54,16 @@ func newWSLDriverDiscoverer(logger logger.Interface, driverRoot string, hookCrea if len(driverStorePaths) == 0 { return nil, fmt.Errorf("no driver store paths found") } + if len(driverStorePaths) > 1 { + logger.Warningf("Found multiple driver store paths: %v", driverStorePaths) + } logger.Infof("Using WSL driver store paths: %v", driverStorePaths) return newWSLDriverStoreDiscoverer(logger, driverRoot, hookCreator, ldconfigPath, driverStorePaths) } // newWSLDriverStoreDiscoverer returns a Discoverer for WSL2 drivers in the driver store associated with a dxcore adapter. -func newWSLDriverStoreDiscoverer(logger logger.Interface, driverRoot string, hookCreator discover.HookCreator, ldconfigPath string, driverStorePaths []string) (discover.Discover, error) { - var searchPaths []string - seen := make(map[string]bool) - for _, path := range driverStorePaths { - if seen[path] { - continue - } - searchPaths = append(searchPaths, path) - } - if len(searchPaths) > 1 { - logger.Warningf("Found multiple driver store paths: %v", searchPaths) - } +func newWSLDriverStoreDiscoverer(logger logger.Interface, driverRoot string, hookCreator discover.HookCreator, ldconfigPath string, searchPaths []string) (discover.Discover, error) { searchPaths = append(searchPaths, "/usr/lib/wsl/lib") libraries := discover.NewMounts(