ModSecurity icon indicating copy to clipboard operation
ModSecurity copied to clipboard

clang: warning: comparison of constant 160 with expression of type 'char' is always false

Open khushbuparakh opened this issue 5 years ago • 7 comments

Description

/src/actions/transformations/remove_whitespace.cc:66:44: warning: comparison of constant 160 with expression of type 'char' is always false

#define NBSP 160 // non breaking space char std::string value(val); if (isspace(value[i]) || (value[i] == NBSP)) {

khushbuparakh avatar Aug 26 '19 09:08 khushbuparakh

hi! I can work on the fix.

khushbuparakh avatar Aug 26 '19 09:08 khushbuparakh

Hi @khushbuparakh,

Thank you for the report. Indeed that will be a valid fix. Sorry for the long delay to answer. It will be a pleasure to have your contribution on that issue.

zimmerle avatar Sep 13 '19 17:09 zimmerle

@khushbuparakh ?

zimmerle avatar Sep 19 '19 13:09 zimmerle

@zimmerle what do you think about the PR #2171?

airween avatar Sep 26 '19 12:09 airween

@zimmerle what do you think about the PR #2171? The comments about #2171 are on #2171.

zimmerle avatar Sep 30 '19 17:09 zimmerle

What do you think about this solution?

-#define NBSP 160    // non breaking space char
+// define NBSP non breaking space char - depends the used type of char
+#if CHAR_MIN <= 0
+#define NBSP -96
+#elif
+#define NBSP 160
+#endif
 

and we can forgot the static_cast<char>().

My idea is that the std::string is type of std::basic_string<char>, and the char could be signed or unsigned. We can check this with the condition.

airween avatar Oct 02 '19 15:10 airween

hi! Missed the updates. thanks, @airween for fixing on time

khushbuparakh avatar Oct 28 '19 15:10 khushbuparakh