[PATCH i-g-t v12 03/11] tests/intel/*_intel_bb: handle base64 encode fail

Kamil Konieczny kamil.konieczny at linux.intel.com
Tue Jun 3 15:36:04 UTC 2025


Hi Jeevaka,
On 2025-06-02 at 19:25:07 +0000, Jeevaka Prabu Badrappan wrote:
> g_base64_encode function returns a newly allocated string containing
> the Base64 encoded data. Upon failure, null can be returned.
> 
> When g_base64_encode function fails, exit the calling function with
> error.
> 
> Signed-off-by: Jeevaka Prabu Badrappan <jeevaka.badrappan at intel.com>
> ---
>  tests/intel/api_intel_bb.c | 3 +++
>  tests/intel/xe_intel_bb.c  | 3 +++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/tests/intel/api_intel_bb.c b/tests/intel/api_intel_bb.c
> index 4a1c9be91..13b1091d8 100644
> --- a/tests/intel/api_intel_bb.c
> +++ b/tests/intel/api_intel_bb.c
> @@ -944,6 +944,9 @@ static int dump_base64(const char *name, struct intel_buf *buf)
>  
>  		igt_info("--- %s ---\n", name);
>  		pos = str = g_base64_encode(destbuf, outsize);
> +		if (str == NULL)

I forgot that checkpatch complained here, use just:
		if (!str)

> +			return -1;
> +
>  		outsize = strlen(str);
>  		while (pos) {
>  			char line[LINELEN + 1];
> diff --git a/tests/intel/xe_intel_bb.c b/tests/intel/xe_intel_bb.c
> index d8bd7b519..ef95b4a2a 100644
> --- a/tests/intel/xe_intel_bb.c
> +++ b/tests/intel/xe_intel_bb.c
> @@ -595,6 +595,9 @@ static int dump_base64(const char *name, struct intel_buf *buf)
>  
>  		igt_info("--- %s ---\n", name);
>  		pos = str = g_base64_encode(destbuf, outsize);
> +		if (str == NULL)

Same here, use:
		if (!str)

With this fixed you can keep my r-b.

Regards,
Kamil

> +			return -1;
> +
>  		outsize = strlen(str);
>  		while (pos) {
>  			char line[LINELEN + 1];
> -- 
> 2.49.0
> 


More information about the igt-dev mailing list