From 80e364b7ad301da26015006d329df44a6853be75 Mon Sep 17 00:00:00 2001 From: tg Date: Fri, 30 Nov 2012 19:02:10 +0000 Subject: [PATCH] =?UTF-8?q?use=20proper=20parenthes=C4=93s;=20int=20?= =?UTF-8?q?=E2=86=92=20bool;=20use=20same=20var=20(eno)=20for=20temp.=20er?= =?UTF-8?q?rno?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- exec.c | 8 ++++---- histrap.c | 6 +++--- jobs.c | 15 ++++++++------- lex.c | 4 ++-- main.c | 6 +++--- var.c | 4 ++-- 6 files changed, 22 insertions(+), 21 deletions(-) diff --git a/exec.c b/exec.c index 79ada47..0271320 100644 --- a/exec.c +++ b/exec.c @@ -23,7 +23,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.105 2012/10/30 20:13:17 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.106 2012/11/30 19:02:06 tg Exp $"); #ifndef MKSH_DEFAULT_EXECSHELL #define MKSH_DEFAULT_EXECSHELL "/bin/sh" @@ -1385,13 +1385,13 @@ iosetup(struct ioword *iop, struct tbl *tp) close(iop->unit); else if (u != iop->unit) { if (ksh_dup2(u, iop->unit, true) < 0) { - int ev; + int eno; - ev = errno; + eno = errno; warningf(true, "%s %s %s", "can't finish (dup) redirection", snptreef(NULL, 32, "%R", &iotmp), - strerror(ev)); + strerror(eno)); if (iotype != IODUP) close(u); return (-1); diff --git a/histrap.c b/histrap.c index a87440d..25344ca 100644 --- a/histrap.c +++ b/histrap.c @@ -27,7 +27,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.127 2012/10/21 21:39:03 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.128 2012/11/30 19:02:07 tg Exp $"); Trap sigtraps[NSIG + 1]; static struct sigaction Sigact_ign; @@ -1112,7 +1112,7 @@ void trapsig(int i) { Trap *p = &sigtraps[i]; - int errno_sv = errno; + int eno = errno; trap = p->set = 1; if (p->flags & TF_DFL_INTR) @@ -1123,7 +1123,7 @@ trapsig(int i) } if (p->shtrap) (*p->shtrap)(i); - errno = errno_sv; + errno = eno; } /* diff --git a/jobs.c b/jobs.c index 4879c87..26096e1 100644 --- a/jobs.c +++ b/jobs.c @@ -22,7 +22,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.88 2012/05/04 22:34:50 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.89 2012/11/30 19:02:07 tg Exp $"); #if HAVE_KILLPG #define mksh_killpg killpg @@ -291,7 +291,7 @@ j_change(void) tty_init(false, true); /* no controlling tty, no SIGT* */ - if ((ttypgrp_ok = use_tty && tty_fd >= 0 && tty_devtty)) { + if ((ttypgrp_ok = (use_tty && tty_fd >= 0 && tty_devtty))) { setsig(&sigtraps[SIGTTIN], SIG_DFL, SS_RESTORE_ORIG|SS_FORCE); /* wait to be given tty (POSIX.1, B.2, job control) */ @@ -363,12 +363,12 @@ static void ksh_nice(int ness) { #if defined(__USE_FORTIFY_LEVEL) && (__USE_FORTIFY_LEVEL > 0) - int e; + int eno; errno = 0; /* this is gonna annoy users; complain to your distro, people! */ - if (nice(ness) == -1 && (e = errno) != 0) - warningf(false, "%s: %s", "bgnice", strerror(e)); + if (nice(ness) == -1 && (eno = errno) != 0) + warningf(false, "%s: %s", "bgnice", strerror(eno)); #else (void)nice(ness); #endif @@ -477,6 +477,7 @@ exchild(struct op *t, int flags, /* job control set up */ if (Flag(FMONITOR) && !(flags&XXCOM)) { bool dotty = false; + if (j->pgrp == 0) { /* First process */ j->pgrp = p->pid; @@ -829,7 +830,7 @@ j_resume(const char *cp, int bg) } if (j->state == PRUNNING && mksh_killpg(j->pgrp, SIGCONT) < 0) { - int err = errno; + int eno = errno; if (!bg) { j->flags &= ~JF_FG; @@ -842,7 +843,7 @@ j_resume(const char *cp, int bg) } sigprocmask(SIG_SETMASK, &omask, NULL); bi_errorf("%s %s %s", "can't continue job", - cp, strerror(err)); + cp, strerror(eno)); return (1); } if (!bg) { diff --git a/lex.c b/lex.c index 47d9d5e..5f00ab9 100644 --- a/lex.c +++ b/lex.c @@ -23,7 +23,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.170 2012/10/30 20:49:41 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.171 2012/11/30 19:02:08 tg Exp $"); /* * states while lexing word @@ -1394,7 +1394,7 @@ getsc_line(Source *s) { char *xp = Xstring(s->xs, xp), *cp; bool interactive = Flag(FTALKING) && s->type == SSTDIN; - int have_tty = interactive && (s->flags & SF_TTY); + bool have_tty = tobool(interactive && (s->flags & SF_TTY)); /* Done here to ensure nothing odd happens when a timeout occurs */ XcheckN(s->xs, xp, LINE); diff --git a/main.c b/main.c index f8fc873..c1dc9f5 100644 --- a/main.c +++ b/main.c @@ -34,7 +34,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/main.c,v 1.241 2012/11/26 22:49:48 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/main.c,v 1.242 2012/11/30 19:02:09 tg Exp $"); extern char **environ; @@ -1327,7 +1327,7 @@ initio(void) if ((lfp = getenv("SDMKSH_PATH")) == NULL) lfp = "/tmp/mksh-dbg.txt"; - if ((shl_dbg_fd = open(lfp, O_WRONLY | O_APPEND | O_CREAT, 0600)) == -1) + if ((shl_dbg_fd = open(lfp, O_WRONLY | O_APPEND | O_CREAT, 0600)) < 0) errorf("cannot open debug output file %s", lfp); if (shl_dbg_fd < FDBASE) { int nfd; @@ -1584,7 +1584,7 @@ maketemp(Area *ap, Temp_type type, struct temp **tlist) } while (len < 5); /* cyclically attempt to open a temporary file */ - while ((i = open(tp->tffn, O_CREAT | O_EXCL | O_RDWR, 0600)) == -1) { + while ((i = open(tp->tffn, O_CREAT | O_EXCL | O_RDWR, 0600)) < 0) { if (errno != EEXIST) goto maketemp_out; /* count down from z to a then from 9 to 0 */ diff --git a/var.c b/var.c index c47eb30..099a391 100644 --- a/var.c +++ b/var.c @@ -27,7 +27,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/var.c,v 1.159 2012/11/26 22:49:50 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/var.c,v 1.160 2012/11/30 19:02:10 tg Exp $"); /*- * Variables @@ -405,7 +405,7 @@ int setstr(struct tbl *vq, const char *s, int error_ok) { char *salloc = NULL; - int no_ro_check = error_ok & 0x4; + bool no_ro_check = tobool(error_ok & 0x4); error_ok &= ~0x4; if ((vq->flag & RDONLY) && !no_ro_check) {