Skip to content

Commit

Permalink
tr2: do compiler enum check in trace2_collect_process_info()
Browse files Browse the repository at this point in the history
Change code added in 2f732bf (tr2: log parent process name,
2021-07-21) to use a switch statement without a "default" branch to
have the compiler error if this code ever drifts out of sync with the
members of the "enum trace2_process_info_reason".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Acked-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
avar authored and gitster committed Sep 7, 2021
1 parent 6eccfc3 commit 326460a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions compat/linux/procinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,30 @@ static void get_ancestry_names(struct strvec *names)

void trace2_collect_process_info(enum trace2_process_info_reason reason)
{
struct strvec names = STRVEC_INIT;

if (!trace2_is_enabled())
return;

if (reason == TRACE2_PROCESS_INFO_EXIT)
switch (reason) {
case TRACE2_PROCESS_INFO_EXIT:
/*
* The Windows version of this calls its
* get_peak_memory_info() here. We may want to insert
* similar process-end statistics here in the future.
*/
return;

if (reason == TRACE2_PROCESS_INFO_STARTUP) {
break;
case TRACE2_PROCESS_INFO_STARTUP:
/*
* NEEDSWORK: we could do the entire ptree in an array instead,
* see compat/win32/trace2_win32_process_info.c.
*/
struct strvec names = STRVEC_INIT;

get_ancestry_names(&names);

if (names.nr)
trace2_cmd_ancestry(names.v);
strvec_clear(&names);
break;
}

return;
Expand Down

0 comments on commit 326460a

Please sign in to comment.