From bc4e7fdd5256e5d0d5e1245ab02d30728d35ed13 Mon Sep 17 00:00:00 2001 From: Robert Swiecki Date: Fri, 15 Sep 2023 15:38:37 +0200 Subject: [PATCH] cmdline: constify structs --- cmdline.cc | 8 ++++---- util.cc | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cmdline.cc b/cmdline.cc index 8a96825..b1b79a2 100644 --- a/cmdline.cc +++ b/cmdline.cc @@ -61,12 +61,12 @@ namespace cmdline { #define _LOG_DEFAULT_FILE "/var/log/nsjail.log" struct custom_option { - struct option opt; - const char *descr; + const struct option opt; + const char *const descr; }; // clang-format off -struct custom_option custom_opts[] = { +static const struct custom_option custom_opts[] = { { { "help", no_argument, NULL, 'h' }, "Help plz.." }, { { "mode", required_argument, NULL, 'M' }, "Execution mode (default: 'o' [MODE_STANDALONE_ONCE]):\n" @@ -221,7 +221,7 @@ std::string FormatDescription(const char *descr) { return formatted; } -static void cmdlineOptUsage(struct custom_option *option) { +static void cmdlineOptUsage(const struct custom_option *option) { if (option->opt.val < 0x80) { LOG_HELP_BOLD(" --%s%s%c %s", option->opt.name, "|-", option->opt.val, option->opt.has_arg == required_argument ? "VALUE" : ""); diff --git a/util.cc b/util.cc index 7893779..1829b30 100644 --- a/util.cc +++ b/util.cc @@ -224,7 +224,8 @@ static const uint64_t c = 1442695040888963407ULL; static void rndInitThread(void) { #if defined(__NR_getrandom) - if (util::syscall(__NR_getrandom, (uintptr_t)&rndX, sizeof(rndX), 0) == sizeof(rndX)) { + if (TEMP_FAILURE_RETRY(util::syscall(__NR_getrandom, (uintptr_t)&rndX, sizeof(rndX), 0)) == + sizeof(rndX)) { return; } #endif /* defined(__NR_getrandom) */