From: Junio C Hamano <gitster@pobox.com>
To: "brian m. carlson" <sandals@crustytoothpaste.net>
Cc: xmqqfrm9t6up.fsf@gitster.g, git@vger.kernel.org,
phillip.wood123@gmail.com, ps@pks.im,
"Sören Krecker" <soekkle@freenet.de>
Subject: Re: [PATCHv2 1/4] add-patch: Fix type missmatch rom msvc
Date: Mon, 06 Jan 2025 16:26:26 -0800 [thread overview]
Message-ID: <xmqqed1fwjt9.fsf@gitster.g> (raw)
In-Reply-To: <Z3xxxbKtqyLmDAif@tapette.crustytoothpaste.net> (brian m. carlson's message of "Tue, 7 Jan 2025 00:13:57 +0000")
"brian m. carlson" <sandals@crustytoothpaste.net> writes:
> We don't typically put comments about the revisions we've made to a
> patch in the commit message. We may put them below the --- so that
> they're visible to readers and reviewers, which is helpful, but we
> pretend that our patches were perfect to begin with in terms of the
> commit message, since the future reader of the history only cares about
> the actual end result and not what changes we made along the way.
Thanks, all true. The future readers would only *see* the end
results, and we do not want to hear about the previous stumblings
the author made before reaching an acceptable version.
>> ---
>> add-patch.c | 53 +++++++++++++++++++++++++++--------------------
>> gettext.h | 2 +-
>> git-compat-util.h | 6 ++++++
>> 3 files changed, 38 insertions(+), 23 deletions(-)
I already made this comment, but I think the offset/count being
ulong is a very sane design decision, and what is causing the
compiler warning is some earlier change that introduced size_t
variables or parameters in the callchain. As far as I can tell,
there is no system functions that yields size_t (hence we must use
size_t everywhere) in the code paths that deal with offset and
count. I suggested to find these abused size_t and fix them to use
the matching type, i.e. "unsigned long", instead, as an alternative
fix. I did not get an impression that the author tried the approach
and found why we must use size_t for offset/count instead.
And if we go that route, there is *no* need to talk about 64-bit ve
32-bit platforms. ulong used consistently everywhere would let you
use offset/count that fits in ulong, and the apply machinery is
artificially limited to limit the patch size to a few gigabytes, so
32-bit ulong should be plenty as Phillip pointed out earlier.
If we needed to parse an integer into a large integer, the existing
code seem to use strtoumax() into uintmax_t and move it to the
target (while checking for truncation). "Ah we are on windows, so
use strtoll, otherwise use strtol" is not something we want to see
in our codebase.
> If we're using size_t, we can use %zu. That's specified in C99 as the
> appropriate formatting type for size_t, and we require C99 or C11 for
> all systems. We don't need to cast to uintmax_t.
You and Documentation/CodingGuidelines contradict with each other
here.
Thanks for a review.
next prev parent reply other threads:[~2025-01-07 0:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-06 19:08 [PATCHv2 0/4] Fixes typemissmatch warinigs from msvc Sören Krecker
2025-01-06 19:08 ` [PATCHv2 1/4] add-patch: Fix type missmatch rom msvc Sören Krecker
2025-01-07 0:13 ` brian m. carlson
2025-01-07 0:26 ` Junio C Hamano [this message]
2025-01-07 0:53 ` Junio C Hamano
2025-01-06 19:08 ` [PATCHv2 2/4] date.c: Fix type missmatch warings from msvc Sören Krecker
2025-01-06 22:22 ` Eric Sunshine
2025-01-06 22:53 ` Andreas Schwab
2025-01-06 19:08 ` [PATCHv2 3/4] apply.c : " Sören Krecker
2025-01-06 22:26 ` Eric Sunshine
2025-01-06 19:08 ` [PATCHv2 4/4] commit.c: " Sören Krecker
2025-01-06 22:27 ` Eric Sunshine
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqed1fwjt9.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=phillip.wood123@gmail.com \
--cc=ps@pks.im \
--cc=sandals@crustytoothpaste.net \
--cc=soekkle@freenet.de \
--cc=xmqqfrm9t6up.fsf@gitster.g \
/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.
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 NNTP newsgroup(s).