diff options
author | Robert Swiecki <robert@swiecki.net> | 2023-10-21 18:37:57 +0200 |
---|---|---|
committer | Robert Swiecki <robert@swiecki.net> | 2023-10-21 18:37:57 +0200 |
commit | 84f6d75d260ef7118287b2bdc16620ca4ca7a1d6 (patch) | |
tree | 43a90759a52968d3af0f8ca6e61963672471692e | |
parent | 98ec95ca85b18bdae6238019b52ed06ca9bb2542 (diff) | |
download | nsjail-84f6d75d260ef7118287b2bdc16620ca4ca7a1d6.tar.gz |
convert strcmp() to util::StrEq
-rw-r--r-- | caps.cc | 2 | ||||
-rw-r--r-- | contain.cc | 4 | ||||
-rw-r--r-- | util.cc | 4 | ||||
-rw-r--r-- | util.h | 1 |
4 files changed, 8 insertions, 3 deletions
@@ -99,7 +99,7 @@ struct { int nameToVal(const char* name) { for (const auto& cap : capNames) { - if (strcmp(name, cap.name) == 0) { + if (util::StrEq(name, cap.name)) { return cap.val; } } @@ -253,10 +253,10 @@ static bool containMakeFdsCOEProc(nsjconf_t* nsjconf) { if (entry == nullptr) { break; } - if (strcmp(".", entry->d_name) == 0) { + if (util::StrEq(".", entry->d_name)) { continue; } - if (strcmp("..", entry->d_name) == 0) { + if (util::StrEq("..", entry->d_name)) { continue; } errno = 0; @@ -215,6 +215,10 @@ bool isANumber(const char* s) { return true; } +bool StrEq(const std::string_view& s1, const std::string_view& s2) { + return (s1 == s2); +} + static __thread pthread_once_t rndThreadOnce = PTHREAD_ONCE_INIT; static __thread uint64_t rndX; @@ -62,6 +62,7 @@ std::string* StrAppend(std::string* str, const char* format, ...) __attribute__((format(printf, 2, 3))); std::string StrPrintf(const char* format, ...) __attribute__((format(printf, 1, 2))); const std::string StrQuote(const std::string& str); +bool StrEq(const std::string_view& s1, const std::string_view& s2); bool isANumber(const char* s); uint64_t rnd64(void); const std::string sigName(int signo); |