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

Lucas De Marchi lucas.demarchi at intel.com
Sat May 4 06:46:33 UTC 2024


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



More information about the igt-dev mailing list