Skip to content

Commit

Permalink
convert strcmp() to util::StrEq
Browse files Browse the repository at this point in the history
  • Loading branch information
robertswiecki committed Oct 21, 2023
1 parent 98ec95c commit 84f6d75
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion caps.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
4 changes: 2 additions & 2 deletions contain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 84f6d75

Please sign in to comment.