Skip to content

fix: unused devices_found variable and unquoted path - #950

Open
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:codequality/nvidia-driver-unused-devices-found-variable-and
Open

fix: unused devices_found variable and unquoted path#950
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:codequality/nvidia-driver-unused-devices-found-variable-and

Conversation

@andrewwhitecdw

Copy link
Copy Markdown

This PR addresses the following issue in ubuntu24.04/nvidia-driver: unused devices_found variable and unquoted path.

Changes

  • ubuntu24.04/nvidia-driver: unused devices_found variable and unquoted path.

Details

--- a/ubuntu24.04/nvidia-driver
+++ b/ubuntu24.04/nvidia-driver
@@ -1,9 +1,8 @@
-_mellanox_devices_present() {
-    devices_found=0
-    for dev in /sys/bus/pci/devices/*; do
-        read vendor < $dev/vendor
-        if [ "$vendor" = "0x15b3" ]; then
-            echo "Mellanox device found at $(basename $dev)"
-            return 0
-        fi
-    done
+_mellanox_devices_present() {
+    for dev in /sys/bus/pci/devices/*; do
+        read vendor < "$dev/vendor"
+        if [ "$vendor" = "0x15b3" ]; then
+            echo "Mellanox device found at $(basename "$dev")"
+            return 0
+        fi
+    done

Tests

  • tests/test_mellanox_devices_present.sh
--- /dev/null
+++ tests/test_mellanox_devices_present.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+set -eu
+
+DRIVER_FILE="ubuntu24.04/nvidia-driver"
+
+if grep -F '    devices_found=0' "$DRIVER_FILE"; then
+    echo "FAIL: unused devices_found variable still present" >&2
+    exit 1
+fi
+
+if ! grep -F 'read vendor < "$dev/vendor"' "$DRIVER_FILE"; then
+    echo "FAIL: device vendor path is not quoted" >&2
+    exit 1
+fi
+
+echo "PASS: mellanox helper has no dead code and quotes device path"

Contributor guidelines

Per this repo's CONTRIBUTING.md:

  • All commits are signed off (Signed-off-by trailer, DCO).

@copy-pr-bot

copy-pr-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant