[PATCH 4/9] cobalt/ancillaries: prevent false positive with -Wstringop-truncation

Jan Kiszka jan.kiszka at siemens.com
Thu Jan 24 19:35:31 CET 2019


On 26.10.18 16:08, Philippe Gerum wrote:
> knamecpy() is meant to copying NUL terminated strings even if this
> incurs potential truncation of the source argument if need be, prevent
> GCC 8.x from detecting a false positive when -Wstringop-truncation is
> in effect.
> ---
>   include/cobalt/kernel/ancillaries.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/cobalt/kernel/ancillaries.h b/include/cobalt/kernel/ancillaries.h
> index cde9856da..b957310c7 100644
> --- a/include/cobalt/kernel/ancillaries.h
> +++ b/include/cobalt/kernel/ancillaries.h
> @@ -58,7 +58,7 @@ void __knamecpy_requires_character_array_as_destination(void);
>   	({								\
>   		if (!__builtin_types_compatible_p(typeof(__dst), char[])) \
>   			__knamecpy_requires_character_array_as_destination();	\
> -		strncpy((__dst), __src, sizeof(__dst) - 1);		\
> +		strncpy((__dst), __src, sizeof(__dst));			\
>   		__dst[sizeof(__dst) - 1] = '\0';			\
>   		__dst;							\
>   	 })
> 

Belatedly picking patch 1-4 of this series into stable to address compilation 
issues against gcc 8.

Jan

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux



More information about the Xenomai mailing list