On Thu, Oct 13, 2022 at 10:16:56AM +0200, Michal Suchanek wrote:
> In file included from ../tools/imagetool.h:24,
>                  from ../tools/default_image.c:16:
> In function ‘image_set_name’,
>     inlined from ‘image_set_header’ at ../tools/default_image.c:133:2:
> ../include/image.h:786:9: warning: ‘strncpy’ specified bound 32 equals 
> destination size [-Wstringop-truncation]
>   786 |         strncpy(image_get_name(hdr), name, IH_NMLEN);
>       |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Suggested-by: Rasmus Villemoes <rasmus.villem...@prevas.dk>
> Signed-off-by: Michal Suchanek <msucha...@suse.de>
> ---
> 
> Changes in v2:
> Use __nonstring instead of suppressing the warning
> 
> ---
>  include/image.h  | 3 ++-
>  tools/kwbimage.h | 6 ------
>  2 files changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/include/image.h b/include/image.h
> index d7d6a3fe5b..82b447aeb7 100644
> --- a/include/image.h
> +++ b/include/image.h
> @@ -18,6 +18,7 @@
>  #include "compiler.h"
>  #include <asm/byteorder.h>
>  #include <stdbool.h>
> +#include <linux/compiler_attributes.h>
>  
>  /* Define this to avoid #ifdefs later on */
>  struct lmb;
> @@ -275,7 +276,7 @@ struct legacy_img_hdr {
>       uint8_t         ih_arch;        /* CPU architecture             */
>       uint8_t         ih_type;        /* Image Type                   */
>       uint8_t         ih_comp;        /* Compression Type             */
> -     uint8_t         ih_name[IH_NMLEN];      /* Image Name           */
> +     uint8_t         ih_name[IH_NMLEN] __nonstring;  /* Image Name   */
>  };
>  
>  struct image_info {
> diff --git a/tools/kwbimage.h b/tools/kwbimage.h
> index 505522332b..327ca34494 100644
> --- a/tools/kwbimage.h
> +++ b/tools/kwbimage.h
> @@ -11,12 +11,6 @@
>  #include <compiler.h>
>  #include <stdint.h>
>  
> -#ifdef __GNUC__
> -#define __packed __attribute((packed))
> -#else
> -#define __packed
> -#endif
> -
>  #define KWBIMAGE_MAX_CONFIG  ((0x1dc - 0x20)/sizeof(struct reg_config))
>  #define MAX_TEMPBUF_LEN              32
>  
> -- 
> 2.37.3
> 

Reply via email to