From 52eafb9eb5d36ff2178bcc7891cb74f63aa6b72e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jurko=20Gospodneti=C4=87?= Date: Tue, 26 Jun 2012 10:30:14 +0000 Subject: [PATCH] Boost Jam code cleanup - minor stylistic changes. [SVN r79101] --- src/engine/command.c | 2 +- src/engine/command.h | 11 ++++++----- src/engine/make1.c | 31 ++++++++++++++++--------------- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/engine/command.c b/src/engine/command.c index 8fb8f3ff0..2c5a9d4c2 100644 --- a/src/engine/command.c +++ b/src/engine/command.c @@ -29,7 +29,7 @@ CMD * cmd_new( RULE * rule, LIST * targets, LIST * sources, LIST * shell ) { CMD * cmd = (CMD *)BJAM_MALLOC( sizeof( CMD ) ); - FRAME frame[1]; + FRAME frame[ 1 ]; assert( cmd ); cmd->rule = rule; diff --git a/src/engine/command.h b/src/engine/command.h index 73fa714e6..03011abba 100644 --- a/src/engine/command.h +++ b/src/engine/command.h @@ -29,6 +29,7 @@ * cmd_new() - return a new CMD or 0 if too many args. * cmd_free() - delete CMD and its parts. * cmd_next() - walk the CMD chain. + * cmd_release_targets_and_shell() - CMD forgets about its targets & shell. */ @@ -48,11 +49,11 @@ typedef struct _cmd CMD; struct _cmd { CMD * next; - CMD * tail; /* valid on in head */ - RULE * rule; /* rule->actions contains shell script */ - LIST * shell; /* $(JAMSHELL) value */ - LOL args; /* LISTs for $(<), $(>) */ - string buf[1]; /* actual commands */ + CMD * tail; /* valid on in head */ + RULE * rule; /* rule->actions contains shell script */ + LIST * shell; /* $(JAMSHELL) value */ + LOL args; /* LISTs for $(<), $(>) */ + string buf[ 1 ]; /* actual commands */ }; CMD * cmd_new diff --git a/src/engine/make1.c b/src/engine/make1.c index be2d41301..e810ffd5e 100644 --- a/src/engine/make1.c +++ b/src/engine/make1.c @@ -91,7 +91,7 @@ typedef struct _state TARGET * t; /* current target */ TARGET * parent; /* parent argument necessary for make1a() */ int curstate; /* current state */ - int status; + int status; /* EXEC_CMD_* - input for make1d() */ } state; static void make1a ( state * ); @@ -547,17 +547,21 @@ static void make1c( state * pState ) } else { + /* Pop state first in case exec_cmd(), exec_wait() or make_closure() + * push a new state. Collect the target off the stack before that to + * avoid accessing data later from a freed stack node. + */ + TARGET * t = pState->t ; + pop_state( &state_stack ); + /* Increment the jobs running counter. */ ++cmdsrunning; /* Execute the actual build command. */ - exec_cmd( cmd->buf, make_closure, pState->t, cmd->shell, rule_name, + exec_cmd( cmd->buf, make_closure, t, cmd->shell, rule_name, target_name ); - /* Pop state first because exec_wait() will push state. */ - pop_state( &state_stack ); - - /* Wait until we are under the concurrent command count limit. */ + /* Wait until under the concurrent command count limit. */ assert( 0 < globs.jobs ); assert( globs.jobs <= MAXJOBS ); while ( cmdsrunning >= globs.jobs ) @@ -591,10 +595,7 @@ static void make1c( state * pState ) TARGET * t = pState->t; TARGET * additional_includes = NULL; - if ( globs.noexec ) - t->progress = T_MAKE_NOEXEC_DONE; - else - t->progress = T_MAKE_DONE; + t->progress = globs.noexec ? T_MAKE_NOEXEC_DONE : T_MAKE_DONE; /* Target has been updated so rescan it for dependencies. */ if ( ( t->fate >= T_FATE_MISSING ) && @@ -969,12 +970,12 @@ static void swap_settings static CMD * make1cmds( TARGET * t ) { - CMD * cmds = 0; - LIST * shell = L0; + CMD * cmds = 0; + LIST * shell = L0; module_t * settings_module = 0; - TARGET * settings_target = 0; - ACTIONS * a0; - int running_flag = globs.noexec ? A_RUNNING_NOEXEC : A_RUNNING; + TARGET * settings_target = 0; + ACTIONS * a0; + int const running_flag = globs.noexec ? A_RUNNING_NOEXEC : A_RUNNING; /* Step through actions. Actions may be shared with other targets or grouped * using RULE_TOGETHER, so actions already seen are skipped.