From 8f7744235844c44e780e026868beef29693c062e Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 26 Oct 2015 14:15:21 +0100 Subject: Squelch warning about an integer overflow We cannot rely on long integers to have more than 32 bits. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano diff --git a/git-compat-util.h b/git-compat-util.h index 400e921..6a16e20 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -475,7 +475,7 @@ extern int git_munmap(void *start, size_t length); #endif #define DEFAULT_PACKED_GIT_LIMIT \ - ((1024L * 1024L) * (sizeof(void*) >= 8 ? 8192 : 256)) + ((1024L * 1024L) * (size_t)(sizeof(void*) >= 8 ? 8192 : 256)) #ifdef NO_PREAD #define pread git_pread -- cgit v0.10.2-6-g49f6 From 56a1a3ab449df33268776a8b72a301d3ee67ad8d Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 26 Oct 2015 14:15:25 +0100 Subject: Silence GCC's "cast of pointer to integer of a different size" warning When calculating hashes from pointers, it actually makes sense to cut off the most significant bits. In that case, said warning does not make a whole lot of sense. So let's just work around it by casting the pointer first to intptr_t and then casting up/down to the final integral type. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano diff --git a/compat/regex/regcomp.c b/compat/regex/regcomp.c index 06f3088..fba5986 100644 --- a/compat/regex/regcomp.c +++ b/compat/regex/regcomp.c @@ -18,6 +18,8 @@ Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include + static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern, size_t length, reg_syntax_t syntax); static void re_compile_fastmap_iter (regex_t *bufp, @@ -2577,7 +2579,7 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa, old_tree = NULL; if (elem->token.type == SUBEXP) - postorder (elem, mark_opt_subexp, (void *) (long) elem->token.opr.idx); + postorder (elem, mark_opt_subexp, (void *) (intptr_t) elem->token.opr.idx); tree = create_tree (dfa, elem, NULL, (end == -1 ? OP_DUP_ASTERISK : OP_ALT)); if (BE (tree == NULL, 0)) @@ -3806,7 +3808,7 @@ create_token_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right, static reg_errcode_t mark_opt_subexp (void *extra, bin_tree_t *node) { - int idx = (int) (long) extra; + int idx = (int) (intptr_t) extra; if (node->token.type == SUBEXP && node->token.opr.idx == idx) node->token.opt_subexp = 1; diff --git a/pack-revindex.c b/pack-revindex.c index 5c8376e..e542ea7 100644 --- a/pack-revindex.c +++ b/pack-revindex.c @@ -21,7 +21,7 @@ static int pack_revindex_hashsz; static int pack_revindex_ix(struct packed_git *p) { - unsigned long ui = (unsigned long)p; + unsigned long ui = (unsigned long)(intptr_t)p; int i; ui = ui ^ (ui >> 16); /* defeat structure alignment */ diff --git a/sha1_file.c b/sha1_file.c index b231b62..2350a91 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -2014,7 +2014,7 @@ static unsigned long pack_entry_hash(struct packed_git *p, off_t base_offset) { unsigned long hash; - hash = (unsigned long)p + (unsigned long)base_offset; + hash = (unsigned long)(intptr_t)p + (unsigned long)base_offset; hash += (hash >> 8) + (hash >> 16); return hash % MAX_DELTA_CACHE; } -- cgit v0.10.2-6-g49f6 From fdcdb778551b904d57c127d9a3546f6a7c8792d3 Mon Sep 17 00:00:00 2001 From: Waldek Maleska Date: Mon, 26 Oct 2015 14:15:33 +0100 Subject: Correct fscanf formatting string for I64u values This fix is probably purely cosmetic because PRIuMAX is likely identical to SCNuMAX. Nevertheless, when using a function of the scanf() family, the correct interpolation to use is the latter, not the former. Signed-off-by: Waldek Maleska Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano diff --git a/builtin/gc.c b/builtin/gc.c index 005adbe..9023aee 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -222,7 +222,7 @@ static const char *lock_repo_for_gc(int force, pid_t* ret_pid) * running. */ time(NULL) - st.st_mtime <= 12 * 3600 && - fscanf(fp, "%"PRIuMAX" %127c", &pid, locking_host) == 2 && + fscanf(fp, "%"SCNuMAX" %127c", &pid, locking_host) == 2 && /* be gentle to concurrent "gc" on remote hosts */ (strcmp(locking_host, my_host) || !kill(pid, 0) || errno == EPERM); if (fp != NULL) diff --git a/git-compat-util.h b/git-compat-util.h index 6a16e20..33bb762 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -237,6 +237,10 @@ extern char *gitbasename(char *); #define PRIuMAX "llu" #endif +#ifndef SCNuMAX +#define SCNuMAX PRIuMAX +#endif + #ifndef PRIu32 #define PRIu32 "u" #endif -- cgit v0.10.2-6-g49f6