From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 05 11:44:34 2024 Received: (at submit) by debbugs.gnu.org; 5 Jan 2024 16:44:34 +0000 Received: from localhost ([127.0.0.1]:57749 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLnJB-0003zp-PS for submit@debbugs.gnu.org; Fri, 05 Jan 2024 11:44:34 -0500 Received: from lists.gnu.org ([2001:470:142::17]:33136) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLnJ8-0003zb-Oo for submit@debbugs.gnu.org; Fri, 05 Jan 2024 11:44:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rLnIu-0001aT-V2 for bug-coreutils@gnu.org; Fri, 05 Jan 2024 11:44:18 -0500 Received: from zoidberg.rfc1149.net ([195.154.227.159]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rLnIr-0006H9-QF for bug-coreutils@gnu.org; Fri, 05 Jan 2024 11:44:16 -0500 Received: from 127.0.0.1 (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by zoidberg.rfc1149.net (Postfix) with ESMTPSA id 2291280024; Fri, 5 Jan 2024 17:44:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rfc1149.net; s=smtp; t=1704473050; bh=YIF66yJI/IJF4bDK009qi80PDDgwtBPW+cPFUNzXGU0=; h=From:To:Cc:Subject:Date; b=rRWioYcwP5VO0Zs8vLgEwF2BDH5oCPA2t53SwfldUrJv90dRZPH+AksJeUgC0bK6F ed+QdXTHFSqzNDrRTLluv49PJXpN8arKKMBlKtBbX4ptJFKZDUsxYuW4nxwpQTspfX 5ZnooEMTz9gkFI7Bq8Otat4mrVDmSTSDkb1462+sQV/XBO1R4+Hveuhd3u5GwEoZs7 o3eLZ0rVHKTUDDkC3HOrNN/9HlrYr426GR+PfglJo4nzwHNXDatuQi08kttyK0DxYy GP5b24vQ3kDZqLuOPogwAiozCzlWGwj4anbVlmOyaS1wFlnQE4mo/01WBBNpB0SgDY xpNuzbV0x5Pcg== From: Samuel Tardieu To: bug-coreutils@gnu.org Subject: [PATCH] maint: add attributes to two functions without side effects Date: Fri, 5 Jan 2024 17:44:06 +0100 Message-ID: <20240105164406.928215-1-sam@rfc1149.net> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=195.154.227.159; envelope-from=sam@rfc1149.net; helo=zoidberg.rfc1149.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.6 (/) X-Debbugs-Envelope-To: submit Cc: Samuel Tardieu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.4 (/) * src/date.c (res_width): This function computes its result solely from the value of its parameter and qualifies for the const attribute. * src/tee.c (get_next_out): This function has no side effect and qualifies for the pure attribute. Those two functions were flagged by GCC 12.3.0. --- Resent here, I sent it to the coreutils@ mailing-list while the hacking doc says to send it here. src/date.c | 1 + src/tee.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/date.c b/src/date.c index 39fc0715d..03bf012e2 100644 --- a/src/date.c +++ b/src/date.c @@ -294,6 +294,7 @@ Show the local time for 9AM next Friday on the west coast of the US\n\ /* Yield the number of decimal digits needed to output a time with the nanosecond resolution RES, without losing information. */ +ATTRIBUTE_CONST static int res_width (long int res) { diff --git a/src/tee.c b/src/tee.c index 07d525c95..eb074427c 100644 --- a/src/tee.c +++ b/src/tee.c @@ -185,6 +185,7 @@ main (int argc, char **argv) /* Return the index of the first non-null descriptor after idx, or -1 if all are null. */ +ATTRIBUTE_PURE static int get_next_out (FILE **descriptors, int nfiles, int idx) { -- 2.42.0 From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 06 10:34:22 2024 Received: (at 68267-done) by debbugs.gnu.org; 6 Jan 2024 15:34:22 +0000 Received: from localhost ([127.0.0.1]:60150 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rM8go-0001Ue-Fs for submit@debbugs.gnu.org; Sat, 06 Jan 2024 10:34:22 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:49386) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rM8gl-0001UR-Qi for 68267-done@debbugs.gnu.org; Sat, 06 Jan 2024 10:34:20 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-40e431a3566so246295e9.2 for <68267-done@debbugs.gnu.org>; Sat, 06 Jan 2024 07:34:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704555249; x=1705160049; darn=debbugs.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=EBQ1JxVBzbgEFiuZEj8dRm5hsB1qvT1F+LRyQ3cFvM4=; b=X4nW/Zg1Q2dx31QfHtPHZg3pYg69vTEhv4cbrGBsYdaEA5fYSRlV+s7zKto9mPkBsQ r5z1xlDTCjdrnSGs9R01dzyZ/Rg9SOfPv/s+BQKJUZSOf4PxNl2GXHU5xAKIuw/gbiGW IACqgWr2zBXOz4x9DKcDiyFK/d/bD2cyraMtgbugBGNG/qWBC5qt2F3+MujIh2l0sl2m Pvj0+PyX8oDPURasSelo6F1DOdepjJsulx38KwfRcb5oqg6UZmXRtWKmNTiWzfkBfumm pG9XM4EuHvOhyWjSPXDmu6NwPUkVyCN3c3Nx+N69Rq6U7unZPGc7taK9y7IjvERtbUqs CK6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704555249; x=1705160049; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EBQ1JxVBzbgEFiuZEj8dRm5hsB1qvT1F+LRyQ3cFvM4=; b=w8Oz9pL3hHljTKDE6VuU3Y1KtTOdcUKPIXczk39k8G1I91axK4RXYoFbIpJKmYgwvC P72mys/ImQdVAtE80FJlYxnETl3Gr6yr4+cCZ5GLfobhnCYWDcoxWtCNT7WScTTVu+3o 5tN5gRfdvunvRL+azo1BpUTj2GoP4cQzeO0KmUHVcYfF9YuZoVVeFQAXsR6fqL8uUaFE zHWs6JgdymPBbf0RknpGoFPMji52pTQ6V5c33FN+fDg7PXUUboqEms7makEpJsRYUpjb XkM1juUGIWRsn9m9+AxQzDEIil6IVY5ZO75e9U5WrgjjPMpdeFmAwbXe+a+vAhHDCndo Nv+w== X-Gm-Message-State: AOJu0YwYydW12DyWmsORHfeTedx3qqR+FoqoY4m9w+OvVk//C5v7em6H AiXDhcn5YWDc+aPAhfPGd9aYrfYRako= X-Google-Smtp-Source: AGHT+IH+YnuWabBYT11qlGf1enQzArjbwWa40H1ds2SwavsLfB3NpunfzOxqXHMARj5J/M0BIpB18w== X-Received: by 2002:a05:600c:1608:b0:40e:3b71:9ab2 with SMTP id m8-20020a05600c160800b0040e3b719ab2mr544002wmn.162.1704555248685; Sat, 06 Jan 2024 07:34:08 -0800 (PST) Received: from [192.168.1.20] (95-44-90-175-dynamic.agg2.lod.rsl-rtd.eircom.net. [95.44.90.175]) by smtp.googlemail.com with ESMTPSA id l42-20020a05600c1d2a00b004030e8ff964sm5013778wms.34.2024.01.06.07.34.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 06 Jan 2024 07:34:08 -0800 (PST) Message-ID: <8f5a4d0c-4cd7-02ae-e48a-e2a8fa71e3e6@draigBrady.com> Date: Sat, 6 Jan 2024 15:34:07 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: bug#68267: [PATCH] maint: add attributes to two functions without side effects Content-Language: en-US To: Samuel Tardieu , 68267-done@debbugs.gnu.org References: <20240105164406.928215-1-sam@rfc1149.net> From: =?UTF-8?Q?P=C3=A1draig_Brady?= In-Reply-To: <20240105164406.928215-1-sam@rfc1149.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 68267-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) On 05/01/2024 16:44, Samuel Tardieu wrote: > * src/date.c (res_width): This function computes its result solely > from the value of its parameter and qualifies for the const attribute. > * src/tee.c (get_next_out): This function has no side effect and > qualifies for the pure attribute. > > Those two functions were flagged by GCC 12.3.0. I'm guessing GCC 12 needs help here as it can't determine the loops are finite. (as per: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109914 ) Though I'm not seeing this suggestion with GCC 13.2.1, so perhaps GCC 12 can determine the loops are finite? I'll apply this since GCC 13 is less that a year old, but in general we try to avoid littering code like this. thanks, Pádraig From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 06 11:34:38 2024 Received: (at 68267) by debbugs.gnu.org; 6 Jan 2024 16:34:38 +0000 Received: from localhost ([127.0.0.1]:60229 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rM9d8-00056t-BI for submit@debbugs.gnu.org; Sat, 06 Jan 2024 11:34:38 -0500 Received: from mail.cs.ucla.edu ([131.179.128.66]:60746) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rM9d4-00056e-Sm for 68267@debbugs.gnu.org; Sat, 06 Jan 2024 11:34:37 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id 7C58D3C01409F; Sat, 6 Jan 2024 08:34:23 -0800 (PST) Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavis, port 10032) with ESMTP id RkFPTZfM2uZX; Sat, 6 Jan 2024 08:34:23 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id 1683D3C0140A0; Sat, 6 Jan 2024 08:34:23 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.cs.ucla.edu 1683D3C0140A0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.ucla.edu; s=9D0B346E-2AEB-11ED-9476-E14B719DCE6C; t=1704558863; bh=jCDbnZlJzHFbJLJp84MR+7Z409k493Jwk4d4bEPK2YY=; h=Message-ID:Date:MIME-Version:To:From; b=C9J/ENnJxjvJUCsz8+DY1fdTjkxoYI5MASkX9ZnzO73LThkBuskwzvP1f16ecU+1/ GK1QLFfNZStSIK3vNW2MWbbi+8p2GDVsyYCsaBhi37MiWjlb64SmkBOlHzVNlYtOlO pdentOYw/gFxXPbo5qSbPPZBW3pQBUnTTylX3nxJPML2G5uSKYoIF1r4Wftm0blTV0 oMoremHr2E4sUaiQuIcvunrps/INTSXcF2NtQtejglDm5M8Xi4CBpF+mjbbk8gDYa1 dNPXQ+TTWONCSCKQ1SHqbwnAEjn7xWqXGNFjT1eg10SfoQy7iPhh/HLTbldcinXcDG YD+UWAlGESjjA== X-Virus-Scanned: amavis at mail.cs.ucla.edu Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavis, port 10026) with ESMTP id KL7wmHLijRfw; Sat, 6 Jan 2024 08:34:23 -0800 (PST) Received: from [192.168.254.12] (unknown [47.148.192.211]) by mail.cs.ucla.edu (Postfix) with ESMTPSA id EF6D93C01409F; Sat, 6 Jan 2024 08:34:22 -0800 (PST) Message-ID: <76c02a77-2ebc-4884-834a-28b5d16d1987@cs.ucla.edu> Date: Sat, 6 Jan 2024 08:34:22 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: bug#68267: [PATCH] maint: add attributes to two functions without side effects To: 68267@debbugs.gnu.org, P@draigBrady.com, sam@rfc1149.net References: <20240105164406.928215-1-sam@rfc1149.net> <8f5a4d0c-4cd7-02ae-e48a-e2a8fa71e3e6@draigBrady.com> Content-Language: en-US From: Paul Eggert Organization: UCLA Computer Science Department In-Reply-To: <8f5a4d0c-4cd7-02ae-e48a-e2a8fa71e3e6@draigBrady.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 68267 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 2024-01-06 07:34, P=C3=A1draig Brady wrote: > Though I'm not seeing this suggestion with GCC 13.2.1, > so perhaps GCC 12 can determine the loops are finite? >=20 > I'll apply this since GCC 13 is less that a year old, > but in general we try to avoid littering code like this. I would not apply this, as it's a bug in GCC's warning code that has=20 been fixed. There is no need to apply these attributes to static=20 functions - as I understand it, with current GCC, either GCC figures out=20 the attributes anyway (so no need for humans to do it) or it doesn't (so=20 it doesn't know to warn). The attributes can help efficiency a bit with=20 small extern functions, but with small static functions they're not=20 worth the trouble. More generally, we don't need to cater to older compilers simply to=20 suppress false-positive warnings. We can simply tell users that they can=20 either ignore the harmless warnings or upgrade to the current GCC. Although there are some exceptions to this guideline (e.g., .h files=20 that are intended to be used by other people) this doesn't seem to be=20 one of them. From unknown Tue Aug 19 10:03:27 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 04 Feb 2024 12:24:08 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator