From: Tomi Ollila <tomi.ollila@iki.fi>
To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org
Cc: David Bremner <david@tethera.net>
Subject: Re: [PATCH 6/7] CLI: make static message strings const
Date: Thu, 13 May 2021 20:27:44 +0300 [thread overview]
Message-ID: <m2bl9e4k8f.fsf@guru.guru-group.fi> (raw)
In-Reply-To: <20210513100710.1460566-7-david@tethera.net>
On Thu, May 13 2021, David Bremner wrote:
> This is both a bit clearer and avoids the possibility of modification.
> ---
> notmuch-insert.c | 2 +-
> notmuch-tag.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/notmuch-insert.c b/notmuch-insert.c
> index 00c00468..e3d87e4a 100644
> --- a/notmuch-insert.c
> +++ b/notmuch-insert.c
> @@ -34,7 +34,7 @@ static volatile sig_atomic_t interrupted;
> static void
> handle_sigint (unused (int sig))
> {
> - static char msg[] = "Stopping... \n";
> + static const char msg[] = "Stopping... \n";
If compiler is smart enough, it can even save copy from read-only
area of the binary to read-write runtime memory area.
If not that smart it does the copy.
In my projects I've been using the following macro:
#define WriteCS(fd, str) write((fd), (str), sizeof(str) - 1)
but I don't know if that behaved any better (if we cared)...
But, in addition to these two identical copies of handle_sigint()
also notmuch-new.c and notmuch-reindex.c defines anoter 2 identical
copies of handle_sigint()...
I did not see that those two were also modified in this series...
Other that these, the series looked ok...
Tomi
>
> /* This write is "opportunistic", so it's okay to ignore the
> * result. It is not required for correctness, and if it does
> diff --git a/notmuch-tag.c b/notmuch-tag.c
> index 667a75d6..de428c8e 100644
> --- a/notmuch-tag.c
> +++ b/notmuch-tag.c
> @@ -27,7 +27,7 @@ static volatile sig_atomic_t interrupted;
> static void
> handle_sigint (unused (int sig))
> {
> - static char msg[] = "Stopping... \n";
> + static const char msg[] = "Stopping... \n";
>
> /* This write is "opportunistic", so it's okay to ignore the
> * result. It is not required for correctness, and if it does
> --
> 2.30.2
> _______________________________________________
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-leave@notmuchmail.org
next prev parent reply other threads:[~2021-05-13 17:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-13 10:07 static variable cleanup David Bremner
2021-05-13 10:07 ` [PATCH 1/7] lib: make glib initialization thread-safe David Bremner
2021-05-13 10:07 ` [PATCH 2/7] lib/generate_thread_id: move static buffer to notmuch_database_t David Bremner
2021-05-13 10:07 ` [PATCH 3/7] lib/message: mark flag2tag as const David Bremner
2021-05-13 10:07 ` [PATCH 4/7] CLI: centralize initialization in notmuch_client_init David Bremner
2021-05-13 10:07 ` [PATCH 5/7] CLI/config: make immutable tables const David Bremner
2021-05-13 10:07 ` [PATCH 6/7] CLI: make static message strings const David Bremner
2021-05-13 17:27 ` Tomi Ollila [this message]
2021-05-14 10:24 ` David Bremner
2021-05-14 14:39 ` Tomi Ollila
2021-05-13 10:07 ` [PATCH 7/7] CLI/notmuch: make immutable tables const David Bremner
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://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2bl9e4k8f.fsf@guru.guru-group.fi \
--to=tomi.ollila@iki.fi \
--cc=david@tethera.net \
--cc=notmuch@notmuchmail.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.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
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).