From: Joel Rosdahl Date: Tue, 15 Apr 2014 20:31:21 +0000 (+0200) Subject: Merge branch 'maint' X-Git-Tag: v3.2~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4936026c7da9d9b5626e5fefb7d7122888cf5f5e;p=thirdparty%2Fccache.git Merge branch 'maint' * maint: manifest file_info fix Clean up dead code flagged by cppcheck and clang-analyzer Mark fatal() with __attribute__((noreturn)) to please clang-analyzer Fix bug in common_dir_prefix_length Conflicts: ccache.h test/test_util.c util.c --- 4936026c7da9d9b5626e5fefb7d7122888cf5f5e diff --cc ccache.h index 1d86a9dc7,ce4d1cf57..50e1ae429 --- a/ccache.h +++ b/ccache.h @@@ -109,34 -101,32 +111,35 @@@ bool hash_file(struct mdfour *md, cons /* ------------------------------------------------------------------------- */ /* util.c */ +void cc_vlog(const char *format, va_list ap); void cc_log(const char *format, ...) ATTR_FORMAT(printf, 1, 2); +void cc_bulklog(const char *format, ...) ATTR_FORMAT(printf, 1, 2); void cc_log_argv(const char *prefix, char **argv); - void fatal(const char *format, ...) ATTR_FORMAT(printf, 1, 2); + void fatal(const char *format, ...) ATTR_FORMAT(printf, 1, 2) ATTR_NORETURN; + void copy_fd(int fd_in, int fd_out); -int copy_file(const char *src, const char *dest, int compress_dest); -int move_file(const char *src, const char *dest, int compress_dest); +int copy_file(const char *src, const char *dest, int compress_level); +int move_file(const char *src, const char *dest, int compress_level); int move_uncompressed_file(const char *src, const char *dest, - int compress_dest); + int compress_level); bool file_is_compressed(const char *filename); - int create_dir(const char *dir); +int create_parent_dirs(const char *path); const char *get_hostname(void); const char *tmp_string(void); -char *format_hash_as_string(const unsigned char *hash, unsigned size); -int create_hash_dir(char **dir, const char *hash, const char *cache_dir); +char *format_hash_as_string(const unsigned char *hash, int size); int create_cachedirtag(const char *dir); char *format(const char *format, ...) ATTR_FORMAT(printf, 1, 2); +void reformat(char **ptr, const char *format, ...) ATTR_FORMAT(printf, 2, 3); char *x_strdup(const char *s); char *x_strndup(const char *s, size_t n); -void *x_realloc(void *ptr, size_t size); void *x_malloc(size_t size); void *x_calloc(size_t nmemb, size_t size); +void *x_realloc(void *ptr, size_t size); +void x_unsetenv(const char *name); void traverse(const char *dir, void (*fn)(const char *, struct stat *)); -char *basename(const char *s); -char *dirname(char *s); +char *basename(const char *path); +char *dirname(const char *path); const char *get_extension(const char *path); char *remove_extension(const char *path); size_t file_size(struct stat *st); diff --cc manifest.c index 1327170d8,4a456f503..b25558e8c --- a/manifest.c +++ b/manifest.c @@@ -67,10 -63,12 +67,11 @@@ */ static const uint32_t MAGIC = 0x63436d46U; -static const uint8_t VERSION = 0; static const uint32_t MAX_MANIFEST_ENTRIES = 100; + static const uint32_t MAX_MANIFEST_FILE_INFO_ENTRIES = 10000; #define ccache_static_assert(e) \ - do { enum { ccache_static_assert__ = 1/(e) }; } while (0) + do { enum { ccache_static_assert__ = 1/(e) }; } while (false) struct file_info { /* Index to n_files. */ @@@ -238,8 -208,10 +239,8 @@@ static struct manifest read_manifest(gzFile f) { struct manifest *mf; - uint16_t i, j; + uint32_t i, j; uint32_t magic; - uint8_t version; - uint16_t dummy; mf = create_empty_manifest(); @@@ -336,10 -306,10 +337,10 @@@ error static int write_manifest(gzFile f, const struct manifest *mf) { - uint16_t i, j; + uint32_t i, j; WRITE_INT(4, MAGIC); - WRITE_INT(1, VERSION); + WRITE_INT(1, MANIFEST_VERSION); WRITE_INT(1, 16); WRITE_INT(2, 0); diff --cc test/test_util.c index a0df1eaa4,258c32795..7caa07ff2 --- a/test/test_util.c +++ b/test/test_util.c @@@ -1,5 -1,5 +1,9 @@@ /* ++<<<<<<< HEAD + * Copyright (C) 2010-2013 Joel Rosdahl ++======= + * Copyright (C) 2010, 2012-2014 Joel Rosdahl ++>>>>>>> maint * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@@ -45,14 -45,16 +49,16 @@@ TEST(dirname TEST(common_dir_prefix_length) { - CHECK_UNS_EQ(0, common_dir_prefix_length("", "")); - CHECK_UNS_EQ(0, common_dir_prefix_length("/", "/")); - CHECK_UNS_EQ(0, common_dir_prefix_length("/", "/b")); - CHECK_UNS_EQ(0, common_dir_prefix_length("/a", "/b")); - CHECK_UNS_EQ(2, common_dir_prefix_length("/a", "/a")); - CHECK_UNS_EQ(2, common_dir_prefix_length("/a", "/a/b")); - CHECK_UNS_EQ(2, common_dir_prefix_length("/a/b", "/a/c")); - CHECK_UNS_EQ(4, common_dir_prefix_length("/a/b", "/a/b")); + CHECK_INT_EQ(0, common_dir_prefix_length("", "")); + CHECK_INT_EQ(0, common_dir_prefix_length("/", "/")); + CHECK_INT_EQ(0, common_dir_prefix_length("/", "/b")); + CHECK_INT_EQ(0, common_dir_prefix_length("/a", "/b")); + CHECK_INT_EQ(2, common_dir_prefix_length("/a", "/a")); + CHECK_INT_EQ(2, common_dir_prefix_length("/a", "/a/b")); + CHECK_INT_EQ(2, common_dir_prefix_length("/a/b", "/a/c")); + CHECK_INT_EQ(4, common_dir_prefix_length("/a/b", "/a/b")); + CHECK_INT_EQ(2, common_dir_prefix_length("/a/bc", "/a/b")); + CHECK_INT_EQ(2, common_dir_prefix_length("/a/b", "/a/bc")); } TEST(get_relative_path) diff --cc util.c index 54f6ec716,ed470d2c3..2662da02e --- a/util.c +++ b/util.c @@@ -233,13 -178,13 +233,13 @@@ mkstemp(char *template #endif /* - * Copy src to dest, decompressing src if needed. compress_dest decides whether - * dest will be compressed. + * Copy src to dest, decompressing src if needed. compress_level > 0 decides + * whether dest will be compressed, and with which compression level. */ int -copy_file(const char *src, const char *dest, int compress_dest) +copy_file(const char *src, const char *dest, int compress_level) { - int fd_in = -1, fd_out = -1; + int fd_in, fd_out; gzFile gz_in = NULL, gz_out = NULL; char buf[10240]; int n, written;