[PATCH i-g-t v3 03/13] fixup! lib/igt_drm_fdinfo: Allow any number of spaces before unit

Umesh Nerlige Ramappa umesh.nerlige.ramappa at intel.com
Mon May 6 20:33:03 UTC 2024


On Fri, May 03, 2024 at 11:46:33PM -0700, Lucas De Marchi wrote:
>---
> lib/igt_drm_fdinfo.c | 17 +++++++----------
> 1 file changed, 7 insertions(+), 10 deletions(-)
>
>diff --git a/lib/igt_drm_fdinfo.c b/lib/igt_drm_fdinfo.c
>index 3b2778eee..3b8e79a35 100644
>--- a/lib/igt_drm_fdinfo.c
>+++ b/lib/igt_drm_fdinfo.c
>@@ -134,8 +134,7 @@ static int parse_region(char *line, struct drm_client_fdinfo *info,
> 			const char **region_map, unsigned int region_entries,
> 			uint64_t *val)
> {
>-	const char *name, *p, *unit = NULL;
>-	char *end_ptr;
>+	char *name, *p;
> 	ssize_t name_len;
> 	int found = -1;
> 	unsigned int i;
>@@ -181,18 +180,16 @@ static int parse_region(char *line, struct drm_client_fdinfo *info,
> 		goto out;
>
> 	p++;
>-	*val = strtoull(p, &end_ptr, 10);
>-
>-	p = ignore_space(end_ptr);
>-	if (!p)
>+	*val = strtoull(p, &p, 10);
>+	p = (char *)ignore_space(p);
>+	if (!*p)
> 		goto out;
>
>-	unit = ++p;
>-	if (!strcmp(unit, "KiB")) {
>+	if (!strcmp(p, "KiB")) {
> 		*val *= 1024;
>-	} else if (!strcmp(unit, "MiB")) {
>+	} else if (!strcmp(p, "MiB")) {
> 		*val *= 1024 * 1024;
>-	} else if (!strcmp(unit, "GiB")) {
>+	} else if (!strcmp(p, "GiB")) {
> 		*val *= 1024 * 1024 * 1024;
> 	}

Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa at intel.com> 

>
>-- 
>2.43.0
>


More information about the igt-dev mailing list