From mboxrd@z Thu Jan 1 00:00:00 1970 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 7AB93C433FE for ; Thu, 10 Nov 2022 02:16:12 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3FA6285100; Thu, 10 Nov 2022 03:16:10 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="DZ9gqNkx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D85F2850F0; Thu, 10 Nov 2022 03:16:06 +0100 (CET) Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7D22A850CE for ; Thu, 10 Nov 2022 03:16:03 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd33.google.com with SMTP id z3so300987iof.3 for ; Wed, 09 Nov 2022 18:16:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LO29/MQJkGo/eJgKTvePVqKr6gRNajH46+8JZpGn7wA=; b=DZ9gqNkxCLAlIZgDuC4tny1ugERFpCSb3i2Ha3s7DRRlfLtRTonoGxNClN0pxOIqOt i08kUUyUFyUe3swKDfaz12PgsjmoEmUcKJQQP7oXz96hQhEf4kod6yPtls3ueqLWoSIl v2o7UGQ58AzOVSNWRZpRhESxNV7MCtNbumbH4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LO29/MQJkGo/eJgKTvePVqKr6gRNajH46+8JZpGn7wA=; b=rs/EnIGks3c1noH93c8I7y0vHxThTysQe7uiDJHektvlyvUUyPtimWeoe3Xbd7AyTy o+wou1N0C3QrGX/8eUicbwnfNGrQ5LogB+5VkF8C6An2QcjVtvICv0o3VgFbUL7mHy/a Zsb6eKhnga1BpHIum4ce9EXeNsLtZ2Z5rb2Y7QNMZ7G1Gk97khCNOjC1j1eLrPAob+ct TvDafypUuNNyU00OyssD3i7Sfbodw2Yzc9ARlWBYGPchoXuVkc+xMq/Wx5bEpzqgKN2w w587j/lBftkIt+Ep/M/vTxpeK5GGfyidh0nEYOLDMvGNw7ZBjQLmb7r9/Bg0+FdlQ1/i 04aA== X-Gm-Message-State: ACrzQf2wx5FTvuldtc7tLhLG75WAis0ZhcWEbaYNi9tfsL0EtRm+D8Mp ajGk9Zv16MIcjlKRiTprRjqY16JTzMFzrA== X-Google-Smtp-Source: AMsMyM5gtBOwcUzXcoa89rwCm/zsmY0aiAY5NWvgjfD+4pRYmoJYN+FwDMPNQHSjJnNkxg1GIyRkMA== X-Received: by 2002:a05:6602:483:b0:68a:b5f2:a508 with SMTP id y3-20020a056602048300b0068ab5f2a508mr35198990iov.97.1668046561803; Wed, 09 Nov 2022 18:16:01 -0800 (PST) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id z23-20020a056638215700b003636b73cf29sm5352785jaj.8.2022.11.09.18.16.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 18:16:01 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Rasmus Villemoes , Simon Glass , Andre Przywara , Heinrich Schuchardt , Jan Kiszka , Joe Hershberger , Marek Vasut , Philippe Reynes , Sean Anderson , Steven Lawrance Subject: [PATCH v5 01/16] image: Correct strncpy() warning with image_set_name() Date: Wed, 9 Nov 2022 19:14:39 -0700 Message-Id: <20221110021455.1004335-2-sjg@chromium.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221110021455.1004335-1-sjg@chromium.org> References: <20221110021455.1004335-1-sjg@chromium.org> MIME-Version: 1.0 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 gcc 12 seems to warn on strncpy() as a matter of course. Rewrite the code a different way to do the same thing, to avoid the warning. Signed-off-by: Simon Glass --- (no changes since v1) include/image.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/image.h b/include/image.h index 65d0d4f4387..6f21dafba8c 100644 --- a/include/image.h +++ b/include/image.h @@ -853,7 +853,13 @@ image_set_hdr_b(comp) /* image_set_comp */ static inline void image_set_name(struct legacy_img_hdr *hdr, const char *name) { - strncpy(image_get_name(hdr), name, IH_NMLEN); + /* + * This is equivalent to: strncpy(image_get_name(hdr), name, IH_NMLEN); + * + * Use the tortured code below to avoid a warning with gcc 12. We do not + * want to include a nul terminator if the name is of length IH_NMLEN + */ + memcpy(image_get_name(hdr), name, strnlen(name, IH_NMLEN)); } int image_check_hcrc(const struct legacy_img_hdr *hdr); -- 2.38.1.431.g37b22c650d-goog