From: Robert Swiecki Date: Tue, 13 Feb 2018 15:53:45 +0000 (+0100) Subject: rename ARRAYSIZE to ARR_SZ due to clash with protobufs headers X-Git-Tag: 2.5~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=11195999a3f82755b91121aaf2d9d0e51927fa01;p=platform%2Fupstream%2Fnsjail.git rename ARRAYSIZE to ARR_SZ due to clash with protobufs headers --- diff --git a/Makefile b/Makefile index e91a5b8..3d45ab7 100644 --- a/Makefile +++ b/Makefile @@ -94,8 +94,8 @@ caps.o: caps.h nsjail.h logs.h macros.h util.h cgroup.o: cgroup.h nsjail.h logs.h util.h cmdline.o: cmdline.h nsjail.h logs.h caps.h config.h macros.h mnt.h user.h cmdline.o: util.h -config.o: caps.h nsjail.h logs.h cmdline.h config.h macros.h mnt.h user.h -config.o: util.h +config.o: caps.h nsjail.h logs.h cmdline.h config.h config.pb.h macros.h +config.o: mnt.h user.h util.h contain.o: contain.h nsjail.h logs.h caps.h cgroup.h cpu.h mnt.h net.h pid.h contain.o: user.h uts.h cpu.o: cpu.h nsjail.h logs.h util.h @@ -110,3 +110,4 @@ subproc.o: sandbox.h user.h util.h uts.o: uts.h nsjail.h logs.h user.o: user.h nsjail.h logs.h macros.h subproc.h util.h util.o: util.h nsjail.h logs.h macros.h +config.pb.o: config.pb.h diff --git a/caps.cc b/caps.cc index ffc15ed..2d8cbef 100644 --- a/caps.cc +++ b/caps.cc @@ -83,7 +83,7 @@ static struct { }; int nameToVal(const char* name) { - for (size_t i = 0; i < ARRAYSIZE(capNames); i++) { + for (size_t i = 0; i < ARR_SZ(capNames); i++) { if (strcmp(name, capNames[i].name) == 0) { return capNames[i].val; } @@ -94,7 +94,7 @@ int nameToVal(const char* name) { static const std::string capToStr(int val) { std::string res; - for (size_t i = 0; i < ARRAYSIZE(capNames); i++) { + for (size_t i = 0; i < ARR_SZ(capNames); i++) { if (val == capNames[i].val) { return capNames[i].name; } @@ -171,7 +171,7 @@ static bool initNsKeepCaps(cap_user_data_t cap_data) { /* Copy all permitted caps to the inheritable set */ dbgmsg[0] = '\0'; - for (size_t i = 0; i < ARRAYSIZE(capNames); i++) { + for (size_t i = 0; i < ARR_SZ(capNames); i++) { if (getPermitted(cap_data, capNames[i].val)) { util::sSnPrintf(dbgmsg, sizeof(dbgmsg), " %s", capNames[i].name); setInheritable(cap_data, capNames[i].val); @@ -185,7 +185,7 @@ static bool initNsKeepCaps(cap_user_data_t cap_data) { /* Make sure the inheritable set is preserved across execve via the ambient set */ dbgmsg[0] = '\0'; - for (size_t i = 0; i < ARRAYSIZE(capNames); i++) { + for (size_t i = 0; i < ARR_SZ(capNames); i++) { if (!getPermitted(cap_data, capNames[i].val)) { continue; } @@ -248,7 +248,7 @@ bool initNs(nsjconf_t* nsjconf) { */ if (getEffective(cap_data, CAP_SETPCAP)) { dbgmsg[0] = '\0'; - for (size_t i = 0; i < ARRAYSIZE(capNames); i++) { + for (size_t i = 0; i < ARR_SZ(capNames); i++) { if (getInheritable(cap_data, capNames[i].val)) { continue; } diff --git a/cmdline.cc b/cmdline.cc index 397726e..1ce2894 100644 --- a/cmdline.cc +++ b/cmdline.cc @@ -179,14 +179,14 @@ static void cmdlineOptUsage(struct custom_option* option) { static void cmdlineUsage(const char* pname) { LOG_HELP_BOLD("Usage: %s [options] -- path_to_command [args]", pname); LOG_HELP_BOLD("Options:"); - for (size_t i = 0; i < ARRAYSIZE(custom_opts); i++) { + for (size_t i = 0; i < ARR_SZ(custom_opts); i++) { cmdlineOptUsage(&custom_opts[i]); } LOG_HELP_BOLD("\nDeprecated options:"); - for (size_t i = 0; i < ARRAYSIZE(deprecated_opts); i++) { + for (size_t i = 0; i < ARR_SZ(deprecated_opts); i++) { cmdlineOptUsage(&deprecated_opts[i]); // Find replacement flag. - for (size_t j = 0; j < ARRAYSIZE(custom_opts); j++) { + for (size_t j = 0; j < ARR_SZ(custom_opts); j++) { if (custom_opts[j].opt.val == deprecated_opts[i].opt.val) { LOG_HELP_BOLD( "\tDEPRECATED: Use %s instead.", custom_opts[j].opt.name); @@ -373,13 +373,13 @@ std::unique_ptr parseArgs(int argc, char* argv[]) { static char cmdlineTmpfsSz[PATH_MAX] = "size=4194304"; // Generate options array for getopt_long. - size_t options_length = ARRAYSIZE(custom_opts) + ARRAYSIZE(deprecated_opts) + 1; + size_t options_length = ARR_SZ(custom_opts) + ARR_SZ(deprecated_opts) + 1; struct option opts[options_length]; - for (unsigned i = 0; i < ARRAYSIZE(custom_opts); i++) { + for (unsigned i = 0; i < ARR_SZ(custom_opts); i++) { opts[i] = custom_opts[i].opt; } - for (unsigned i = 0; i < ARRAYSIZE(deprecated_opts); i++) { - opts[ARRAYSIZE(custom_opts) + i] = deprecated_opts[i].opt; + for (unsigned i = 0; i < ARR_SZ(deprecated_opts); i++) { + opts[ARR_SZ(custom_opts) + i] = deprecated_opts[i].opt; } // Last, NULL option as a terminator. struct option terminator = {NULL, 0, NULL, 0}; diff --git a/macros.h b/macros.h index 8803eaa..d29b03b 100644 --- a/macros.h +++ b/macros.h @@ -35,9 +35,9 @@ })) #endif /* !defined(TEMP_FAILURE_RETRY) */ -#if !defined(ARRAYSIZE) -#define ARRAYSIZE(array) (sizeof(array) / sizeof(*array)) -#endif /* !defined(ARRAYSIZE) */ +#if !defined(ARR_SZ) +#define ARR_SZ(array) (sizeof(array) / sizeof(*array)) +#endif /* !defined(ARR_SZ) */ #define UNUSED __attribute__((unused)) #if 0 /* Works, but needs -fblocks and libBlocksRuntime with clang */ diff --git a/mnt.cc b/mnt.cc index d6ec47c..b26c249 100644 --- a/mnt.cc +++ b/mnt.cc @@ -87,7 +87,7 @@ static const std::string flagsToStr(uintptr_t flags) { }; uintptr_t knownFlagMask = 0U; - for (size_t i = 0; i < ARRAYSIZE(mountFlags); i++) { + for (size_t i = 0; i < ARR_SZ(mountFlags); i++) { if (flags & mountFlags[i].flag) { res.append(mountFlags[i].name); res.append("|"); @@ -259,7 +259,7 @@ static bool remountRO(const mount_t& mpt) { }; unsigned long new_flags = MS_REMOUNT | MS_RDONLY | MS_BIND; - for (size_t i = 0; i < ARRAYSIZE(mountPairs); i++) { + for (size_t i = 0; i < ARR_SZ(mountPairs); i++) { if (vfs.f_flag & mountPairs[i].vfs_flag) { new_flags |= mountPairs[i].mount_flag; } diff --git a/nsjail.cc b/nsjail.cc index a8b53ce..19632c5 100644 --- a/nsjail.cc +++ b/nsjail.cc @@ -73,7 +73,7 @@ static bool nsjailSetSigHandler(int sig) { } static bool nsjailSetSigHandlers(void) { - for (size_t i = 0; i < ARRAYSIZE(nssigs); i++) { + for (size_t i = 0; i < ARR_SZ(nssigs); i++) { if (!nsjailSetSigHandler(nssigs[i])) { return false; } diff --git a/subproc.cc b/subproc.cc index c543fb9..3b49c79 100644 --- a/subproc.cc +++ b/subproc.cc @@ -92,7 +92,7 @@ static const std::string cloneFlagsToStr(uintptr_t flags) { }; uintptr_t knownFlagMask = CSIGNAL; - for (size_t i = 0; i < ARRAYSIZE(cloneFlags); i++) { + for (size_t i = 0; i < ARR_SZ(cloneFlags); i++) { if (flags & cloneFlags[i].flag) { res.append(cloneFlags[i].name); res.append("|"); @@ -112,7 +112,7 @@ static const std::string cloneFlagsToStr(uintptr_t flags) { /* Reset the execution environment for the new process */ static bool resetEnv(void) { /* Set all previously changed signals to their default behavior */ - for (size_t i = 0; i < ARRAYSIZE(nssigs); i++) { + for (size_t i = 0; i < ARR_SZ(nssigs); i++) { if (signal(nssigs[i], SIG_DFL) == SIG_ERR) { PLOG_W("signal(%s, SIG_DFL)", util::sigName(nssigs[i]).c_str()); return false; diff --git a/util.cc b/util.cc index 22bda1f..648138a 100644 --- a/util.cc +++ b/util.cc @@ -250,7 +250,7 @@ const std::string sigName(int signo) { NS_VALSTR_STRUCT(SIGWINCH), }; - for (size_t i = 0; i < ARRAYSIZE(sigNames); i++) { + for (size_t i = 0; i < ARR_SZ(sigNames); i++) { if (signo == sigNames[i].signo) { res.append(sigNames[i].name); return res;