Skip to content

Commit a65f996

Browse files
committed
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. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 4c81eef commit a65f996

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

compat/regex/regcomp.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
1919
02110-1301 USA. */
2020

21+
#include <stdint.h>
22+
2123
static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern,
2224
size_t length, reg_syntax_t syntax);
2325
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,
25772579
old_tree = NULL;
25782580

25792581
if (elem->token.type == SUBEXP)
2580-
postorder (elem, mark_opt_subexp, (void *) (long) elem->token.opr.idx);
2582+
postorder (elem, mark_opt_subexp, (void *) (intptr_t) elem->token.opr.idx);
25812583

25822584
tree = create_tree (dfa, elem, NULL, (end == -1 ? OP_DUP_ASTERISK : OP_ALT));
25832585
if (BE (tree == NULL, 0))
@@ -3806,7 +3808,7 @@ create_token_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
38063808
static reg_errcode_t
38073809
mark_opt_subexp (void *extra, bin_tree_t *node)
38083810
{
3809-
int idx = (int) (long) extra;
3811+
int idx = (int) (intptr_t) extra;
38103812
if (node->token.type == SUBEXP && node->token.opr.idx == idx)
38113813
node->token.opt_subexp = 1;
38123814

pack-revindex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static int pack_revindex_hashsz;
2121

2222
static int pack_revindex_ix(struct packed_git *p)
2323
{
24-
unsigned long ui = (unsigned long)p;
24+
unsigned long ui = (unsigned long)(intptr_t)p;
2525
int i;
2626

2727
ui = ui ^ (ui >> 16); /* defeat structure alignment */

sha1_file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2017,7 +2017,7 @@ static unsigned long pack_entry_hash(struct packed_git *p, off_t base_offset)
20172017
{
20182018
unsigned long hash;
20192019

2020-
hash = (unsigned long)p + (unsigned long)base_offset;
2020+
hash = (unsigned long)(intptr_t)p + (unsigned long)base_offset;
20212021
hash += (hash >> 8) + (hash >> 16);
20222022
return hash % MAX_DELTA_CACHE;
20232023
}

0 commit comments

Comments
 (0)