liblzma enum values added in 5.3.1 and 5.3.2 cause compile warnings
Summary
This is just a small janitorial task I'd like to fix in order to get clean builds (with --enable-fatal-warnings) completing on Debian unstable, which includes liblzma 5.4.1. Both of the alpha releases 5.3.1 and 5.3.2 added new enum values.
Steps to reproduce:
- ./configure --enable-fatal-warnings
- make
What is the current bug behavior?
On Debian unstable, with --enable-fatal-warnings, the build fails. (logs below)
What is the expected behavior?
Clean build.
Environment
Git main branch, Debian unstable.
Relevant logs and/or screenshots
src/lib/compress/compress_lzma.c: In function ‘lzma_error_str’:
src/lib/compress/compress_lzma.c:51:3: error: enumeration value ‘LZMA_SEEK_NEEDED’ not handled in switch [-Werror=switch-enum]
51 | switch (error) {
| ^~~~~~
src/lib/compress/compress_lzma.c:51:3: error: enumeration value ‘LZMA_RET_INTERNAL1’ not handled in switch [-Werror=switch-enum]
src/lib/compress/compress_lzma.c:51:3: error: enumeration value ‘LZMA_RET_INTERNAL2’ not handled in switch [-Werror=switch-enum]
src/lib/compress/compress_lzma.c:51:3: error: enumeration value ‘LZMA_RET_INTERNAL3’ not handled in switch [-Werror=switch-enum]
src/lib/compress/compress_lzma.c:51:3: error: enumeration value ‘LZMA_RET_INTERNAL4’ not handled in switch [-Werror=switch-enum]
src/lib/compress/compress_lzma.c:51:3: error: enumeration value ‘LZMA_RET_INTERNAL5’ not handled in switch [-Werror=switch-enum]
src/lib/compress/compress_lzma.c:51:3: error: enumeration value ‘LZMA_RET_INTERNAL6’ not handled in switch [-Werror=switch-enum]
src/lib/compress/compress_lzma.c:51:3: error: enumeration value ‘LZMA_RET_INTERNAL7’ not handled in switch [-Werror=switch-enum]
src/lib/compress/compress_lzma.c:51:3: error: enumeration value ‘LZMA_RET_INTERNAL8’ not handled in switch [-Werror=switch-enum]
src/lib/compress/compress_lzma.c: In function ‘tor_lzma_compress_process’:
src/lib/compress/compress_lzma.c:282:3: error: enumeration value ‘LZMA_SEEK_NEEDED’ not handled in switch [-Werror=switch-enum]
282 | switch (retval) {
| ^~~~~~
src/lib/compress/compress_lzma.c:282:3: error: enumeration value ‘LZMA_RET_INTERNAL1’ not handled in switch [-Werror=switch-enum]
src/lib/compress/compress_lzma.c:282:3: error: enumeration value ‘LZMA_RET_INTERNAL2’ not handled in switch [-Werror=switch-enum]
src/lib/compress/compress_lzma.c:282:3: error: enumeration value ‘LZMA_RET_INTERNAL3’ not handled in switch [-Werror=switch-enum]
src/lib/compress/compress_lzma.c:282:3: error: enumeration value ‘LZMA_RET_INTERNAL4’ not handled in switch [-Werror=switch-enum]
src/lib/compress/compress_lzma.c:282:3: error: enumeration value ‘LZMA_RET_INTERNAL5’ not handled in switch [-Werror=switch-enum]
src/lib/compress/compress_lzma.c:282:3: error: enumeration value ‘LZMA_RET_INTERNAL6’ not handled in switch [-Werror=switch-enum]
src/lib/compress/compress_lzma.c:282:3: error: enumeration value ‘LZMA_RET_INTERNAL7’ not handled in switch [-Werror=switch-enum]
src/lib/compress/compress_lzma.c:282:3: error: enumeration value ‘LZMA_RET_INTERNAL8’ not handled in switch [-Werror=switch-enum]
Possible fixes
The new enums seem quite unlikely to matter for Tor, but the existing comments (compress_lzma.c:298) do mention specifically that we are trying to keep the switch-enum warning in place so that we have an exhaustive list of the return codes that were defined at compile-time.
It may be worth reconsidering this approach and going with -Wno-error=switch-enum
here, but we can safely add the new enums under LZMA_VERSION guards at the cost of just a little more verbosity in this code. That's the approach I would implement unless others have objections to the clutter.