Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/libexec/getty Fix another automatic variable that is life bo...



details:   https://anonhg.NetBSD.org/src/rev/07df15d021ee
branches:  trunk
changeset: 789240:07df15d021ee
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Aug 11 09:16:42 2013 +0000

description:
Fix another automatic variable that is life both pre- and post the siglongjmp
(which gcc calls "might be clobbered") by marking it volatile: on some
machines, this value might end up in a register loaded before the sigsetjmp,
but not preserved by the siglongjmp later.
Fixes the VAX build.

diffstat:

 libexec/getty/main.c |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (43 lines):

diff -r a580a5fee465 -r 07df15d021ee libexec/getty/main.c
--- a/libexec/getty/main.c      Sun Aug 11 09:10:47 2013 +0000
+++ b/libexec/getty/main.c      Sun Aug 11 09:16:42 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.62 2013/08/11 05:48:56 dholland Exp $       */
+/*     $NetBSD: main.c,v 1.63 2013/08/11 09:16:42 martin Exp $ */
 
 /*-
  * Copyright (c) 1980, 1993
@@ -40,7 +40,7 @@
 #if 0
 static char sccsid[] = "from: @(#)main.c       8.1 (Berkeley) 6/20/93";
 #else
-__RCSID("$NetBSD: main.c,v 1.62 2013/08/11 05:48:56 dholland Exp $");
+__RCSID("$NetBSD: main.c,v 1.63 2013/08/11 09:16:42 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -183,13 +183,14 @@
 main(int argc, char *argv[], char *envp[])
 {
        const char *progname;
-       const char *tname;
        int repcnt = 0, failopenlogged = 0, first_time = 1;
        struct rlimit limit;
        struct passwd *pw;
        int rval;
-       /* gcc 4.5 claims longjmp can clobber this, but I don't see how */
+       /* this is used past the siglongjmp, so make sure it is not cached
+          in registers that might become invalid. */
        volatile int uugetty = 0;
+       const char * volatile tname = "default";
 
        (void)signal(SIGINT, SIG_IGN);
        openlog("getty", LOG_PID, LOG_AUTH);
@@ -294,7 +295,6 @@
 
        gettable("default", defent);
        gendefaults();
-       tname = "default";
        if (argc > 1)
                tname = argv[1];
        for (;;) {



Home | Main Index | Thread Index | Old Index