Merge branch 'rj/no-sign-compare' into maint
authorJunio C Hamano <gitster@pobox.com>
Mon, 23 Oct 2017 05:20:18 +0000 (14:20 +0900)
committerJunio C Hamano <gitster@pobox.com>
Mon, 23 Oct 2017 05:20:18 +0000 (14:20 +0900)
Many codepaths have been updated to squelch -Wsign-compare
warnings.

* rj/no-sign-compare:
ALLOC_GROW: avoid -Wsign-compare warnings
cache.h: hex2chr() - avoid -Wsign-compare warnings
commit-slab.h: avoid -Wsign-compare warnings
git-compat-util.h: xsize_t() - avoid -Wsign-compare warnings

1  2 
builtin/pack-objects.c
config.c
diff.c
diff --combined builtin/pack-objects.c
index bd391e97a4b9513bd44e327a38c2712daeeef401,b40cdfe64ade3a280aecdf86d270716fa5a97c97..3af63ad54cdd4230e9d9eebe3ffd528b5f00551f
@@@ -2170,10 -2170,7 +2170,10 @@@ static void *threaded_find_deltas(void 
  {
        struct thread_params *me = arg;
  
 +      progress_lock();
        while (me->remaining) {
 +              progress_unlock();
 +
                find_deltas(me->list, &me->remaining,
                            me->window, me->depth, me->processed);
  
                        pthread_cond_wait(&me->cond, &me->mutex);
                me->data_ready = 0;
                pthread_mutex_unlock(&me->mutex);
 +
 +              progress_lock();
        }
 +      progress_unlock();
        /* leave ->working 1 so that this doesn't get more work assigned */
        return NULL;
  }
@@@ -2562,8 -2556,8 +2562,8 @@@ struct in_pack_object 
  };
  
  struct in_pack {
-       int alloc;
-       int nr;
+       unsigned int alloc;
+       unsigned int nr;
        struct in_pack_object *array;
  };
  
diff --combined config.c
index c6bc2ff715147d16734e3b997c18fdd49642fd00,149bee1c714dc991242d26fb1981b1500ad60246..1a8e24f32ceda05861fda9704e195a81b28ce8ce
+++ b/config.c
@@@ -16,6 -16,7 +16,6 @@@
  #include "string-list.h"
  #include "utf8.h"
  #include "dir.h"
 -#include "color.h"
  
  struct config_source {
        struct config_source *prev;
@@@ -1350,6 -1351,9 +1350,6 @@@ int git_default_config(const char *var
        if (starts_with(var, "advice."))
                return git_default_advice_config(var, value);
  
 -      if (git_color_config(var, value, dummy) < 0)
 -              return -1;
 -
        if (!strcmp(var, "pager.color") || !strcmp(var, "color.pager")) {
                pager_use_color = git_config_bool(var,value);
                return 0;
@@@ -2155,7 -2159,7 +2155,7 @@@ static struct 
        size_t *offset;
        unsigned int offset_alloc;
        enum { START, SECTION_SEEN, SECTION_END_SEEN, KEY_SEEN } state;
-       int seen;
+       unsigned int seen;
  } store;
  
  static int matches(const char *key, const char *value)
@@@ -2400,7 -2404,7 +2400,7 @@@ int git_config_set_multivar_in_file_gen
  {
        int fd = -1, in_fd = -1;
        int ret;
 -      struct lock_file *lock = NULL;
 +      static struct lock_file lock;
        char *filename_buf = NULL;
        char *contents = NULL;
        size_t contents_sz;
         * The lock serves a purpose in addition to locking: the new
         * contents of .git/config will be written into it.
         */
 -      lock = xcalloc(1, sizeof(struct lock_file));
 -      fd = hold_lock_file_for_update(lock, config_filename, 0);
 +      fd = hold_lock_file_for_update(&lock, config_filename, 0);
        if (fd < 0) {
                error_errno("could not lock config file %s", config_filename);
                free(store.key);
                close(in_fd);
                in_fd = -1;
  
 -              if (chmod(get_lock_file_path(lock), st.st_mode & 07777) < 0) {
 -                      error_errno("chmod on %s failed", get_lock_file_path(lock));
 +              if (chmod(get_lock_file_path(&lock), st.st_mode & 07777) < 0) {
 +                      error_errno("chmod on %s failed", get_lock_file_path(&lock));
                        ret = CONFIG_NO_WRITE;
                        goto out_free;
                }
                contents = NULL;
        }
  
 -      if (commit_lock_file(lock) < 0) {
 +      if (commit_lock_file(&lock) < 0) {
                error_errno("could not write config file %s", config_filename);
                ret = CONFIG_NO_WRITE;
 -              lock = NULL;
                goto out_free;
        }
  
 -      /*
 -       * lock is committed, so don't try to roll it back below.
 -       * NOTE: Since lockfile.c keeps a linked list of all created
 -       * lock_file structures, it isn't safe to free(lock).  It's
 -       * better to just leave it hanging around.
 -       */
 -      lock = NULL;
        ret = 0;
  
        /* Invalidate the config cache */
        git_config_clear();
  
  out_free:
 -      if (lock)
 -              rollback_lock_file(lock);
 +      rollback_lock_file(&lock);
        free(filename_buf);
        if (contents)
                munmap(contents, contents_sz);
        return ret;
  
  write_err_out:
 -      ret = write_error(get_lock_file_path(lock));
 +      ret = write_error(get_lock_file_path(&lock));
        goto out_free;
  
  }
diff --combined diff.c
index 85e714f6c68d24e11228b69d2511c49811c979b4,c7cf683e0be05941b3f8beb5184a08c785b174fd..fa77b00492688c67f0cff4d7f1ac54a1868403d4
--- 1/diff.c
--- 2/diff.c
+++ b/diff.c
@@@ -299,9 -299,6 +299,9 @@@ int git_diff_ui_config(const char *var
                return 0;
        }
  
 +      if (git_color_config(var, value, cb) < 0)
 +              return -1;
 +
        return git_diff_basic_config(var, value, cb);
  }
  
@@@ -828,7 -825,7 +828,7 @@@ static void emit_rewrite_diff(const cha
  
  struct diff_words_buffer {
        mmfile_t text;
-       long alloc;
+       unsigned long alloc;
        struct diff_words_orig {
                const char *begin, *end;
        } *orig;