Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Shuah Khan <skhan@linuxfoundation.org>
To: Zhang Chujun <zhangchujun@cmss.chinamobile.com>, vkoul@kernel.org
Cc: dmaengine@vger.kernel.org, linux-kselftest@vger.kernel.org,
	Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH] selftests/dma: fix invalid array access in printf
Date: Thu, 6 Nov 2025 17:24:45 -0700	[thread overview]
Message-ID: <250fe2c8-eeef-4764-ad50-d5e5987fbd38@linuxfoundation.org> (raw)
In-Reply-To: <20251106033056.1926-1-zhangchujun@cmss.chinamobile.com>

On 11/5/25 20:30, Zhang Chujun wrote:
> The printf statement attempts to print the DMA direction string using
> the syntax 'dir[directions]', which is an invalid array access. The
> variable 'dir' is an integer, and 'directions' is a char pointer array.
> This incorrect syntax should be 'directions[dir]', using 'dir' as the
> index into the 'directions' array. Fix this by correcting the array
> access from 'dir[directions]' to 'directions[dir]'.
> 
> Signed-off-by: Zhang Chujun <zhangchujun@cmss.chinamobile.com>
> 
> diff --git a/tools/testing/selftests/dma/dma_map_benchmark.c b/tools/testing/selftests/dma/dma_map_benchmark.c
> index b12f1f9babf8..b925756373ce 100644
> --- a/tools/testing/selftests/dma/dma_map_benchmark.c
> +++ b/tools/testing/selftests/dma/dma_map_benchmark.c
> @@ -118,7 +118,7 @@ int main(int argc, char **argv)
>   	}
>   
>   	printf("dma mapping benchmark: threads:%d seconds:%d node:%d dir:%s granule: %d\n",
> -			threads, seconds, node, dir[directions], granule);
> +			threads, seconds, node, directions[dir], granule);
>   	printf("average map latency(us):%.1f standard deviation:%.1f\n",
>   			map.avg_map_100ns/10.0, map.map_stddev/10.0);
>   	printf("average unmap latency(us):%.1f standard deviation:%.1f\n",

Looks like you sent the same patch again. I replied to your previous
patch asking you how you found this problem. It looks like a needed
change. Compiler doesn't complain about it which is strange.

thanks,
-- Shuah

  reply	other threads:[~2025-11-07  0:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-06  3:30 [PATCH] selftests/dma: fix invalid array access in printf Zhang Chujun
2025-11-07  0:24 ` Shuah Khan [this message]
2025-11-07  1:55   ` [PATCH] dma_map_benchmark: fix incorrect " Zhang Chujun
2025-11-19 22:02     ` Shuah Khan
  -- strict thread matches above, loose matches on Subject: below --
2025-11-04  2:52 [PATCH] selftests/dma: fix invalid " Zhang Chujun
2025-11-06 22:11 ` Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=250fe2c8-eeef-4764-ad50-d5e5987fbd38@linuxfoundation.org \
    --to=skhan@linuxfoundation.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=vkoul@kernel.org \
    --cc=zhangchujun@cmss.chinamobile.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox