From: Samuel Tardieu <sam@rfc1149.net>
To: 68267@debbugs.gnu.org
Cc: Samuel Tardieu <sam@rfc1149.net>
Subject: bug#68267: [PATCH] maint: add attributes to two functions without side effects
Date: Fri, 5 Jan 2024 17:44:06 +0100 [thread overview]
Message-ID: <20240105164406.928215-1-sam@rfc1149.net> (raw)
* 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
next reply other threads:[~2024-01-05 16:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-05 16:44 Samuel Tardieu [this message]
2024-01-06 15:34 ` bug#68267: [PATCH] maint: add attributes to two functions without side effects Pádraig Brady
2024-01-06 16:34 ` Paul Eggert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.gnu.org/mailman/listinfo/bug-coreutils
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240105164406.928215-1-sam@rfc1149.net \
--to=sam@rfc1149.net \
--cc=68267@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).