From: Philip Oakley <hidden> Date: 2021-11-26 11:46:35
The Visual Studio MSVC compilation reports a number of C4334 "was 64-bit
shift intended" size mismatch warnings. In most of these cases a size_t
is ANDed (masked) with a bit shift of 1, or 1U. On LLP64 systems the unity
value is 32 bits, while size_t is 64 bits.
The fix is to upcast the unity value to size_t.
The first patch has also been reported [1] by René Scharfe as an extra patch
to the rs/mergesort series. That patch had been on maint.
The middle two patches are similar changes, though [2/4] is a uintptr_t.
The final patch is applied to object-file.c, which has recently been
renamed from sha1-file.c, so couldn't be applied to the earlier maint
branch.[2]
These fixes clear all the current C4334 warnings.
The patches can be squashed together if required.
[1] https://lore.kernel.org/git/7fbd4cf4-5f66-a4cd-0c41-e5b12d14d761@iee.email/
[2] https://lore.kernel.org/git/3e7af5d3-58fd-3a92-371f-3fa26cfe05a0@iee.email/
Philip Oakley (4):
mergesort.c: LLP64 compatibility, upcast unity for left shift
repack.c: LLP64 compatibility, upcast unity for left shift
diffcore-delta.c: LLP64 compatibility, upcast unity for left shift
object-file.c: LLP64 compatibility, upcast unity for left shift
builtin/repack.c | 2 +-
diffcore-delta.c | 6 +++---
mergesort.c | 2 +-
object-file.c | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
--
2.34.0.rc1.windows.1.4.ga126985b17
From: Philip Oakley <hidden> Date: 2021-11-26 11:46:36
Visual Studio reports C4334 "was 64-bit shift intended" warning because
of size miss-match.
Promote unity to the matching type to fit with the assignment.
Signed-off-by: Philip Oakley <redacted>
---
This cannot be applied to the maint-2.32 branch as the earlier René Scharfe
patch had been, because the original sha1-file.c, to which the backport
would apply, has been renamed in e5afd4449d (object-file.c: rename
from sha1-file.c, 2020-12-31) which was merged in 8b327f1784
(Merge branch 'ma/sha1-is-a-hash', 2021-01-15)
---
object-file.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Philip Oakley <hidden> Date: 2021-11-26 11:46:37
Visual Studio reports C4334 "was 64-bit shift intended" size mismatch
warning because of size miss-match.
Promote unity to the matching type to fit with the `&` operator.
Signed-off-by: Philip Oakley <redacted>
---
This is the same fix that René Scharfe provided in 42c456ff81
(mergesort: avoid left shift overflow, 2021-11-16)
Use size_t to match n when building the bitmask for checking whether a
rank is occupied, instead of the default signed int.
---
mergesort.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Philip Oakley <hidden> Date: 2021-11-26 11:46:39
Visual Studio reports C4334 "was 64-bit shift intended" warning
because of size miss-match.
Promote unity to the matching type to fit with its subsequent operation.
Signed-off-by: Philip Oakley <redacted>
---
diffcore-delta.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
From: Philip Oakley <hidden> Date: 2021-11-26 11:46:40
Visual Studio reports C4334 "was 64-bit shift intended" warning
because of size miss-match.
Promote unity to the matching type to fit with the `&` operator.
Signed-off-by: Philip Oakley <redacted>
---
builtin/repack.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: René Scharfe <hidden> Date: 2021-11-27 07:34:44
Am 26.11.21 um 12:36 schrieb Philip Oakley:
Visual Studio reports C4334 "was 64-bit shift intended" size mismatch
warning because of size miss-match.
Promote unity to the matching type to fit with the `&` operator.
Signed-off-by: Philip Oakley <redacted>
---
This is the same fix that René Scharfe provided in 42c456ff81
(mergesort: avoid left shift overflow, 2021-11-16)
Use size_t to match n when building the bitmask for checking whether a
rank is occupied, instead of the default signed int.
Fine with me -- it's just nicer to take the whole set.
René
Visual Studio reports C4334 "was 64-bit shift intended" warning
because of size miss-match.
Promote unity to the matching type to fit with its subsequent operation.
Signed-off-by: Philip Oakley <redacted>
---
diffcore-delta.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
The Visual Studio MSVC compilation reports a number of C4334 "was 64-bit
shift intended" size mismatch warnings. In most of these cases a size_t
is ANDed (masked) with a bit shift of 1, or 1U. On LLP64 systems the unity
value is 32 bits, while size_t is 64 bits.
The fix is to upcast the unity value to size_t.
The first patch has also been reported [1] by René Scharfe as an extra patch
to the rs/mergesort series. That patch had been on maint.
The middle two patches are similar changes, though [2/4] is a uintptr_t.
The final patch is applied to object-file.c, which has recently been
renamed from sha1-file.c, so couldn't be applied to the earlier maint
branch.[2]
These fixes clear all the current C4334 warnings.
Thank you for these changes. They all are obviously correct.
I had one style nitpick that you could take or leave.
From: Philip Oakley <hidden> Date: 2021-11-29 23:49:07
On 27/11/2021 07:32, René Scharfe wrote:
Am 26.11.21 um 12:36 schrieb Philip Oakley:
quoted
Visual Studio reports C4334 "was 64-bit shift intended" size mismatch
warning because of size miss-match.
Promote unity to the matching type to fit with the `&` operator.
Signed-off-by: Philip Oakley <redacted>
---
This is the same fix that René Scharfe provided in 42c456ff81
(mergesort: avoid left shift overflow, 2021-11-16)
Use size_t to match n when building the bitmask for checking whether a
rank is occupied, instead of the default signed int.
Fine with me -- it's just nicer to take the whole set.
René
Thanks, I'm happy either way if others feels it belongs better with your
mergesort series.
From: Philip Oakley <hidden> Date: 2021-11-29 23:50:04
On 29/11/2021 14:44, Derrick Stolee wrote:
On 11/26/2021 6:36 AM, Philip Oakley wrote:
quoted
Visual Studio reports C4334 "was 64-bit shift intended" warning
because of size miss-match.
Promote unity to the matching type to fit with its subsequent operation.
Signed-off-by: Philip Oakley <redacted>
---
diffcore-delta.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
This line blames to me from back in 2fcb03b52d (builtin/repack.c: don't
move existing packs out of the way, 2020-11-17).
The proposed fix here looks good to me (though we were never at any
practical risk of getting bitten by a down-cast here since the maximum
value for `ext` is 5).
Thanks,
Taylor
This line blames to me from back in 2fcb03b52d (builtin/repack.c: don't
move existing packs out of the way, 2020-11-17).
The proposed fix here looks good to me (though we were never at any
practical risk of getting bitten by a down-cast here since the maximum
value for `ext` is 5).
Agreed. It's nice to get a head start on fixing a group of warnings.