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

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


On Fri, May 03, 2024 at 11:46:32PM -0700, Lucas De Marchi wrote:
>When parsing memory region, allow any number of spaces between value and
>unit by using ignore_space() and adjusting constness of the variables.
>
>Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
>---
> lib/igt_drm_fdinfo.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
>diff --git a/lib/igt_drm_fdinfo.c b/lib/igt_drm_fdinfo.c
>index b3f6fc35a..3b2778eee 100644
>--- a/lib/igt_drm_fdinfo.c
>+++ b/lib/igt_drm_fdinfo.c
>@@ -134,7 +134,8 @@ static int parse_region(char *line, struct drm_client_fdinfo *info,
> 			const char **region_map, unsigned int region_entries,
> 			uint64_t *val)
> {
>-	char *name, *p, *unit = NULL;
>+	const char *name, *p, *unit = NULL;
>+	char *end_ptr;
> 	ssize_t name_len;
> 	int found = -1;
> 	unsigned int i;
>@@ -180,9 +181,9 @@ static int parse_region(char *line, struct drm_client_fdinfo *info,
> 		goto out;
>
> 	p++;
>-	*val = strtoull(p, &p, 10);
>+	*val = strtoull(p, &end_ptr, 10);
>
>-	p = index(p, ' ');
>+	p = ignore_space(end_ptr);
> 	if (!p)
> 		goto out;

I think the next line of code here is 

	unit = ++p;

but p should already be pointing to the unit after ignoring the spaces.

Regards,
Umesh
>
>-- 
>2.43.0
>


More information about the igt-dev mailing list