cmdline: constify structs

This commit is contained in:
Robert Swiecki 2023-09-15 15:38:37 +02:00
parent 6c5c13017d
commit bc4e7fdd52
2 changed files with 6 additions and 5 deletions

View File

@ -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" : "");

View File

@ -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) */