Skip to content

Commit ace5348

Browse files
committed
Merge branch 'js/misc-fixes' into maint
Various compilation fixes and squelching of warnings. * js/misc-fixes: Correct fscanf formatting string for I64u values Silence GCC's "cast of pointer to integer of a different size" warning Squelch warning about an integer overflow
2 parents a878e7e + fdcdb77 commit ace5348

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

builtin/gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ static const char *lock_repo_for_gc(int force, pid_t* ret_pid)
240240
* running.
241241
*/
242242
time(NULL) - st.st_mtime <= 12 * 3600 &&
243-
fscanf(fp, "%"PRIuMAX" %127c", &pid, locking_host) == 2 &&
243+
fscanf(fp, "%"SCNuMAX" %127c", &pid, locking_host) == 2 &&
244244
/* be gentle to concurrent "gc" on remote hosts */
245245
(strcmp(locking_host, my_host) || !kill(pid, 0) || errno == EPERM);
246246
if (fp != NULL)

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

git-compat-util.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ extern char *gitbasename(char *);
296296
#define PRIuMAX "llu"
297297
#endif
298298

299+
#ifndef SCNuMAX
300+
#define SCNuMAX PRIuMAX
301+
#endif
302+
299303
#ifndef PRIu32
300304
#define PRIu32 "u"
301305
#endif
@@ -568,7 +572,7 @@ extern int git_lstat(const char *, struct stat *);
568572
#endif
569573

570574
#define DEFAULT_PACKED_GIT_LIMIT \
571-
((1024L * 1024L) * (sizeof(void*) >= 8 ? 8192 : 256))
575+
((1024L * 1024L) * (size_t)(sizeof(void*) >= 8 ? 8192 : 256))
572576

573577
#ifdef NO_PREAD
574578
#define pread git_pread

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
@@ -2137,7 +2137,7 @@ static unsigned long pack_entry_hash(struct packed_git *p, off_t base_offset)
21372137
{
21382138
unsigned long hash;
21392139

2140-
hash = (unsigned long)p + (unsigned long)base_offset;
2140+
hash = (unsigned long)(intptr_t)p + (unsigned long)base_offset;
21412141
hash += (hash >> 8) + (hash >> 16);
21422142
return hash % MAX_DELTA_CACHE;
21432143
}

0 commit comments

Comments
 (0)