Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9D506C4332F for ; Wed, 12 Oct 2022 19:47:38 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BA84F84EA2; Wed, 12 Oct 2022 21:47:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="dv/Y2Hmt"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="iX0xOLHX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5ADBE84E09; Wed, 12 Oct 2022 21:47:34 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2D2DD84E95 for ; Wed, 12 Oct 2022 21:47:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=msuchanek@suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id DC90E1F937; Wed, 12 Oct 2022 19:47:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1665604051; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=eB15WK8Kg/1dBJF23Rr0wzgU0APH4T12FjDaIH/KwTU=; b=dv/Y2HmtXX0rkFTF1E8BPyPCgU58qweWukmwsaf1S+7zBaf9Goo9NFTIyXG7gmj2kmtdie 38McjBYPb6C4jLNEraKjdDrelC5he6TvG1xZuK+9hkjjqRauz7x9C0lBTOeA0b46NswI7f a2tGvPapJkaMjR+s+MuDKkDjcMF0uD8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1665604051; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=eB15WK8Kg/1dBJF23Rr0wzgU0APH4T12FjDaIH/KwTU=; b=iX0xOLHXTAnx6+tsfdcJdfusycHTi4YoBjZ+mNQO7D3t3SoTCHtBb1z14Oz0yIOZizRaxA Gkeqw5OJR2xJECCg== Received: from naga.suse.cz (unknown [10.100.224.114]) by relay2.suse.de (Postfix) with ESMTP id 750352C141; Wed, 12 Oct 2022 19:47:31 +0000 (UTC) From: Michal Suchanek To: u-boot@lists.denx.de Cc: Michal Suchanek , Andre Przywara , Heinrich Schuchardt , Jan Kiszka , Philippe Reynes , Sean Anderson , Simon Glass , Steven Lawrance Subject: [PATCH 1/2] image: Suppress string truncation warning Date: Wed, 12 Oct 2022 21:47:24 +0200 Message-Id: <20221012194725.5628-1-msuchanek@suse.de> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean 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); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There is no standard function that can be used to make the copy without a warning. Signed-off-by: Michal Suchanek --- include/image.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/image.h b/include/image.h index d7d6a3fe5b..e08ef6ed55 100644 --- a/include/image.h +++ b/include/image.h @@ -783,7 +783,14 @@ image_set_hdr_b(comp) /* image_set_comp */ static inline void image_set_name(struct legacy_img_hdr *hdr, const char *name) { +#if defined(__GNUC__) && (__GNUC__ > 7) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-truncation" +#endif strncpy(image_get_name(hdr), name, IH_NMLEN); +#if defined(__GNUC__) && (__GNUC__ > 7) +#pragma GCC diagnostic pop +#endif } int image_check_hcrc(const struct legacy_img_hdr *hdr); -- 2.37.3