Use the LST_FOREACH macro instead of the Lst_ForEach function. This

saves function calls and reduces void casting.
This commit is contained in:
harti 2005-03-02 08:30:49 +00:00
parent e80e223f73
commit 9dee98908c

View File

@ -295,7 +295,6 @@ static sig_atomic_t interrupted;
#define W_SETEXITSTATUS(st, val) W_SETMASKED(st, val, WEXITSTATUS)
static int JobCondPassSig(void *, void *);
static void JobPassSig(int);
static int JobPrintCommand(void *, void *);
static int JobSaveCommand(void *, void *);
@ -327,26 +326,26 @@ JobCatchSig(int signo)
/*-
*-----------------------------------------------------------------------
* JobCondPassSig --
* Pass a signal to a job if USE_PGRP is defined.
*
* Results:
* === 0
* Pass a signal to all jobs
*
* Side Effects:
* None, except the job may bite it.
*
*-----------------------------------------------------------------------
*/
static int
JobCondPassSig(void *jobp, void *signop)
static void
JobCondPassSig(int signo)
{
Job *job = jobp;
int signo = *(int *)signop;
LstNode *ln;
Job *job;
DEBUGF(JOB, ("JobCondPassSig passing signal %d to child %d.\n",
signo, job->pid));
KILL(job->pid, signo);
return (0);
LST_FOREACH(ln, &jobs) {
job = Lst_Datum(ln);
DEBUGF(JOB, ("JobCondPassSig passing signal %d to child %d.\n",
signo, job->pid));
KILL(job->pid, signo);
}
}
/*-
@ -374,7 +373,7 @@ JobPassSig(int signo)
sigprocmask(SIG_SETMASK, &nmask, &omask);
DEBUGF(JOB, ("JobPassSig(%d) called.\n", signo));
Lst_ForEach(&jobs, JobCondPassSig, &signo);
JobCondPassSig(signo);
/*
* Deal with proper cleanup based on the signal received. We only run
@ -413,7 +412,7 @@ JobPassSig(int signo)
KILL(getpid(), signo);
signo = SIGCONT;
Lst_ForEach(&jobs, JobCondPassSig, &signo);
JobCondPassSig(signo);
sigprocmask(SIG_SETMASK, &omask, NULL);
sigprocmask(SIG_SETMASK, &omask, NULL);
@ -456,7 +455,7 @@ JobCmpPid(const void *job, const void *pid)
* made and return non-zero to signal that the end of the commands
* was reached. These commands are later attached to the postCommands
* node and executed by Job_Finish when all things are done.
* This function is called from JobStart via Lst_ForEach.
* This function is called from JobStart via LST_FOREACH.
*
* Results:
* Always 0, unless the command was "..."
@ -1402,6 +1401,7 @@ JobStart(GNode *gn, int flags, Job *previous)
Boolean cmdsOK; /* true if the nodes commands were all right */
Boolean noExec; /* Set true if we decide not to run the job */
int tfd; /* File descriptor for temp file */
LstNode *ln;
if (interrupted) {
JobPassSig(interrupted);
@ -1514,7 +1514,10 @@ JobStart(GNode *gn, int flags, Job *previous)
* We can do all the commands at once. hooray for sanity
*/
numCommands = 0;
Lst_ForEach(&gn->commands, JobPrintCommand, job);
LST_FOREACH(ln, &gn->commands) {
if (JobPrintCommand(Lst_Datum(ln), job))
break;
}
/*
* If we didn't print out any commands to the shell script,
@ -1540,7 +1543,10 @@ JobStart(GNode *gn, int flags, Job *previous)
* doesn't do any harm in this case and may do some good.
*/
if (cmdsOK) {
Lst_ForEach(&gn->commands, JobPrintCommand, job);
LST_FOREACH(ln, &gn->commands) {
if (JobPrintCommand(Lst_Datum(ln), job))
break;
}
}
/*
* Don't execute the shell, thank you.