Factor out repeated conditions and merge the resulting if statement with the following one. This makes the intent clearer and silences a flurry of warnings from clang.
Unified · Split
| @@ -302,23 +302,27 @@ char const * sox_find_comment(sox_comments_t comments, char const * id) · 301 unmodified lines | |||
| 302 | 302 | ||
| 303 | static void set_endiannesses(sox_format_t * ft) | 303 | static void set_endiannesses(sox_format_t * ft) |
| 304 | { | 304 | { |
| 305 | if (ft->encoding.opposite_endian) | 305 | if (ft->handler.flags & SOX_FILE_ENDIAN) { |
| 306 | ft->encoding.reverse_bytes = (ft->handler.flags & SOX_FILE_ENDIAN)? | 306 | sox_bool file_is_bigendian = !(ft->handler.flags & SOX_FILE_ENDBIG); |
| 307 | !(ft->handler.flags & SOX_FILE_ENDBIG) != MACHINE_IS_BIGENDIAN : sox_true; | 307 | |
| 308 | else if (ft->encoding.reverse_bytes == sox_option_default) | 308 | if (ft->encoding.opposite_endian) { |
| 309 | ft->encoding.reverse_bytes = (ft->handler.flags & SOX_FILE_ENDIAN)? | 309 | ft->encoding.reverse_bytes = file_is_bigendian != MACHINE_IS_BIGENDIAN; |
| 310 | !(ft->handler.flags & SOX_FILE_ENDBIG) == MACHINE_IS_BIGENDIAN : sox_false; | 310 | lsx_report("`%s': overriding file-type byte-order", ft->filename); |
| 311 | } else if (ft->encoding.reverse_bytes == sox_option_default) { | ||
| 312 | ft->encoding.reverse_bytes = file_is_bigendian == MACHINE_IS_BIGENDIAN; | ||
| 313 | } | ||
| 314 | } else { | ||
| 315 | if (ft->encoding.opposite_endian) { | ||
| 316 | ft->encoding.reverse_bytes = sox_option_yes; | ||
| 317 | lsx_report("`%s': overriding machine byte-order", ft->filename); | ||
| 318 | } else if (ft->encoding.reverse_bytes == sox_option_default) { | ||
| 319 | ft->encoding.reverse_bytes = sox_option_no; | ||
| 320 | } | ||
| 321 | } | ||
| 311 | 322 | ||
| 312 | /* FIXME: Change reports to suitable warnings if trying | 323 | /* FIXME: Change reports to suitable warnings if trying |
| 313 | * to override something that can't be overridden. */ | 324 | * to override something that can't be overridden. */ |
| 314 | 325 | ||
| 315 | if (ft->handler.flags & SOX_FILE_ENDIAN) { | ||
| 316 | if (ft->encoding.reverse_bytes == (sox_option_t) | ||
| 317 | (!(ft->handler.flags & SOX_FILE_ENDBIG) != MACHINE_IS_BIGENDIAN)) | ||
| 318 | lsx_report("`%s': overriding file-type byte-order", ft->filename); | ||
| 319 | } else if (ft->encoding.reverse_bytes == sox_option_yes) | ||
| 320 | lsx_report("`%s': overriding machine byte-order", ft->filename); | ||
| 321 | |||
| 322 | if (ft->encoding.reverse_bits == sox_option_default) | 326 | if (ft->encoding.reverse_bits == sox_option_default) |
| 323 | ft->encoding.reverse_bits = !!(ft->handler.flags & SOX_FILE_BIT_REV); | 327 | ft->encoding.reverse_bits = !!(ft->handler.flags & SOX_FILE_BIT_REV); |
| 324 | else if (ft->encoding.reverse_bits == !(ft->handler.flags & SOX_FILE_BIT_REV)) | 328 | else if (ft->encoding.reverse_bits == !(ft->handler.flags & SOX_FILE_BIT_REV)) |