diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2023-07-05 18:45:15 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2023-07-05 18:45:15 +0000 |
commit | 6f50fa37070232dc215585aab16f2fd60b30806f (patch) | |
tree | 3526c6718eb9e009d42abe930c1154d8c4bbfc91 | |
parent | 205f38591802247882a1aac84b2e8c56acd07702 (diff) |
It isn't portable to use stderr (or std{in,out}) in file-scope
initializers as they are not required to be compile-time constants.
So, intialize these global variables at the top of main().
ok miod@ deraadt@ yasuoka@ millert@
-rw-r--r-- | bin/pax/pax.c | 6 | ||||
-rw-r--r-- | usr.sbin/amd/amd/amd.c | 4 | ||||
-rw-r--r-- | usr.sbin/amd/amd/xutil.c | 4 |
3 files changed, 9 insertions, 5 deletions
diff --git a/bin/pax/pax.c b/bin/pax/pax.c index 0ddfd9d91ed..cd5fcd69021 100644 --- a/bin/pax/pax.c +++ b/bin/pax/pax.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pax.c,v 1.53 2019/06/28 13:34:59 deraadt Exp $ */ +/* $OpenBSD: pax.c,v 1.54 2023/07/05 18:45:14 guenther Exp $ */ /* $NetBSD: pax.c,v 1.5 1996/03/26 23:54:20 mrg Exp $ */ /*- @@ -93,7 +93,7 @@ char *dirptr; /* destination dir in a copy */ char *argv0; /* root of argv[0] */ enum op_mode op_mode; /* what program are we acting as? */ sigset_t s_mask; /* signal mask for cleanup critical sect */ -FILE *listf = stderr; /* file pointer to print file list to */ +FILE *listf; /* file pointer to print file list to */ int listfd = STDERR_FILENO; /* fd matching listf, for sighandler output */ char *tempfile; /* tempfile to use for mkstemp(3) */ char *tempbase; /* basename of tempfile to use for mkstemp(3) */ @@ -224,6 +224,8 @@ main(int argc, char **argv) char *tmpdir; size_t tdlen; + listf = stderr; + /* * Keep a reference to cwd, so we can always come back home. */ diff --git a/usr.sbin/amd/amd/amd.c b/usr.sbin/amd/amd/amd.c index 03163b129d1..1c777cd9672 100644 --- a/usr.sbin/amd/amd/amd.c +++ b/usr.sbin/amd/amd/amd.c @@ -32,7 +32,7 @@ * SUCH DAMAGE. * * from: @(#)amd.c 8.1 (Berkeley) 6/6/93 - * $Id: amd.c,v 1.24 2021/10/21 10:55:56 deraadt Exp $ + * $Id: amd.c,v 1.25 2023/07/05 18:45:14 guenther Exp $ */ /* @@ -190,6 +190,8 @@ main(int argc, char *argv[]) pid_t ppid = 0; int error; + logfp = stderr; /* Log errors to stderr initially */ + /* * Make sure some built-in assumptions are true before we start */ diff --git a/usr.sbin/amd/amd/xutil.c b/usr.sbin/amd/amd/xutil.c index ea36fec9c98..082ac1555e9 100644 --- a/usr.sbin/amd/amd/xutil.c +++ b/usr.sbin/amd/amd/xutil.c @@ -32,7 +32,7 @@ * SUCH DAMAGE. * * from: @(#)xutil.c 8.1 (Berkeley) 6/6/93 - * $Id: xutil.c,v 1.19 2015/12/12 20:06:42 mmcc Exp $ + * $Id: xutil.c,v 1.20 2023/07/05 18:45:14 guenther Exp $ */ #include "am.h" @@ -45,7 +45,7 @@ #include <time.h> #include <unistd.h> -FILE *logfp = stderr; /* Log errors to stderr initially */ +FILE *logfp; int syslogging; int xlog_level = XLOG_ALL & ~XLOG_MAP & ~XLOG_STATS & ~XLOG_INFO; int xlog_level_init = ~0; |