* bug#43982: strerror return value
@ 2020-10-13 19:15 Philipp Klaus Krause
2020-10-14 4:20 ` Lars Ingebrigtsen
0 siblings, 1 reply; 2+ messages in thread
From: Philipp Klaus Krause @ 2020-10-13 19:15 UTC (permalink / raw)
To: 43982
[-- 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);
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
* bug#43982: strerror return value
2020-10-13 19:15 bug#43982: strerror return value Philipp Klaus Krause
@ 2020-10-14 4:20 ` Lars Ingebrigtsen
0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2020-10-14 4:20 UTC (permalink / raw)
To: Philipp Klaus Krause; +Cc: 43982
Philipp Klaus Krause <pkk@spth.de> writes:
> 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.
[...]
> - char *s = strerror (errno);
> + const char *s = strerror (errno);
Makes sense; I've now applied this to Emacs 28.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-10-14 4:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-13 19:15 bug#43982: strerror return value Philipp Klaus Krause
2020-10-14 4:20 ` Lars Ingebrigtsen
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.