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 <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
							parent
							
								
									8f77442358
								
							
						
					
					
						commit
						56a1a3ab44
					
				|  | @ -18,6 +18,8 @@ | ||||||
|    Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |    Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||||||
|    02110-1301 USA.  */ |    02110-1301 USA.  */ | ||||||
|  |  | ||||||
|  | #include <stdint.h> | ||||||
|  |  | ||||||
| static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern, | static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern, | ||||||
| 					  size_t length, reg_syntax_t syntax); | 					  size_t length, reg_syntax_t syntax); | ||||||
| static void re_compile_fastmap_iter (regex_t *bufp, | 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; |     old_tree = NULL; | ||||||
|  |  | ||||||
|   if (elem->token.type == SUBEXP) |   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)); |   tree = create_tree (dfa, elem, NULL, (end == -1 ? OP_DUP_ASTERISK : OP_ALT)); | ||||||
|   if (BE (tree == NULL, 0)) |   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 | static reg_errcode_t | ||||||
| mark_opt_subexp (void *extra, bin_tree_t *node) | 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) |   if (node->token.type == SUBEXP && node->token.opr.idx == idx) | ||||||
|     node->token.opt_subexp = 1; |     node->token.opt_subexp = 1; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @ -21,7 +21,7 @@ static int pack_revindex_hashsz; | ||||||
|  |  | ||||||
| static int pack_revindex_ix(struct packed_git *p) | 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; | 	int i; | ||||||
|  |  | ||||||
| 	ui = ui ^ (ui >> 16); /* defeat structure alignment */ | 	ui = ui ^ (ui >> 16); /* defeat structure alignment */ | ||||||
|  |  | ||||||
|  | @ -2014,7 +2014,7 @@ static unsigned long pack_entry_hash(struct packed_git *p, off_t base_offset) | ||||||
| { | { | ||||||
| 	unsigned long hash; | 	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); | 	hash += (hash >> 8) + (hash >> 16); | ||||||
| 	return hash % MAX_DELTA_CACHE; | 	return hash % MAX_DELTA_CACHE; | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Johannes Schindelin
						Johannes Schindelin