use proper parenthesēs; int → bool; use same var (eno) for temp. errno

This commit is contained in:
tg 2012-11-30 19:02:10 +00:00
parent e36075e58d
commit 80e364b7ad
6 changed files with 22 additions and 21 deletions

8
exec.c
View File

@ -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);

View File

@ -27,7 +27,7 @@
#include <sys/file.h>
#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;
}
/*

15
jobs.c
View File

@ -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) {

4
lex.c
View File

@ -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);

6
main.c
View File

@ -34,7 +34,7 @@
#include <locale.h>
#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 */

4
var.c
View File

@ -27,7 +27,7 @@
#include <sys/sysctl.h>
#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) {