From: Arvin Schnell Date: Mon, 5 Jan 2026 08:29:47 +0000 (+0100) Subject: - coding style X-Git-Tag: v0.13.1~54^2 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=401043e9dc9bc012f8c6ca27ceb5a78de751a677;p=thirdparty%2Fsnapper.git - coding style --- diff --git a/client/snapper/cmd-create.cc b/client/snapper/cmd-create.cc index 51f9e290..26e09284 100644 --- a/client/snapper/cmd-create.cc +++ b/client/snapper/cmd-create.cc @@ -1,6 +1,6 @@ /* * Copyright (c) [2011-2015] Novell, Inc. - * Copyright (c) [2016-2020] SUSE LLC + * Copyright (c) [2016-2026] SUSE LLC * * All Rights Reserved. * @@ -23,7 +23,6 @@ #include -#include #include #include @@ -177,47 +176,58 @@ namespace snapper switch (type) { - case CreateType::SINGLE: { + case CreateType::SINGLE: + { snapshot1 = snapper->createSingleSnapshot(parent, scd, report); if (print_number) cout << snapshot1->getNum() << endl; - } break; + } + break; - case CreateType::PRE: { + case CreateType::PRE: + { snapshot1 = snapper->createPreSnapshot(scd, report); if (print_number) cout << snapshot1->getNum() << endl; - } break; + } + break; - case CreateType::POST: { + case CreateType::POST: + { snapshot2 = snapper->createPostSnapshot(snapshot1, scd, report); if (print_number) cout << snapshot2->getNum() << endl; - } break; + } + break; - case CreateType::PRE_POST: { + case CreateType::PRE_POST: + { snapshot1 = snapper->createPreSnapshot(scd, report); + int const status = system(command.c_str()); - if (status == -1) { + if (status == -1) throw runtime_error_with_errno("fork failed", errno); - } + snapshot2 = snapper->createPostSnapshot(snapshot1, scd, report); if (print_number) cout << snapshot1->getNum() << ".." << snapshot2->getNum() << endl; + if (WIFEXITED(status)) { int const exit_status = WEXITSTATUS(status); if (exit_status != 0) { SN_THROW(CommandException(exit_status)); } } else if (WIFSIGNALED(status)) { - SN_THROW(Exception(sformat("%s killed with %d", command.c_str(), WTERMSIG(status)))); - } else { + SN_THROW(Exception(sformat(_("%s killed by signal %d"), command.c_str(), WTERMSIG(status)))); + } else if (WIFSTOPPED(status)) { + // For system(3), only WIFEXITED or WIFSIGNALED should be possible. + SN_THROW(Exception(sformat(_("%s stopped"), command.c_str()))); + } else if (WIFCONTINUED(status)) { // For system(3), only WIFEXITED or WIFSIGNALED should be possible. - string error = sformat(_("%s got STOP or CONT signal and may still be running"), - command.c_str()); - SN_THROW(Exception(error)); + SN_THROW(Exception(sformat(_("%s continued"), command.c_str()))); } - } break; + } + break; } }