From: Junio C Hamano Date: Mon, 23 Oct 2017 05:20:18 +0000 (+0900) Subject: Merge branch 'rj/no-sign-compare' into maint X-Git-Tag: v2.14.3~4 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/7186408f2486ebbb82736c15efb8fbc372fb5f95?ds=inline;hp=-c Merge branch 'rj/no-sign-compare' into maint 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 --- 7186408f2486ebbb82736c15efb8fbc372fb5f95 diff --combined builtin/pack-objects.c index bd391e97a4,b40cdfe64a..3af63ad54c --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@@ -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); @@@ -2195,10 -2192,7 +2195,10 @@@ 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 c6bc2ff715,149bee1c71..1a8e24f32c --- a/config.c +++ 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; @@@ -2419,7 -2423,8 +2419,7 @@@ * 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); @@@ -2532,8 -2537,8 +2532,8 @@@ 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; } @@@ -2588,19 -2593,28 +2588,19 @@@ 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); @@@ -2609,7 -2623,7 +2609,7 @@@ 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 85e714f6c6,c7cf683e0b..fa77b00492 --- a/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;