From: Philip Oakley <philipoakley@iee.email>
To: GitList <git@vger.kernel.org>, Junio C Hamano <gitster@pobox.com>
Cc: "René Scharfe" <l.s.r@web.de>,
"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
"Derrick Stolee" <stolee@gmail.com>,
"Taylor Blau" <me@ttaylorr.com>,
"Philip Oakley" <philipoakley@iee.email>
Subject: [PATCH v2 0/3] Fix LLP64 `(size_t)1` compatibility VS C4334 warnings
Date: Wed, 1 Dec 2021 00:28:59 +0000 [thread overview]
Message-ID: <20211201002902.1042-1-philipoakley@iee.email> (raw)
Since V1 (gitster/po/size-t-for-vs)
https://lore.kernel.org/git/20211126113614.709-1-philipoakley@iee.email/
Former patch 1/4 was dropped as it was already in Junio's tree.
Patch 1/3 corrects my spelling mistake.
Patch 2/3 has added extra spacing around the << operator as suggested by
Stollee[1].
Patch 3/3 removes the superceded commit message comment regarding
backporting the patch onto maint.
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 [dropped] patch had been reported [2] by René Scharfe as an extra patch
to the rs/mergesort series.
These fixes clear all the current C4334 warnings.
[1] https://lore.kernel.org/git/?q=%3Cf721bc99-6d79-e2f2-7810-dd77b777161f%40gmail.com%3E
[2] https://lore.kernel.org/git/7fbd4cf4-5f66-a4cd-0c41-e5b12d14d761@iee.email/
Philip Oakley (3):
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 +++---
object-file.c | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
Range-diff against v1:
1: c00e082ed8 < -: ---------- mergesort.c: LLP64 compatibility, upcast unity for left shift
2: 85506c7e77 ! 1: 13d9b3fd6d repack.c: LLP64 compatibility, upcast unity for left shift
@@ Commit message
repack.c: LLP64 compatibility, upcast unity for left shift
Visual Studio reports C4334 "was 64-bit shift intended" warning
- because of size miss-match.
+ because of size mismatch.
Promote unity to the matching type to fit with the `&` operator.
3: 2072852f61 ! 2: b6c7ad9177 diffcore-delta.c: LLP64 compatibility, upcast unity for left shift
@@ diffcore-delta.c: static struct spanhash_top *hash_chars(struct repository *r,
i = INITIAL_HASH_SIZE;
hash = xmalloc(st_add(sizeof(*hash),
- st_mult(sizeof(struct spanhash), 1<<i)));
-+ st_mult(sizeof(struct spanhash), (size_t)1<<i)));
++ st_mult(sizeof(struct spanhash), (size_t)1 << i)));
hash->alloc_log2 = i;
hash->free = INITIAL_FREE(i);
- memset(hash->data, 0, sizeof(struct spanhash) * (1<<i));
4: 3b8f33fb28 ! 3: 0fa0d0a8c6 object-file.c: LLP64 compatibility, upcast unity for left shift
@@ Commit message
Signed-off-by: Philip Oakley <philipoakley@iee.email>
- ---
-
- 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 ##
@@ object-file.c: struct oidtree *odb_loose_cache(struct object_directory *odb,
struct strbuf buf = STRBUF_INIT;
--
2.34.0.rc1.windows.1.4.ga126985b17
next reply other threads:[~2021-12-01 0:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-01 0:28 Philip Oakley [this message]
2021-12-01 0:29 ` [PATCH v2 1/3] repack.c: LLP64 compatibility, upcast unity for left shift Philip Oakley
2021-12-01 0:29 ` [PATCH v2 2/3] diffcore-delta.c: " Philip Oakley
2021-12-01 0:29 ` [PATCH v2 3/3] object-file.c: " Philip Oakley
2021-12-01 22:49 ` [PATCH v2 0/3] Fix LLP64 `(size_t)1` compatibility VS C4334 warnings Junio C Hamano
2021-12-02 20:56 ` Derrick Stolee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211201002902.1042-1-philipoakley@iee.email \
--to=philipoakley@iee.email \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=l.s.r@web.de \
--cc=me@ttaylorr.com \
--cc=stolee@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).