David Soria Parra:

-               if (p->field < 0 || GREP_HEADER_FIELD_MAX <= p->field)
+               if (GREP_HEADER_FIELD_MAX <= p->field)

A friend taught me this trick, which will check that it isn't negative for compilers that have the enumeration be signed (notably MSVC), while not complaining for compilers that have it unsigned (GCC, Clang):

  const unsigned int sign = 1u << (sizeof(p->field) * CHAR_BIT - 1);
  if (!(sign & (unsigned int) p->field) || GREP_HEADER_FIELD_MAX <= p->field)

\\// Peter - http://www.softwolves.pp.se/
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to