-
Notifications
You must be signed in to change notification settings - Fork 243
NVML: Change Inforom-related APIs from str to bytes #1570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20035,7 +20035,7 @@ cpdef unsigned int device_get_minor_number(intptr_t device) except? 0: | |
| return minor_number | ||
|
|
||
|
|
||
| cpdef str device_get_board_part_number(intptr_t device): | ||
| cpdef bytes device_get_board_part_number(intptr_t device): | ||
| """Retrieves the the device board part number which is programmed into the board's InfoROM. | ||
|
|
||
| Args: | ||
|
|
@@ -20048,10 +20048,10 @@ cpdef str device_get_board_part_number(intptr_t device): | |
| with nogil: | ||
| __status__ = nvmlDeviceGetBoardPartNumber(<Device>device, part_number, length) | ||
| check_status(__status__) | ||
| return cpython.PyUnicode_FromString(part_number) | ||
| return cpython.PyBytes_FromStringAndSize(part_number, 80) | ||
|
|
||
|
|
||
| cpdef str device_get_inforom_version(intptr_t device, int object): | ||
| cpdef bytes device_get_inforom_version(intptr_t device, int object): | ||
| """Retrieves the version information for the device's infoROM object. | ||
|
|
||
| Args: | ||
|
|
@@ -20065,10 +20065,10 @@ cpdef str device_get_inforom_version(intptr_t device, int object): | |
| with nogil: | ||
| __status__ = nvmlDeviceGetInforomVersion(<Device>device, <_InforomObject>object, version, length) | ||
| check_status(__status__) | ||
| return cpython.PyUnicode_FromString(version) | ||
| return cpython.PyBytes_FromStringAndSize(version, 16) | ||
|
||
|
|
||
|
|
||
| cpdef str device_get_inforom_image_version(intptr_t device): | ||
| cpdef bytes device_get_inforom_image_version(intptr_t device): | ||
| """Retrieves the global infoROM image version. | ||
|
|
||
| Args: | ||
|
|
@@ -20081,7 +20081,7 @@ cpdef str device_get_inforom_image_version(intptr_t device): | |
| with nogil: | ||
| __status__ = nvmlDeviceGetInforomImageVersion(<Device>device, version, length) | ||
| check_status(__status__) | ||
| return cpython.PyUnicode_FromString(version) | ||
| return cpython.PyBytes_FromStringAndSize(version, 16) | ||
|
||
|
|
||
|
|
||
| cpdef unsigned int device_get_inforom_configuration_checksum(intptr_t device) except? 0: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using PyBytes_FromStringAndSize with the full buffer size (80) may include uninitialized or garbage data beyond the actual string content returned by the NVML API. Consider using the actual string length (e.g., via strlen) instead of the hardcoded buffer size, unless the NVML API guarantees that all 80 bytes are meaningful. If embedded NULLs need to be preserved, you could use strlen to find the length up to the first NULL, or modify the approach based on confirmed NVML API behavior.