]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Merge branch 'maint'
authorJoel Rosdahl <joel@rosdahl.net>
Tue, 15 Apr 2014 20:31:21 +0000 (22:31 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 15 Apr 2014 20:31:21 +0000 (22:31 +0200)
* 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

1  2 
ccache.h
manifest.c
test/test_util.c
util.c

diff --cc ccache.h
index 1d86a9dc746ae60c33840fa6505d3ebaffc6b080,ce4d1cf5779c749a2235c7be7677c0e90bdbba3a..50e1ae42966cf87ee9cc9a466b2505eda3f5c495
+++ 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 1327170d800e470d3ab8e278500018cd5f438bca,4a456f50317f3be6b203796b4bea9a6bad7ab027..b25558e8cba3bc86b6449c429acef8cfa90fa929
   */
  
  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);
  
index a0df1eaa4a688c078472cfbdb307bf52aea8a561,258c3279565281b9cc90390354aa46731e6a3aa1..7caa07ff297b9c108dc71fff9467875b99432fab
@@@ -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 54f6ec7163c82cf110bf467638db0f7478c8b912,ed470d2c3d376b1a46bf0eaafcf52f1f88039974..2662da02ebabe64a3f8187ae6725591206115ab4
--- 1/util.c
--- 2/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;