git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: 20250126125638.3089-1-soekkle@freenet.de
Cc: git@vger.kernel.org, gitster@pobox.com,
	phillip.wood123@gmail.com, sunshine@sunshineco.com,
	"Sören Krecker" <soekkle@freenet.de>
Subject: Re: [PATCH v3 2/4] date.c: Fix type conversation warnings from msvc
Date: Mon, 27 Jan 2025 08:26:15 +0100	[thread overview]
Message-ID: <Z5c1F7oqsaPrHRiT@pks.im> (raw)
In-Reply-To: <20250126125850.3195-1-soekkle@freenet.de>

On Sun, Jan 26, 2025 at 01:58:50PM +0100, Sören Krecker wrote:
> Fix compiler warnings from msvc in date.c for value truncation from 64
> bit to 32 bit integers.
> 
> Also switch from int to size_t for all variables with result of strlen()
> which cannot become negative.

As far as I can see this patch only does the latter and doesn't do the
former, so the commit message seems inaccurate to me.

> diff --git a/date.c b/date.c
> index a1b26a8dce..0a3fafc8a4 100644
> --- a/date.c
> +++ b/date.c
> @@ -1270,8 +1270,8 @@ static const char *approxidate_alpha(const char *date, struct tm *tm, struct tm
>  
>  	tl = typelen;
>  	while (tl->type) {
> -		int len = strlen(tl->type);
> -		if (match_string(date, tl->type) >= len-1) {
> +		size_t len = strlen(tl->type);
> +		if (match_string(date, tl->type)+1 >= len) {

Formatting is off here, there should be spaces around `+`, even though
you simply followed previous style. It would be nice to point out why
this change is makde in the commit message.

Patrick

  reply	other threads:[~2025-01-27  7:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-26 12:58 [PATCH v3 2/4] date.c: Fix type conversation warnings from msvc Sören Krecker
2025-01-27  7:26 ` Patrick Steinhardt [this message]
2025-01-27 16:15   ` Junio C Hamano
2025-01-28  8:45     ` Patrick Steinhardt

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=Z5c1F7oqsaPrHRiT@pks.im \
    --to=ps@pks.im \
    --cc=20250126125638.3089-1-soekkle@freenet.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=phillip.wood123@gmail.com \
    --cc=soekkle@freenet.de \
    --cc=sunshine@sunshineco.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.
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).