all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Philipp Klaus Krause <pkk@spth.de>
To: 43982@debbugs.gnu.org
Subject: bug#43982: strerror return value
Date: Tue, 13 Oct 2020 21:15:47 +0200	[thread overview]
Message-ID: <d21333e4-e3e8-ab95-060d-f68a7e5e387e@spth.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 316 bytes --]

This is just a very minor issue.

emacs contains two calls to strerror where the result is assigned
to a char *. However, according to the strerror specification, the
string returned by strerror should never be changed, so it would be
better to use const char * instead.

See the attached patch for the trivial fix.

[-- Attachment #2: emacs-strerror-const.patch --]
[-- Type: text/x-patch, Size: 817 bytes --]

diff --git a/lib-src/movemail.c b/lib-src/movemail.c
index 8016a4e373..4f9abc998a 100644
--- a/lib-src/movemail.c
+++ b/lib-src/movemail.c
@@ -580,7 +580,7 @@ pfatal_with_name (char *name)
 static void
 pfatal_and_delete (char *name)
 {
-  char *s = strerror (errno);
+  const char *s = strerror (errno);
   unlink (name);
   fatal ("%s for %s", s, name);
 }
diff --git a/src/emacs.c b/src/emacs.c
index 6ed970b9fd..e9e9661c39 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -1273,7 +1273,7 @@ main (int argc, char **argv)
 	      || (fcntl (STDIN_FILENO, F_DUPFD_CLOEXEC, STDOUT_FILENO)
 		  != STDOUT_FILENO))
 	    {
-	      char *errstring = strerror (errno);
+	      const char *errstring = strerror (errno);
 	      fprintf (stderr, "%s: %s: %s\n", argv[0], term, errstring);
 	      exit (EXIT_FAILURE);
 	    }

             reply	other threads:[~2020-10-13 19:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-13 19:15 Philipp Klaus Krause [this message]
2020-10-14  4:20 ` bug#43982: strerror return value Lars Ingebrigtsen

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d21333e4-e3e8-ab95-060d-f68a7e5e387e@spth.de \
    --to=pkk@spth.de \
    --cc=43982@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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.