Re: [PATCH] cxgb4/chcr: avoid -Wreturn-local-addr warning

From: David Miller
Date: Mon May 04 2020 - 14:48:11 EST


From: Arnd Bergmann <arnd@xxxxxxxx>
Date: Thu, 30 Apr 2020 12:39:02 +0200

> gcc-10 warns about functions that return a pointer to a stack
> variable. In chcr_write_cpl_set_tcb_ulp(), this does not actually
> happen, but it's too hard to see for the compiler:
>
> drivers/crypto/chelsio/chcr_ktls.c: In function 'chcr_write_cpl_set_tcb_ulp.constprop':
> drivers/crypto/chelsio/chcr_ktls.c:760:9: error: function may return address of local variable [-Werror=return-local-addr]
> 760 | return pos;
> | ^~~
> drivers/crypto/chelsio/chcr_ktls.c:712:5: note: declared here
> 712 | u8 buf[48] = {0};
> | ^~~
>
> Split the middle part of the function out into a helper to make
> it easier to understand by both humans and compilers, which avoids
> the warning.
>
> Fixes: 5a4b9fe7fece ("cxgb4/chcr: complete record tx handling")
> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>

Applied, thanks Arnd.