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 C939EC433FE for ; Thu, 13 Oct 2022 08:12:17 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D846084EF9; Thu, 13 Oct 2022 10:12:14 +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="MoOJ9+EM"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="0YNx08Gx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AC44D8491C; Thu, 13 Oct 2022 10:12:13 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) (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 F2C7E84E8D for ; Thu, 13 Oct 2022 10:12:10 +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 AB6701F74D; Thu, 13 Oct 2022 08:12:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1665648730; 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: in-reply-to:in-reply-to:references:references; bh=ecnkq8IZUM5OIjEAMdp03ndPmbOOmy/g/1JMHaiY4NY=; b=MoOJ9+EMYfJzj09nKYbLHVtbbj7Mmk2WnTHisaxTLH/pcO9RLb1fM8FDdZm59FY23O96Rv CrRZCnXp+Ab9eTbszra01lzkrS5HaYY+FWmMLEyJbzDcrbp2c33be5WxVjlMe8NEtlS9YZ naFjDHxpg5mN94oYewpRx7igw2Qu5UE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1665648730; 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: in-reply-to:in-reply-to:references:references; bh=ecnkq8IZUM5OIjEAMdp03ndPmbOOmy/g/1JMHaiY4NY=; b=0YNx08Gxz1PlUALPfH6Y6HEPAUpyx9YXsHYgrTpVAPX3WsGBJD1yzR4v0iqdrxiuHzLy7v RNY56dRvQZ+4UICw== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 431892C141; Thu, 13 Oct 2022 08:12:10 +0000 (UTC) Date: Thu, 13 Oct 2022 10:12:09 +0200 From: Michal =?iso-8859-1?Q?Such=E1nek?= To: Rasmus Villemoes Cc: u-boot@lists.denx.de, Andre Przywara , Heinrich Schuchardt , Jan Kiszka , Philippe Reynes , Sean Anderson , Simon Glass , Steven Lawrance Subject: Re: [PATCH 1/2] image: Suppress string truncation warning Message-ID: <20221013081209.GF28810@kitsune.suse.cz> References: <20221012194725.5628-1-msuchanek@suse.de> <4abe5029-b8fd-efdc-3144-b89a8dec3fe4@prevas.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4abe5029-b8fd-efdc-3144-b89a8dec3fe4@prevas.dk> User-Agent: Mutt/1.10.1 (2018-07-13) 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 On Thu, Oct 13, 2022 at 09:29:22AM +0200, Rasmus Villemoes wrote: > On 12/10/2022 21.47, 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); > > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > There is no standard function that can be used to make the copy without > > a warning. > > True, but the compiler does give a way to inform that the destination is > not _supposed_ to be a nul-terminated string. > > https://lore.kernel.org/u-boot/dad17a9f-d823-1e8b-3381-53961294521c@prevas.dk/ > > And our include/linux/compiler_attributes.h indeed already exposes that > __nonstring attribute. Perhaps try applying that to the ih_name member. That's better, that's an actual fix. Thanks Michal