[PATCH] drm/amd/display: Add gnu_printf format attribute for snprintf_count()
Rodrigo Siqueira Jordao
Rodrigo.Siqueira at amd.com
Fri Jun 2 15:19:26 UTC 2023
On 5/30/23 14:33, Srinivasan Shanmugam wrote:
> Fix the following W=1 kernel build warning:
>
> display/dc/dcn10/dcn10_hw_sequencer_debug.c: In function ‘snprintf_count’:
> display/dc/dcn10/dcn10_hw_sequencer_debug.c:56:2: warning: function ‘snprintf_count’ might be a candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format]
>
> Use the __printf() attribute to let the compiler warn if
> invalid format strings are passed in.
>
> And fix the following checks:
>
> CHECK: Avoid CamelCase: <pBuf> +unsigned int __printf(3, 4)
> snprintf_count(char *pBuf, unsigned int bufSize, char *fmt, ...)
>
> CHECK: Avoid CamelCase: <bufSize> +unsigned int __printf(3, 4)
> snprintf_count(char *pBuf, unsigned int bufSize, char *fmt, ...)
>
> Cc: Hamza Mahfooz <hamza.mahfooz at amd.com>
> Cc: Rodrigo Siqueira <Rodrigo.Siqueira at amd.com>
> Cc: Harry Wentland <harry.wentland at amd.com>
> Cc: Aurabindo Pillai <aurabindo.pillai at amd.com>
> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam at amd.com>
> ---
> .../drm/amd/display/dc/dcn10/dcn10_hw_sequencer_debug.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer_debug.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer_debug.c
> index a0f8e31d2adc..46a2ebcabd1a 100644
> --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer_debug.c
> +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer_debug.c
> @@ -45,7 +45,8 @@
> #include "dcn10_cm_common.h"
> #include "clk_mgr.h"
>
> -unsigned int snprintf_count(char *pBuf, unsigned int bufSize, char *fmt, ...)
> +__printf(3, 4)
> +unsigned int snprintf_count(char *pbuf, unsigned int bufsize, char *fmt, ...)
> {
> int ret_vsnprintf;
> unsigned int chars_printed;
> @@ -53,15 +54,15 @@ unsigned int snprintf_count(char *pBuf, unsigned int bufSize, char *fmt, ...)
> va_list args;
> va_start(args, fmt);
>
> - ret_vsnprintf = vsnprintf(pBuf, bufSize, fmt, args);
> + ret_vsnprintf = vsnprintf(pbuf, bufsize, fmt, args);
>
> va_end(args);
>
> if (ret_vsnprintf > 0) {
> - if (ret_vsnprintf < bufSize)
> + if (ret_vsnprintf < bufsize)
> chars_printed = ret_vsnprintf;
> else
> - chars_printed = bufSize - 1;
> + chars_printed = bufsize - 1;
> } else
> chars_printed = 0;
>
Reviewed-by: Rodrigo Siqueira <Rodrigo.Siqueira at amd.com>
More information about the amd-gfx
mailing list