meta.c: use macro to access job->bm
and if job is NULL use Mybm. No functional change.
This commit is contained in:
parent
68f52b2486
commit
6f6525029a
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: meta.c,v 1.202 2023/02/14 21:38:31 rillig Exp $ */
|
/* $NetBSD: meta.c,v 1.203 2023/02/25 22:52:21 sjg Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Implement 'meta' mode.
|
* Implement 'meta' mode.
|
||||||
|
@ -99,6 +99,8 @@ extern char **environ;
|
||||||
# define strsep(s, d) stresep((s), (d), '\0')
|
# define strsep(s, d) stresep((s), (d), '\0')
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define BM(job) (job != NULL) ? &job->bm : &Mybm
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Filemon is a kernel module which snoops certain syscalls.
|
* Filemon is a kernel module which snoops certain syscalls.
|
||||||
*
|
*
|
||||||
|
@ -642,11 +644,7 @@ meta_job_start(Job *job, GNode *gn)
|
||||||
{
|
{
|
||||||
BuildMon *pbm;
|
BuildMon *pbm;
|
||||||
|
|
||||||
if (job != NULL) {
|
pbm = BM(job);
|
||||||
pbm = &job->bm;
|
|
||||||
} else {
|
|
||||||
pbm = &Mybm;
|
|
||||||
}
|
|
||||||
pbm->mfp = meta_create(pbm, gn);
|
pbm->mfp = meta_create(pbm, gn);
|
||||||
#ifdef USE_FILEMON_ONCE
|
#ifdef USE_FILEMON_ONCE
|
||||||
/* compat mode we open the filemon dev once per command */
|
/* compat mode we open the filemon dev once per command */
|
||||||
|
@ -673,11 +671,7 @@ meta_job_child(Job *job MAKE_ATTR_UNUSED)
|
||||||
#ifdef USE_FILEMON
|
#ifdef USE_FILEMON
|
||||||
BuildMon *pbm;
|
BuildMon *pbm;
|
||||||
|
|
||||||
if (job != NULL) {
|
pbm = BM(job);
|
||||||
pbm = &job->bm;
|
|
||||||
} else {
|
|
||||||
pbm = &Mybm;
|
|
||||||
}
|
|
||||||
if (pbm->mfp != NULL) {
|
if (pbm->mfp != NULL) {
|
||||||
close(fileno(pbm->mfp));
|
close(fileno(pbm->mfp));
|
||||||
if (useFilemon && pbm->filemon != NULL) {
|
if (useFilemon && pbm->filemon != NULL) {
|
||||||
|
@ -698,11 +692,7 @@ meta_job_parent(Job *job MAKE_ATTR_UNUSED, pid_t pid MAKE_ATTR_UNUSED)
|
||||||
#if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV)
|
#if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV)
|
||||||
BuildMon *pbm;
|
BuildMon *pbm;
|
||||||
|
|
||||||
if (job != NULL) {
|
pbm = BM(job);
|
||||||
pbm = &job->bm;
|
|
||||||
} else {
|
|
||||||
pbm = &Mybm;
|
|
||||||
}
|
|
||||||
if (useFilemon && pbm->filemon != NULL) {
|
if (useFilemon && pbm->filemon != NULL) {
|
||||||
filemon_setpid_parent(pbm->filemon, pid);
|
filemon_setpid_parent(pbm->filemon, pid);
|
||||||
}
|
}
|
||||||
|
@ -715,11 +705,7 @@ meta_job_fd(Job *job MAKE_ATTR_UNUSED)
|
||||||
#if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV)
|
#if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV)
|
||||||
BuildMon *pbm;
|
BuildMon *pbm;
|
||||||
|
|
||||||
if (job != NULL) {
|
pbm = BM(job);
|
||||||
pbm = &job->bm;
|
|
||||||
} else {
|
|
||||||
pbm = &Mybm;
|
|
||||||
}
|
|
||||||
if (useFilemon && pbm->filemon != NULL) {
|
if (useFilemon && pbm->filemon != NULL) {
|
||||||
return filemon_readfd(pbm->filemon);
|
return filemon_readfd(pbm->filemon);
|
||||||
}
|
}
|
||||||
|
@ -733,11 +719,7 @@ meta_job_event(Job *job MAKE_ATTR_UNUSED)
|
||||||
#if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV)
|
#if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV)
|
||||||
BuildMon *pbm;
|
BuildMon *pbm;
|
||||||
|
|
||||||
if (job != NULL) {
|
pbm = BM(job);
|
||||||
pbm = &job->bm;
|
|
||||||
} else {
|
|
||||||
pbm = &Mybm;
|
|
||||||
}
|
|
||||||
if (useFilemon && pbm->filemon != NULL) {
|
if (useFilemon && pbm->filemon != NULL) {
|
||||||
return filemon_process(pbm->filemon);
|
return filemon_process(pbm->filemon);
|
||||||
}
|
}
|
||||||
|
@ -751,13 +733,9 @@ meta_job_error(Job *job, GNode *gn, bool ignerr, int status)
|
||||||
char cwd[MAXPATHLEN];
|
char cwd[MAXPATHLEN];
|
||||||
BuildMon *pbm;
|
BuildMon *pbm;
|
||||||
|
|
||||||
if (job != NULL) {
|
pbm = BM(job);
|
||||||
pbm = &job->bm;
|
if (job != NULL && gn == NULL)
|
||||||
if (gn == NULL)
|
|
||||||
gn = job->node;
|
gn = job->node;
|
||||||
} else {
|
|
||||||
pbm = &Mybm;
|
|
||||||
}
|
|
||||||
if (pbm->mfp != NULL) {
|
if (pbm->mfp != NULL) {
|
||||||
fprintf(pbm->mfp, "\n*** Error code %d%s\n",
|
fprintf(pbm->mfp, "\n*** Error code %d%s\n",
|
||||||
status, ignerr ? "(ignored)" : "");
|
status, ignerr ? "(ignored)" : "");
|
||||||
|
@ -779,11 +757,7 @@ meta_job_output(Job *job, char *cp, const char *nl)
|
||||||
{
|
{
|
||||||
BuildMon *pbm;
|
BuildMon *pbm;
|
||||||
|
|
||||||
if (job != NULL) {
|
pbm = BM(job);
|
||||||
pbm = &job->bm;
|
|
||||||
} else {
|
|
||||||
pbm = &Mybm;
|
|
||||||
}
|
|
||||||
if (pbm->mfp != NULL) {
|
if (pbm->mfp != NULL) {
|
||||||
if (metaVerbose) {
|
if (metaVerbose) {
|
||||||
static char *meta_prefix = NULL;
|
static char *meta_prefix = NULL;
|
||||||
|
@ -851,11 +825,7 @@ meta_job_finish(Job *job)
|
||||||
int error = 0;
|
int error = 0;
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
if (job != NULL) {
|
pbm = BM(job);
|
||||||
pbm = &job->bm;
|
|
||||||
} else {
|
|
||||||
pbm = &Mybm;
|
|
||||||
}
|
|
||||||
if (pbm->mfp != NULL) {
|
if (pbm->mfp != NULL) {
|
||||||
error = meta_cmd_finish(pbm);
|
error = meta_cmd_finish(pbm);
|
||||||
x = fclose(pbm->mfp);
|
x = fclose(pbm->mfp);
|
||||||
|
|
Loading…
Reference in New Issue