[PATCH i-g-t v2 08/21] lib/igt_drm_fdinfo: Allow any number of spaces before unit

Lucas De Marchi lucas.demarchi at intel.com
Tue Apr 23 23:44:18 UTC 2024


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;
 
-- 
2.43.0



More information about the igt-dev mailing list