[PATCH i-g-t] lib/igt_sysfs: Remove redundant variable assignment
Kamil Konieczny
kamil.konieczny at linux.intel.com
Thu Jul 17 10:44:00 UTC 2025
Hi Pranay,
On 2025-07-16 at 18:57:52 +0530, Pranay Samala wrote:
as Ashutosh pointed out, this is a fix, as code was printing a var
which has no assigned value. Please improve subject, for example to:
[PATCH i-g-t] lib/igt_sysfs: Fix mask printing
> Eliminate redundant assignment in debug mask setup.
> Simplified the logic by directly using the input
> parameter for logging and sysfs operations.
Improve also description, for example:
Remove variable which is printed but has no assigned value.
>
> Fixes: 835f38b71973 ("lib/igt_sysfs: Update new debug mask requested by user")
> Signed-off-by: Pranay Samala <pranay.samala at intel.com>
> ---
> lib/igt_sysfs.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
> index aec157b5b..96ca57ed9 100644
> --- a/lib/igt_sysfs.c
> +++ b/lib/igt_sysfs.c
> @@ -506,7 +506,6 @@ void igt_drm_debug_mask_reset_exit_handler(int sig)
> */
> void igt_drm_debug_mask_update(unsigned int mask_to_set)
> {
> - unsigned int new_debug_mask;
> static bool debug_mask_read_once = true;
> char buf[20];
> int dir;
> @@ -525,8 +524,8 @@ void igt_drm_debug_mask_update(unsigned int mask_to_set)
> }
> }
>
> - igt_debug("Setting DRM debug mask to %d\n", new_debug_mask);
> - snprintf(buf, sizeof(buf), "%d", new_debug_mask);
> + igt_debug("Setting DRM debug mask to %d\n", mask_to_set);
When printing to screen imho it is better to use hex values,
as these are bits, so please use '0x%x' instead of '%d'
If you will make this change please also describe it in commit
message, for example:
Also while at this, print it's value as hex as this is bitmask.
Regards,
Kamil
> + snprintf(buf, sizeof(buf), "%d", mask_to_set);
> igt_assert(igt_sysfs_set(dir, "debug", buf));
>
> close(dir);
> --
> 2.34.1
>
More information about the igt-dev
mailing list