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

Lucas De Marchi lucas.demarchi at intel.com
Mon May 6 20:38:35 UTC 2024


On Mon, May 06, 2024 at 01:32:16PM GMT, Umesh Nerlige Ramappa wrote:
>On Mon, May 06, 2024 at 01:28:33PM -0700, Umesh Nerlige Ramappa wrote:
>>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.
>
>Looks like this is fixed in the next patch. Not sure why the next 
>patch is a fixup!.
>
>Maybe squash the patches into one and then this is

yeah.. that was actually my intention, but I forgot to squash them.

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

thanks
Lucas De Marchi

>
>>
>>Regards,
>>Umesh
>>>
>>>-- 
>>>2.43.0
>>>


More information about the igt-dev mailing list