Patchwork [2,of,3] xdiff: silence a 32-bit shift warning on Windows

login
register
mail settings
Submitter Matt Harbison
Date March 10, 2018, 3:07 a.m.
Message ID <1f313a913f4356f272ef.1520651222@Envy>
Download mbox | patch
Permalink /patch/29231/
State Accepted
Headers show

Comments

Matt Harbison - March 10, 2018, 3:07 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1520649753 18000
#      Fri Mar 09 21:42:33 2018 -0500
# Node ID 1f313a913f4356f272ef275061d5d169d9c1690e
# Parent  d3b978ff5c3fc50b33b3ca8f6c371df23d46404b
xdiff: silence a 32-bit shift warning on Windows

It's probably harmless, but:

    warning C4334: '<<' : result of 32-bit shift implicitly converted to 64 bits
    (was 64-bit shift intended?)

Adding a 'ULL' suffix to 1 also works, but I doubt that's portable.

Patch

diff --git a/mercurial/thirdparty/xdiff/xprepare.c b/mercurial/thirdparty/xdiff/xprepare.c
--- a/mercurial/thirdparty/xdiff/xprepare.c
+++ b/mercurial/thirdparty/xdiff/xprepare.c
@@ -71,7 +71,7 @@ 
 	cf->flags = flags;
 
 	cf->hbits = xdl_hashbits(size);
-	cf->hsize = 1 << cf->hbits;
+	cf->hsize = ((uint64_t)1) << cf->hbits;
 
 	if (xdl_cha_init(&cf->ncha, sizeof(xdlclass_t), size / 4 + 1) < 0) {
 
@@ -263,7 +263,7 @@ 
 
 	{
 		hbits = xdl_hashbits(narec);
-		hsize = 1 << hbits;
+		hsize = ((uint64_t)1) << hbits;
 		if (!(rhash = (xrecord_t **) xdl_malloc(hsize * sizeof(xrecord_t *))))
 			goto abort;
 		memset(rhash, 0, hsize * sizeof(xrecord_t *));