From: Joel Rosdahl Date: Sat, 22 Jun 2019 20:44:01 +0000 (+0200) Subject: Tweak code style X-Git-Tag: v4.0~932 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6d6cf779d7e6531c46b39956eb4a799aeaba892;p=thirdparty%2Fccache.git Tweak code style --- diff --git a/Makefile.in b/Makefile.in index 9bd954f8f..93cb71fae 100644 --- a/Makefile.in +++ b/Makefile.in @@ -37,8 +37,8 @@ non_3pp_sources = \ src/compopt.c \ src/compr_none.c \ src/compr_zlib.c \ - src/compression.c \ src/compr_zstd.c \ + src/compression.c \ src/conf.c \ src/confitems.c \ src/counters.c \ diff --git a/src/common_header.h b/src/common_header.h index 09f1aa6e8..69fd027ca 100644 --- a/src/common_header.h +++ b/src/common_header.h @@ -1,7 +1,6 @@ #define COMMON_HEADER_SIZE 15 -struct common_header -{ +struct common_header { char magic[4]; uint8_t version; uint8_t compression_type; diff --git a/src/compr_zlib.c b/src/compr_zlib.c index a174ecf2a..899c4c7e6 100644 --- a/src/compr_zlib.c +++ b/src/compr_zlib.c @@ -19,8 +19,7 @@ #include -struct state -{ +struct state { FILE *output; z_stream stream; bool failed; diff --git a/src/compr_zstd.c b/src/compr_zstd.c index 49840101f..998dfbb48 100644 --- a/src/compr_zstd.c +++ b/src/compr_zstd.c @@ -22,8 +22,8 @@ #endif #ifdef HAVE_LIBZSTD -struct state -{ + +struct state { FILE *output; ZSTD_CStream *stream; ZSTD_inBuffer in; @@ -78,7 +78,7 @@ compr_zstd_write(struct compr_state *handle, const void *data, size_t size) } } ret = flush; - while (ret) { + while (ret > 0) { unsigned char buffer[READ_BUFFER_SIZE]; state->out.dst = buffer; state->out.size = sizeof(buffer); @@ -115,4 +115,5 @@ struct compressor compressor_zstd_impl = { compr_zstd_write, compr_zstd_free }; -#endif //HAVE_LIBZSTD + +#endif // HAVE_LIBZSTD diff --git a/src/compression.h b/src/compression.h index b087ea81c..19baafdeb 100644 --- a/src/compression.h +++ b/src/compression.h @@ -34,7 +34,7 @@ extern struct decompressor decompressor_zlib_impl; #ifdef HAVE_LIBZSTD extern struct compressor compressor_zstd_impl; extern struct decompressor decompressor_zstd_impl; -#endif //HAVE_LIBZSTD +#endif // HAVE_LIBZSTD int8_t compression_level_from_config(void); enum compression_type compression_type_from_config(void); diff --git a/src/confitems.c b/src/confitems.c index 1c2446410..d9d14bdd5 100644 --- a/src/confitems.c +++ b/src/confitems.c @@ -20,7 +20,7 @@ static char * format_string(const void *value) { - const char * const *str = (const char * const*)value; + const char *const *str = (const char *const *)value; return x_strdup(*str); } @@ -268,7 +268,7 @@ confitem_format_unsigned(const void *value) bool confitem_verify_absolute_path(const void *value, char **errmsg) { - const char * const *path = (const char * const *)value; + const char *const *path = (const char *const *)value; assert(*path); if (str_eq(*path, "")) { // The empty string means "disable" in this case. diff --git a/src/decompr_zlib.c b/src/decompr_zlib.c index e5ddada28..3f3ec2c01 100644 --- a/src/decompr_zlib.c +++ b/src/decompr_zlib.c @@ -25,8 +25,7 @@ enum stream_state { STREAM_STATE_END }; -struct state -{ +struct state { FILE *input; char input_buffer[READ_BUFFER_SIZE]; size_t input_size; diff --git a/src/decompr_zstd.c b/src/decompr_zstd.c index 8fc3ace4f..96ec79a57 100644 --- a/src/decompr_zstd.c +++ b/src/decompr_zstd.c @@ -22,14 +22,14 @@ #endif #ifdef HAVE_LIBZSTD + enum stream_state { STREAM_STATE_READING, STREAM_STATE_FAILED, STREAM_STATE_END }; -struct state -{ +struct state { FILE *input; char input_buffer[READ_BUFFER_SIZE]; size_t input_size; @@ -120,4 +120,5 @@ struct decompressor decompressor_zstd_impl = { decompr_zstd_read, decompr_zstd_free }; -#endif //HAVE_LIBZSTD + +#endif // HAVE_LIBZSTD diff --git a/src/result.c b/src/result.c index 43e46d10d..62cf4dbf2 100644 --- a/src/result.c +++ b/src/result.c @@ -101,7 +101,8 @@ result_files_init(void) } void -result_files_add(struct result_files *list, const char *path, const char *suffix) +result_files_add(struct result_files *list, const char *path, + const char *suffix) { uint32_t n = list->n_files; list->files = x_realloc(list->files, (n + 1) * sizeof(*list->files)); @@ -232,8 +233,8 @@ read_result( break; case REF_MARKER: - // TODO: Implement. - // Fall through. + // TODO: Implement. + // Fall through. default: *errmsg = format("Unknown entry type: %u", marker); diff --git a/unittest/test_compr_zstd.c b/unittest/test_compr_zstd.c index 16e4ff927..bd3c5e803 100644 --- a/unittest/test_compr_zstd.c +++ b/unittest/test_compr_zstd.c @@ -21,6 +21,7 @@ TEST_SUITE(compr_zstd) #ifdef HAVE_LIBZSTD + TEST(zstd_small_roundtrip) { FILE *f = fopen("data.zstd", "w"); @@ -116,11 +117,14 @@ TEST(zstd_large_uncompressible_roundtrip) CHECK(decompr_zstd->free(d_state)); fclose(f); } -#else + +#else // HAVE_LIBZSTD + TEST(zstd_skip) { // disabled } + #endif // HAVE_LIBZSTD TEST_SUITE_END diff --git a/unittest/test_conf.c b/unittest/test_conf.c index 278507342..930125ba4 100644 --- a/unittest/test_conf.c +++ b/unittest/test_conf.c @@ -370,7 +370,8 @@ TEST(conf_set_new_value) char *data; create_file("ccache.conf", "path = vanilla\n"); - CHECKM(conf_set_value_in_file("ccache.conf", "compiler", "chocolate", &errmsg), + CHECKM(conf_set_value_in_file("ccache.conf", "compiler", "chocolate", + &errmsg), errmsg); data = read_text_file("ccache.conf", 0); CHECK(data);