]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Merge remote-tracking branch 'afbjorklund/everything'
authorJoel Rosdahl <joel@rosdahl.net>
Tue, 2 Oct 2018 19:33:27 +0000 (21:33 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 2 Oct 2018 19:33:27 +0000 (21:33 +0200)
* afbjorklund/everything:
  Make configure work with older clang versions
  Add option for enabling more compiler warnings
  Add configure support for detecting clang
  Avoid bad function cast by using temporary
  Proper use of const qualifier char* strings
  Removed locally shadowed global variables
  Don't use undefined macros, use ifdef instead
  Add noreturn to functions that don't return
  Add missing extern prototypes, or make static
  Don't use reserved id macros in the headers
  Only compile getopt_long.c when needed
  Address issues found by lgtm.com alerts

1  2 
configure.ac
src/ccache.c
src/ccache.h
src/compopt.c
src/conf.c
src/hash.c
src/stats.c
src/unify.c
src/util.c
unittest/main.c
unittest/test_conf.c

diff --cc configure.ac
Simple merge
diff --cc src/ccache.c
index a5d04cf2d7110e2735e036403a88db3673a2c58e,5d893d93ec9704f7b65bce8e67fe07ce4aa17155..6634554b4e556b690e3f7b08a2da2d98436752e7
  #define STRINGIFY(x) #x
  #define TO_STRING(x) STRINGIFY(x)
  
+ extern struct conf *conf;
+ extern char *primary_config_path;
+ extern char *secondary_config_path;
+ extern char *current_working_dir;
+ extern char *stats_file;
+ extern unsigned lock_staleness_limit;
+ static void failed(void) ATTR_NORETURN;
+ static void ccache(int argc, char *argv[]) ATTR_NORETURN;
+ int ccache_main(int argc, char *argv[]);
  static const char VERSION_TEXT[] =
 -  MYNAME " version %s\n"
 -  "\n"
 -  "Copyright (C) 2002-2007 Andrew Tridgell\n"
 -  "Copyright (C) 2009-2018 Joel Rosdahl\n"
 -  "\n"
 -  "This program is free software; you can redistribute it and/or modify it under\n"
 -  "the terms of the GNU General Public License as published by the Free Software\n"
 -  "Foundation; either version 3 of the License, or (at your option) any later\n"
 -  "version.\n";
 +      MYNAME " version %s\n"
 +      "\n"
 +      "Copyright (C) 2002-2007 Andrew Tridgell\n"
 +      "Copyright (C) 2009-2018 Joel Rosdahl\n"
 +      "\n"
 +      "This program is free software; you can redistribute it and/or modify it under\n"
 +      "the terms of the GNU General Public License as published by the Free Software\n"
 +      "Foundation; either version 3 of the License, or (at your option) any later\n"
 +      "version.\n";
  
  static const char USAGE_TEXT[] =
 -  "Usage:\n"
 -  "    " MYNAME " [options]\n"
 -  "    " MYNAME " compiler [compiler options]\n"
 -  "    compiler [compiler options]          (via symbolic link)\n"
 -  "\n"
 -  "Options:\n"
 -  "    -c, --cleanup         delete old files and recalculate size counters\n"
 -  "                          (normally not needed as this is done automatically)\n"
 -  "    -C, --clear           clear the cache completely (except configuration)\n"
 -  "    -F, --max-files=N     set maximum number of files in cache to N (use 0 for\n"
 -  "                          no limit)\n"
 -  "    -M, --max-size=SIZE   set maximum size of cache to SIZE (use 0 for no\n"
 -  "                          limit); available suffixes: k, M, G, T (decimal) and\n"
 -  "                          Ki, Mi, Gi, Ti (binary); default suffix: G\n"
 -  "    -o, --set-config=K=V  set configuration key K to value V\n"
 -  "    -p, --print-config    print current configuration options\n"
 -  "    -s, --show-stats      show statistics summary\n"
 -  "    -z, --zero-stats      zero statistics counters\n"
 -  "\n"
 -  "    -h, --help            print this help text\n"
 -  "    -V, --version         print version and copyright information\n"
 -  "\n"
 -  "See also <https://ccache.samba.org>.\n";
 +      "Usage:\n"
 +      "    " MYNAME " [options]\n"
 +      "    " MYNAME " compiler [compiler options]\n"
 +      "    compiler [compiler options]          (via symbolic link)\n"
 +      "\n"
 +      "Options:\n"
 +      "    -c, --cleanup         delete old files and recalculate size counters\n"
 +      "                          (normally not needed as this is done automatically)\n"
 +      "    -C, --clear           clear the cache completely (except configuration)\n"
 +      "    -F, --max-files=N     set maximum number of files in cache to N (use 0 for\n"
 +      "                          no limit)\n"
 +      "    -M, --max-size=SIZE   set maximum size of cache to SIZE (use 0 for no\n"
 +      "                          limit); available suffixes: k, M, G, T (decimal) and\n"
 +      "                          Ki, Mi, Gi, Ti (binary); default suffix: G\n"
 +      "    -o, --set-config=K=V  set configuration key K to value V\n"
 +      "    -p, --print-config    print current configuration options\n"
 +      "    -s, --show-stats      show statistics summary\n"
 +      "    -z, --zero-stats      zero statistics counters\n"
 +      "\n"
 +      "    -h, --help            print this help text\n"
 +      "    -V, --version         print version and copyright information\n"
 +      "\n"
 +      "See also <https://ccache.samba.org>.\n";
  
  // Global configuration data.
  struct conf *conf = NULL;
diff --cc src/ccache.h
Simple merge
diff --cc src/compopt.c
Simple merge
diff --cc src/conf.c
Simple merge
diff --cc src/hash.c
index f58d8f6b7e37cbcc6804da2391d3a54d3de7fd30,fec5f706577322eec58bb79a40085aecc3744f73..0205143f7281c4e69e22684f8e7916ada93e30b1
  #include "ccache.h"
  
  #define HASH_DELIMITER "\000cCaChE"
-       mdfour_update(md, (unsigned char *)s, len);
 +#define HASH_DEBUG_DELIMITER "### "
 +
 +// binary input, for hashing
 +static char *debug_hash_bin;
 +
 +// text input, for debugging
 +static char *debug_hash_txt;
 +
 +// char mapping to open files
 +static FILE **debug_hash_file;
 +
 +void hash_debug_init(const char *bin, const char *txt)
 +{
 +      debug_hash_file = x_calloc(256, sizeof(FILE *));
 +      static char *hash_types = "cdp"; // common, direct, cpp
 +      if (bin) {
 +              debug_hash_bin = x_strdup(bin);
 +              assert(debug_hash_bin[strlen(debug_hash_bin)-1] == 'X');
 +              for (char *p = hash_types; *p != '\0'; p++) {
 +                      debug_hash_bin[strlen(debug_hash_bin)-1] = *p;
 +                      debug_hash_file[(int) *p] = fopen(debug_hash_bin, "wb");
 +              }
 +              debug_hash_bin[strlen(debug_hash_bin)-1] = 'X';
 +      }
 +      if (txt) {
 +              debug_hash_txt = x_strdup(txt);
 +              debug_hash_file[(int) 't'] = fopen(debug_hash_txt, "w");
 +      }
 +}
 +
 +void hash_debug_end()
 +{
 +      for (int i = 0; i < 256; i++) {
 +              if (debug_hash_file[i] != NULL) {
 +                      fclose(debug_hash_file[i]);
 +              }
 +      }
 +}
 +
 +static void
 +hash_binary_buffer(struct mdfour *md, const void *s, size_t len)
 +{
++      mdfour_update(md, (const unsigned char *)s, len);
 +      if (!md->identifier || len == 0) {
 +              return;
 +      }
 +      if (debug_hash_bin) {
 +              // log to different files, for the different hash types
 +              fwrite(s, 1, len, debug_hash_file[md->identifier]);
 +      }
 +}
 +
 +static void
 +hash_debug_buffer(struct mdfour *md, const void *s, size_t len)
 +{
 +      if (!md->identifier || len == 0) {
 +              return;
 +      }
 +      if (debug_hash_txt) {
 +              fwrite(s, 1, len, debug_hash_file['t']);
 +      }
 +}
  
  void
  hash_start(struct mdfour *md)
diff --cc src/stats.c
Simple merge
diff --cc src/unify.c
Simple merge
diff --cc src/util.c
index cac8415cf0ac600c8dcff1add19202d144228888,52d16251305650b2e2d0d895327c8ea9b2db41cd..6b87b94374e93af253f59b2affed8a77a09e73d5
@@@ -632,11 -580,11 +634,11 @@@ format_hash_as_string(const unsigned ch
        return ret;
  }
  
- char const CACHEDIR_TAG[] =
static char const CACHEDIR_TAG[] =
 -  "Signature: 8a477f597d28d172789f06886806bc55\n"
 -  "# This file is a cache directory tag created by ccache.\n"
 -  "# For information about cache directory tags, see:\n"
 -  "#\thttp://www.brynosaurus.com/cachedir/\n";
 +      "Signature: 8a477f597d28d172789f06886806bc55\n"
 +      "# This file is a cache directory tag created by ccache.\n"
 +      "# For information about cache directory tags, see:\n"
 +      "#\thttp://www.brynosaurus.com/cachedir/\n";
  
  int
  create_cachedirtag(const char *dir)
diff --cc unittest/main.c
index d3edd49e7dd4e96f442c18c15774fb900612eb08,e2da341dd831f07a31f48cfbac773157332f8a83..e3299b00e77d373892e8bc0e26be9b39810dde70
  #undef SUITE
  // *INDENT-ON* enable uncrustify
  
- const char USAGE_TEXT[] =
static const char USAGE_TEXT[] =
 -  "Usage:\n"
 -  "    test [options]\n"
 -  "\n"
 -  "Options:\n"
 -  "    -h, --help      print this help text\n"
 -  "    -v, --verbose   enable verbose logging of tests\n";
 +      "Usage:\n"
 +      "    test [options]\n"
 +      "\n"
 +      "Options:\n"
 +      "    -h, --help      print this help text\n"
 +      "    -v, --verbose   enable verbose logging of tests\n";
  
  int
  main(int argc, char **argv)
index 80233153613336f183089cd155f212a7fe050137,bb3f95ce502b86f9a9c5361c77abf011937063aa..2028ddc8c14ffce91a1f6cf31b8d855842dd4e2b
  #include "framework.h"
  #include "util.h"
  
 -#define N_CONFIG_ITEMS 32
 +#define N_CONFIG_ITEMS 33
  static struct {
        char *descr;
-       const char *origin;
+       char *origin;
  } received_conf_items[N_CONFIG_ITEMS];
  static size_t n_received_conf_items = 0;