Received: by 2002:a05:7412:3210:b0:e2:908c:2ebd with SMTP id eu16csp400100rdb; Thu, 31 Aug 2023 12:43:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHoaWxyoirQG/eWm+IX/X8UuCu2NcSwCO/qhNAG5uSOs0ikaGMX/RkCVWELer58ENkWFvn+ X-Received: by 2002:a05:6a00:330f:b0:68a:2260:c84d with SMTP id cq15-20020a056a00330f00b0068a2260c84dmr739540pfb.10.1693511006712; Thu, 31 Aug 2023 12:43:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693511006; cv=none; d=google.com; s=arc-20160816; b=VrYPOJYJLcSR8E0AHxOfjzzPJTBeGugG+j4Oyi0L/QOixZyhURzBkA2sbhY+OhTjXy UfS5xQHIHE/npvw/M518YS7uYxniA5EPLbr5TQ8KF5DcQD+8AoxSFzTGO8jyp3j4oK1s sPWVGcNOND+9JqfoYrerYjbgR7CSpCx5d5wrR+BXjfp0ZZasA05+jNhQGnNednTGcROj 6e4szRIDoUteruMNkKjDD9kNccPr2I3UfOnI6z/xcUKqPNmYsIm4W6CI61VOwGW3rHJ7 NgwYSHEqSbx+Jc6yF4A6UwWBhLpJjsHgXZv5chEP7Bo7A0+YwceGCY8q5zfiMoCDHsOc J9OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=mn628LmpxG/f96/Oo5mjK3y99XwY+d3qYPV700oEkNA=; fh=Up195F8ESrqJoyv7b2mH+sLMTmRiE5LpNkLHdbL/nQ8=; b=ulZ8Rn3eeDbOU+tK2gsPrHGaVe8kzWUcmJMH8V+2SDjaoqTA/juA27Eli5GBHqxR4x L3ahMBYtt/tVzTTYu2K4VB4Yu3dIQZrMt2fVs+RsXAyCQU1AhoLLgtuWQGER3tf3zjcu G4xDelGIyhpnz2/p3MqlQzs9Bl6d2Bldi3RYoHYOePqDLkyKzlNHu33Zkxbx2JFxpxQv irWmTx0zvbFuBYc2eU+Nk06aEfbuXxHgzuUHbIIQgkBcGCU4whTwUsKc0jEtOJfP8E2D YM/iJovf1qq055Oi6UT8+tQ2qck26xpwn2GGZrN8sJtEXWeO66xJXNXwOvnn9+PdVhGH sD5w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eg16-20020a056a00801000b0068c005fcd11si1710901pfb.20.2023.08.31.12.42.49; Thu, 31 Aug 2023 12:43:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243347AbjHaJfl convert rfc822-to-8bit (ORCPT + 93 others); Thu, 31 Aug 2023 05:35:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231892AbjHaJfk (ORCPT ); Thu, 31 Aug 2023 05:35:40 -0400 Received: from mail-oo1-f44.google.com (mail-oo1-f44.google.com [209.85.161.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60361CDD; Thu, 31 Aug 2023 02:35:37 -0700 (PDT) Received: by mail-oo1-f44.google.com with SMTP id 006d021491bc7-5733d11894dso147846eaf.0; Thu, 31 Aug 2023 02:35:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693474536; x=1694079336; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w1zXFq6yH7gKwLUxTi+5zNAwg8QTKD31cnvIQY4Ezq4=; b=MdQZEA+QRH/2YwCpiwqPxcVTSPPPiY85nOMb4Fwr0eYW7x4rDUa4cny7IQL1FwfDIx qwNjRICZRVRNrw6kZHatEI6UlP21bSmSduWGTiCMPWBJem1QEVXu3RibF8Gi1N9Cm/86 /NIp/il3aQ2lwmaqpN0vad6I+pwYDkn/pYVTU7xWPXYiG4ZptLPdB1vgma5tDlnq2xYX lB5rZq2kVOM3Q6FW/KB9n/s7TMB5JEF/S7PBDsX+LEWgZk2Q8D1ny/hjhA2RaCQCnP1d ZknscjsER6+Vs80bzK/AfgwtpBArS0i+fySahEV+sbB+ZNs0g4anG0g8Jittv5J8djHv XUBg== X-Gm-Message-State: AOJu0YxYKMAVltPBnOC+qC+D73oz6b3CgYmbRDTSypk6xnMs1OZQCYuP gEMtWKjcGsvpZ5qMN5qjUjvWztpl1ka//o4bPAbpZI+gZhw= X-Received: by 2002:a4a:a302:0:b0:573:764b:3b8d with SMTP id q2-20020a4aa302000000b00573764b3b8dmr4332395ool.0.1693474536546; Thu, 31 Aug 2023 02:35:36 -0700 (PDT) MIME-Version: 1.0 References: <20230831073432.1712904-1-suhui@nfschina.com> In-Reply-To: <20230831073432.1712904-1-suhui@nfschina.com> From: "Rafael J. Wysocki" Date: Thu, 31 Aug 2023 11:35:24 +0200 Message-ID: Subject: Re: [PATCH 1/2] ACPICA: Use strscpy to replace strncpy To: Su Hui Cc: robert.moore@intel.com, rafael.j.wysocki@intel.com, lenb@kernel.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linuxfoundation.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 31, 2023 at 9:35 AM Su Hui wrote: > > With gcc and W=1 option to compile kernel, warning happens: > > inlined from ‘acpi_tb_find_table’ at drivers/acpi/acpica/tbfind.c:60:2: > include/linux/fortify-string.h:68:30: error: ‘__builtin_strncpy’ specified > bound 6 equals destination size [-Werror=stringop-truncation] > > Use strscpy to avoid this warning and is safer. > > Signed-off-by: Su Hui Please see https://lore.kernel.org/linux-acpi/202308241612.DFE4119@keescook/ > --- > drivers/acpi/acpica/tbfind.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/acpi/acpica/tbfind.c b/drivers/acpi/acpica/tbfind.c > index 1c1b2e284bd9..5536d1755188 100644 > --- a/drivers/acpi/acpica/tbfind.c > +++ b/drivers/acpi/acpica/tbfind.c > @@ -57,8 +57,8 @@ acpi_tb_find_table(char *signature, > > memset(&header, 0, sizeof(struct acpi_table_header)); > ACPI_COPY_NAMESEG(header.signature, signature); > - strncpy(header.oem_id, oem_id, ACPI_OEM_ID_SIZE); > - strncpy(header.oem_table_id, oem_table_id, ACPI_OEM_TABLE_ID_SIZE); > + strscpy(header.oem_id, oem_id, ACPI_OEM_ID_SIZE); > + strscpy(header.oem_table_id, oem_table_id, ACPI_OEM_TABLE_ID_SIZE); > > /* Search for the table */ > > -- > 2.30.2 >