Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
CHECK_NVML_API(nvmlDeviceGetCount(&nvmlCounts));

int cudaDev;
int probeDev = 0;
for (i=0;i<nvmlCounts;i++){
cudaDev=nvml_to_cuda_map(i);
if (cudaDev<0) {
Expand All @@ -123,14 +124,15 @@
LOG_ERROR("Device2GetComputeRunningProcesses failed %d,%d\n",res,i);
return res;
}
}while(res==NVML_ERROR_INSUFFICIENT_SIZE);
}while(res==NVML_ERROR_INSUFFICIENT_SIZE);

Check failure on line 127 in src/utils.c

View workflow job for this annotation

GitHub Actions / cpplint

[cpplint] reported by reviewdog 🐶 Missing spaces around == [whitespace/operators] [3] Raw Output: src/utils.c:127: Missing spaces around == [whitespace/operators] [3]
mergepid(&previous,&merged_num,(nvmlProcessInfo_t1 *)tmp_pids_on_device,pre_pids_on_device);
probeDev = cudaDev;
break;
}
previous = merged_num;
merged_num = 0;
memset(tmp_pids_on_device,0,sizeof(nvmlProcessInfo_v1_t)*SHARED_REGION_MAX_PROCESS_NUM);
CHECK_CU_RESULT(cuDevicePrimaryCtxRetain(&pctx,0));
CHECK_CU_RESULT(cuDevicePrimaryCtxRetain(&pctx,probeDev));

Check failure on line 135 in src/utils.c

View workflow job for this annotation

GitHub Actions / cpplint

[cpplint] reported by reviewdog 🐶 Missing space after , [whitespace/comma] [3] Raw Output: src/utils.c:135: Missing space after , [whitespace/comma] [3]
Comment on lines +127 to +135

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Fix the CppLint whitespace failures.

Use spaces around == at Line 127 and after the comma at Line 135; these currently fail the reported cpplint checks.

Proposed fix
-        }while(res==NVML_ERROR_INSUFFICIENT_SIZE);
+        } while (res == NVML_ERROR_INSUFFICIENT_SIZE);
...
-    CHECK_CU_RESULT(cuDevicePrimaryCtxRetain(&pctx,probeDev));
+    CHECK_CU_RESULT(cuDevicePrimaryCtxRetain(&pctx, probeDev));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
}while(res==NVML_ERROR_INSUFFICIENT_SIZE);
mergepid(&previous,&merged_num,(nvmlProcessInfo_t1 *)tmp_pids_on_device,pre_pids_on_device);
probeDev = cudaDev;
break;
}
previous = merged_num;
merged_num = 0;
memset(tmp_pids_on_device,0,sizeof(nvmlProcessInfo_v1_t)*SHARED_REGION_MAX_PROCESS_NUM);
CHECK_CU_RESULT(cuDevicePrimaryCtxRetain(&pctx,0));
CHECK_CU_RESULT(cuDevicePrimaryCtxRetain(&pctx,probeDev));
} while (res == NVML_ERROR_INSUFFICIENT_SIZE);
mergepid(&previous,&merged_num,(nvmlProcessInfo_t1 *)tmp_pids_on_device,pre_pids_on_device);
probeDev = cudaDev;
break;
}
previous = merged_num;
merged_num = 0;
memset(tmp_pids_on_device,0,sizeof(nvmlProcessInfo_v1_t)*SHARED_REGION_MAX_PROCESS_NUM);
CHECK_CU_RESULT(cuDevicePrimaryCtxRetain(&pctx, probeDev));
🧰 Tools
🪛 Cppcheck (2.21.0)

[warning] 135-135: If resource allocation fails, then there is a possible null pointer dereference

(nullPointerOutOfResources)

🪛 GitHub Check: cpplint

[failure] 135-135:
[cpplint] reported by reviewdog 🐶
Missing space after , [whitespace/comma] [3]

Raw Output:
src/utils.c:135: Missing space after , [whitespace/comma] [3]


[failure] 127-127:
[cpplint] reported by reviewdog 🐶
Missing spaces around == [whitespace/operators] [3]

Raw Output:
src/utils.c:127: Missing spaces around == [whitespace/operators] [3]

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/utils.c` around lines 127 - 135, Fix the reported CppLint whitespace
issues in the shown process-query block: add spaces around the == operator in
the do-while condition and after the comma in the mergepid call. Keep the
surrounding logic unchanged.

Source: Linters/SAST tools

for (i=0;i<nvmlCounts;i++) {
cudaDev=nvml_to_cuda_map(i);
if (cudaDev<0) {
Expand Down Expand Up @@ -168,7 +170,7 @@
}
}
}
CHECK_CU_RESULT(cuDevicePrimaryCtxRelease(0));
CHECK_CU_RESULT(cuDevicePrimaryCtxRelease(probeDev));
return NVML_SUCCESS;
}

Expand Down
Loading