Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2021-08-27 11:02:17 +0300
committerJunio C Hamano <gitster@pobox.com>2021-09-07 21:07:59 +0300
commit326460a8700c4bc025578da18509c77f72928950 (patch)
treed6f75cc796a21d63f3c906bd62ac2d75e438a121 /compat/linux
parent6eccfc3adf7091ea6481e6a9a80be97703eef252 (diff)
tr2: do compiler enum check in trace2_collect_process_info()
Change code added in 2f732bf15e6 (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>
Diffstat (limited to 'compat/linux')
-rw-r--r--compat/linux/procinfo.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/compat/linux/procinfo.c b/compat/linux/procinfo.c
index bd01f017bc..0b47d44990 100644
--- a/compat/linux/procinfo.c
+++ b/compat/linux/procinfo.c
@@ -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;