]> granicus.if.org Git - libexpat/commit
Rewrite XML_ErrorString to use a switch
authorHans Wennborg <hans@chromium.org>
Tue, 24 Oct 2017 14:18:34 +0000 (07:18 -0700)
committerSebastian Pipping <sebastian@pipping.org>
Wed, 25 Oct 2017 11:42:44 +0000 (13:42 +0200)
commit0ab7640bd96fcf0c99a02b89478ff8a7282b7825
treefea04939d3cec7169992ea4b44f80eba2126a6a5
parent5c224d67ec8a074c47d3c1a54c467b2c5922dd8f
Rewrite XML_ErrorString to use a switch

This makes it a little easier to correlate each enumerator with its
error message, and the compiler should generate a lookup table anyway.

It also avoids running into Clang's -Wsign-compare warning when building
on Windows (where enum's are signed ints):

  error: comparison of integers of different signs: 'enum XML_Error'
  and 'unsigned int' [-Werror,-Wsign-compare]
  if (code > 0 && code < sizeof(message)/sizeof(message[0]))
                  ~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

We ran into this when building Chromium on Windows using a recent version of
Clang.
expat/lib/xmlparse.c