Fix comparisson operation of const char* with hidl_string
The arguments to the strcmp function were flipped.
Test: Would have caught this ;-)
Change-Id: I1f7379a4a6537790a269ebe2c1874135713e4ca4
diff --git a/base/include/hidl/HidlSupport.h b/base/include/hidl/HidlSupport.h
index f44160f..5cda20a 100644
--- a/base/include/hidl/HidlSupport.h
+++ b/base/include/hidl/HidlSupport.h
@@ -173,15 +173,15 @@
};
// Use NOLINT to suppress missing parentheses warnings around OP.
-#define HIDL_STRING_OPERATOR(OP) \
- inline bool operator OP(const hidl_string &hs1, const hidl_string &hs2) { \
- return strcmp(hs1.c_str(), hs2.c_str()) OP 0; /* NOLINT */ \
- } \
- inline bool operator OP(const hidl_string &hs, const char *s) { \
- return strcmp(hs.c_str(), s) OP 0; /* NOLINT */ \
- } \
- inline bool operator OP(const char *s, const hidl_string &hs) { \
- return strcmp(hs.c_str(), s) OP 0; /* NOLINT */ \
+#define HIDL_STRING_OPERATOR(OP) \
+ inline bool operator OP(const hidl_string& hs1, const hidl_string& hs2) { \
+ return strcmp(hs1.c_str(), hs2.c_str()) OP 0; /* NOLINT */ \
+ } \
+ inline bool operator OP(const hidl_string& hs, const char* s) { \
+ return strcmp(hs.c_str(), s) OP 0; /* NOLINT */ \
+ } \
+ inline bool operator OP(const char* s, const hidl_string& hs) { \
+ return strcmp(s, hs.c_str()) OP 0; /* NOLINT */ \
}
HIDL_STRING_OPERATOR(==)