Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:19
erlang
1009-Since-the-string-from-strerror-should-neve...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 1009-Since-the-string-from-strerror-should-never-be-modif.patch of Package erlang
From 894c45b308c98852769263d98a18e517183f414b Mon Sep 17 00:00:00 2001 From: Philipp Klaus Krause <pkk@spth.de> Date: Wed, 14 Oct 2020 10:45:34 +0200 Subject: [PATCH] Since the string from strerror should never be modified, use const. --- erts/emulator/beam/erl_alloc.c | 2 +- erts/emulator/beam/erl_drv_thread.c | 4 ++-- erts/emulator/beam/erl_init.c | 2 +- erts/emulator/sys/unix/sys_time.c | 10 +++++----- erts/etc/common/erlexec.c | 4 ++-- erts/lib_src/common/ethr_aux.c | 2 +- lib/erl_interface/src/connect/ei_connect.c | 4 ++-- lib/tools/c_src/erl_memory.c | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/erts/emulator/beam/erl_alloc.c b/erts/emulator/beam/erl_alloc.c index f98471420a..ade67e7301 100644 --- a/erts/emulator/beam/erl_alloc.c +++ b/erts/emulator/beam/erl_alloc.c @@ -710,7 +710,7 @@ erts_alloc_init(int *argc, char **argv, ErtsAllocInitOpts *eaiop) errno = 0; if (mlockall(MCL_CURRENT|MCL_FUTURE) != 0) { int err = errno; - char *errstr = err ? strerror(err) : "unknown"; + const char *errstr = err ? strerror(err) : "unknown"; erts_exit(1, "Failed to lock physical memory: %s (%d)\n", errstr, err); } diff --git a/erts/emulator/beam/erl_drv_thread.c b/erts/emulator/beam/erl_drv_thread.c index 04839fa958..949d89232a 100644 --- a/erts/emulator/beam/erl_drv_thread.c +++ b/erts/emulator/beam/erl_drv_thread.c @@ -35,9 +35,9 @@ + sizeof(((ErlDrvThreadOpts *) 0)->LAST_FIELD)) static void -fatal_error(int err, char *func) +fatal_error(int err, const char *func) { - char *estr = strerror(err); + const char *estr = strerror(err); if (!estr) { if (err == ENOTSUP) estr = "Not supported"; diff --git a/erts/emulator/beam/erl_init.c b/erts/emulator/beam/erl_init.c index aca03157dd..6ab85cffc4 100644 --- a/erts/emulator/beam/erl_init.c +++ b/erts/emulator/beam/erl_init.c @@ -2380,7 +2380,7 @@ erl_start(int argc, char **argv) __decl_noreturn void erts_thr_fatal_error(int err, char *what) { - char *errstr = err ? strerror(err) : NULL; + const char *errstr = err ? strerror(err) : NULL; erts_fprintf(stderr, "Failed to %s: %s%s(%d)\n", what, diff --git a/erts/emulator/sys/unix/sys_time.c b/erts/emulator/sys/unix/sys_time.c index 64c8f006c9..5fd48b793c 100644 --- a/erts/emulator/sys/unix/sys_time.c +++ b/erts/emulator/sys/unix/sys_time.c @@ -453,7 +453,7 @@ posix_clock_gettime(clockid_t id, char *name) if (clock_gettime(id, &ts) != 0) { int err = errno; - char *errstr = err ? strerror(err) : "unknown"; + const char *errstr = err ? strerror(err) : "unknown"; erts_exit(ERTS_ABORT_EXIT, "clock_gettime(%s, _) failed: %s (%d)\n", name, errstr, err); @@ -498,13 +498,13 @@ posix_clock_gettime_times(clockid_t mid, char *mname, serr = errno; if (mres != 0) { - char *errstr = merr ? strerror(merr) : "unknown"; + const char *errstr = merr ? strerror(merr) : "unknown"; erts_exit(ERTS_ABORT_EXIT, "clock_gettime(%s, _) failed: %s (%d)\n", mname, errstr, merr); } if (sres != 0) { - char *errstr = serr ? strerror(serr) : "unknown"; + const char *errstr = serr ? strerror(serr) : "unknown"; erts_exit(ERTS_ABORT_EXIT, "clock_gettime(%s, _) failed: %s (%d)\n", sname, errstr, serr); @@ -698,7 +698,7 @@ mach_clocks_init(void) if (atexit(mach_clocks_fini) != 0) { int err = errno; - char *errstr = err ? strerror(err) : "unknown"; + const char *errstr = err ? strerror(err) : "unknown"; erts_exit(ERTS_ABORT_EXIT, "Failed to register mach_clocks_fini() " "for call at exit: %s (%d)\n", @@ -853,7 +853,7 @@ erts_os_system_time(void) if (gettimeofday(&tv, NULL) != 0) { int err = errno; - char *errstr = err ? strerror(err) : "unknown"; + const char *errstr = err ? strerror(err) : "unknown"; erts_exit(ERTS_ABORT_EXIT, "gettimeofday(_, NULL) failed: %s (%d)\n", errstr, err); diff --git a/erts/etc/common/erlexec.c b/erts/etc/common/erlexec.c index 06a60244ff..028c3a6789 100644 --- a/erts/etc/common/erlexec.c +++ b/erts/etc/common/erlexec.c @@ -1854,10 +1854,10 @@ done: #undef ENSURE } -static char * +static const char * errno_string(void) { - char *str = strerror(errno); + const char *str = strerror(errno); if (!str) return "unknown error"; return str; diff --git a/erts/lib_src/common/ethr_aux.c b/erts/lib_src/common/ethr_aux.c index b844960854..c24f262e9c 100644 --- a/erts/lib_src/common/ethr_aux.c +++ b/erts/lib_src/common/ethr_aux.c @@ -738,7 +738,7 @@ ETHR_IMPL_NORETURN__ ethr_fatal_error__(const char *file, const char *func, int err) { - char *errstr; + const char *errstr; if (err == ENOTSUP) errstr = "Operation not supported"; else { diff --git a/lib/tools/c_src/erl_memory.c b/lib/tools/c_src/erl_memory.c index 13a3fccc6d..d52203c7cd 100644 --- a/lib/tools/c_src/erl_memory.c +++ b/lib/tools/c_src/erl_memory.c @@ -1859,7 +1859,7 @@ error_string(int error) error_str = unknown_error; if (error > 0) { - char *str = strerror(error); + const char *str = strerror(error); if (str) error_str = str; } -- 2.26.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor