From patchwork Mon Dec 23 11:04:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?S=C3=B6ren_Krecker?= X-Patchwork-Id: 13918770 Received: from mout0.freenet.de (mout0.freenet.de [195.4.92.90]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A11A419E98B for ; Mon, 23 Dec 2024 11:09:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.4.92.90 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734952189; cv=none; b=F4WU7DF/VYXapfBO04fQGusjzebQE2ssozgtkp8Cc+vvGfwo5Bl5FEQ4DgAzEhRkLnyvl4TjJOYigeffhpq6ihvYCNNbEtdhNaHe+0odw6xt8QzM3gZRGxn090rIkBhM5YBkLU7+wet7i72VSSa4shTEnMQEdH5qHDP64TI5p1E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734952189; c=relaxed/simple; bh=raavfDdC077toO5qPnU/xqgwY2dPKSWGhSVxvEffEfU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=i0ENEZUvPRC6DQxZty+Ip4qM0x5/DruF8UycIHx03qm4n1fJihQwJCJ/XrANYIDWYtYyacJnnajWk6vlGEW1unG/F7gOGokZNmX2qCgFRp/1rPhoWrErrG+l/Wlx13G8o4r/EVE3y8shkgoe2l1fS90vvvM1tcOiEf+u9hiS2mU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=freenet.de; spf=pass smtp.mailfrom=freenet.de; dkim=pass (2048-bit key) header.d=freenet.de header.i=@freenet.de header.b=ubElE96O; arc=none smtp.client-ip=195.4.92.90 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=freenet.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=freenet.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=freenet.de header.i=@freenet.de header.b="ubElE96O" Received: from [195.4.92.126] (helo=sub7.freenet.de) by mout0.freenet.de with esmtpa (ID soekkle@freenet.de) (port 25) (Exim 4.94.2 #2) id 1tPgEc-0042dB-AE for git@vger.kernel.org; Mon, 23 Dec 2024 12:04:26 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=freenet.de; s=mjaymdexmjqk; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=94JEfwm6F/c4RLXmO/TpXVtnnNbBuzqseUJJbgrAyHk=; b=ubElE96OGblI3e38LT4Jfti4c8 tj7TQ3arSOaFpqGm/STUDUvhGIM2NCsO3JRqe7F7ZFFP9TxdhThgDdhWQMlSvuA3LpPqSZX+kwcCy 0JF3z8qSVMyBqXm76dUXI6cheVX96Bt87Vytfxx3WDHzTUqD94O0lgdCWz9uNOpG+USXD12Nw988n pKb/Jxgd3VAhZI5XaBXfHWPOLLgqfLXoZUBoDTrbPBUD6C+iDb8DySR2RC40fz5tTDS4PpFXdZk3x fKNn/27H7n+qI3+9PJ91ud1ijZfClugim6Vk3VkyD6ovkL4Acq5ZYOIy5EyqMbLSjQde6EUydB2pr kvRNfMKg==; Received: from p200300e2e705fb00dacb8afffee0ca63.dip0.t-ipconnect.de ([2003:e2:e705:fb00:dacb:8aff:fee0:ca63]:53566 helo=soren-pc.lan) by sub7.freenet.de with esmtpsa (ID soekkle@freenet.de) (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (port 465) (Exim 4.94.2 #2) id 1tPgEc-00BYML-0n; Mon, 23 Dec 2024 12:04:26 +0100 From: =?utf-8?q?S=C3=B6ren_Krecker?= To: git@vger.kernel.org Cc: =?utf-8?q?S=C3=B6ren_Krecker?= Subject: [PATCH 1/4] add-patch: Fix type missmatch rom msvc Date: Mon, 23 Dec 2024 12:04:04 +0100 Message-Id: <20241223110407.3308-2-soekkle@freenet.de> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241223110407.3308-1-soekkle@freenet.de> References: <20241223110407.3308-1-soekkle@freenet.de> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FN-MUUID: 173495186601ECAF0BD35CO X-Originated-At: 2003:e2:e705:fb00:dacb:8aff:fee0:ca63!53566 X-Scan-TS: Mon, 23 Dec 2024 12:04:26 +0100 Fix some compiler warings from msvw in add-patch.c for value truncation form 64 bit to 32 bit integers.Change unsigned long to size_t for correct variable size on linux and windows Signed-off-by: Sören Krecker --- add-patch.c | 44 +++++++++++++++++++++++++------------------- gettext.h | 2 +- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/add-patch.c b/add-patch.c index 557903310d..1ea70ef988 100644 --- a/add-patch.c +++ b/add-patch.c @@ -241,7 +241,7 @@ static struct patch_mode patch_mode_worktree_nothead = { }; struct hunk_header { - unsigned long old_offset, old_count, new_offset, new_count; + size_t old_offset, old_count, new_offset, new_count; /* * Start/end offsets to the extra text after the second `@@` in the * hunk header, e.g. the function signature. This is expected to @@ -321,7 +321,7 @@ static void setup_child_process(struct add_p_state *s, } static int parse_range(const char **p, - unsigned long *offset, unsigned long *count) + size_t *offset, size_t *count) { char *pend; @@ -672,8 +672,8 @@ static void render_hunk(struct add_p_state *s, struct hunk *hunk, */ const char *p; size_t len; - unsigned long old_offset = header->old_offset; - unsigned long new_offset = header->new_offset; + size_t old_offset = header->old_offset; + size_t new_offset = header->new_offset; if (!colored) { p = s->plain.buf + header->extra_start; @@ -699,12 +699,14 @@ static void render_hunk(struct add_p_state *s, struct hunk *hunk, else new_offset += delta; - strbuf_addf(out, "@@ -%lu", old_offset); + strbuf_addf(out, "@@ -%" PRIuMAX, (uintmax_t)old_offset); if (header->old_count != 1) - strbuf_addf(out, ",%lu", header->old_count); - strbuf_addf(out, " +%lu", new_offset); + strbuf_addf(out, ",%" PRIuMAX, + (uintmax_t)header->old_count); + strbuf_addf(out, " +%" PRIuMAX, (uintmax_t)new_offset); if (header->new_count != 1) - strbuf_addf(out, ",%lu", header->new_count); + strbuf_addf(out, ",%" PRIuMAX, + (uintmax_t)header->new_count); strbuf_addstr(out, " @@"); if (len) @@ -1065,11 +1067,13 @@ static int split_hunk(struct add_p_state *s, struct file_diff *file_diff, /* last hunk simply gets the rest */ if (header->old_offset != remaining.old_offset) - BUG("miscounted old_offset: %lu != %lu", - header->old_offset, remaining.old_offset); + BUG("miscounted old_offset: %"PRIuMAX" != %"PRIuMAX, + (uintmax_t)header->old_offset, + (uintmax_t)remaining.old_offset); if (header->new_offset != remaining.new_offset) - BUG("miscounted new_offset: %lu != %lu", - header->new_offset, remaining.new_offset); + BUG("miscounted new_offset: %"PRIuMAX" != %"PRIuMAX, + (uintmax_t)header->new_offset, + (uintmax_t)remaining.new_offset); header->old_count = remaining.old_count; header->new_count = remaining.new_count; hunk->end = end; @@ -1353,9 +1357,10 @@ static void summarize_hunk(struct add_p_state *s, struct hunk *hunk, struct strbuf *plain = &s->plain; size_t len = out->len, i; - strbuf_addf(out, " -%lu,%lu +%lu,%lu ", - header->old_offset, header->old_count, - header->new_offset, header->new_count); + strbuf_addf(out, + " -%"PRIuMAX",%"PRIuMAX" +%"PRIuMAX",%"PRIuMAX" ", + (uintmax_t)header->old_offset, (uintmax_t)header->old_count, + (uintmax_t)header->new_offset, (uintmax_t)header->new_count); if (out->len - len < SUMMARY_HEADER_WIDTH) strbuf_addchars(out, ' ', SUMMARY_HEADER_WIDTH + len - out->len); @@ -1624,10 +1629,11 @@ static int patch_update_file(struct add_p_state *s, else if (0 < response && response <= file_diff->hunk_nr) hunk_index = response - 1; else - err(s, Q_("Sorry, only %d hunk available.", - "Sorry, only %d hunks available.", - file_diff->hunk_nr), - (int)file_diff->hunk_nr); + err(s, + Q_("Sorry, only %"PRIuMAX" hunk available.", + "Sorry, only %"PRIuMAX" hunks available.", + (uintmax_t)file_diff->hunk_nr), + (uintmax_t)file_diff->hunk_nr); } else if (s->answer.buf[0] == '/') { regex_t regex; int ret; diff --git a/gettext.h b/gettext.h index 484cafa562..d36f5a7ade 100644 --- a/gettext.h +++ b/gettext.h @@ -53,7 +53,7 @@ static inline FORMAT_PRESERVING(1) const char *_(const char *msgid) } static inline FORMAT_PRESERVING(1) FORMAT_PRESERVING(2) -const char *Q_(const char *msgid, const char *plu, unsigned long n) +const char *Q_(const char *msgid, const char *plu, size_t n) { if (!git_gettext_enabled) return n == 1 ? msgid : plu; From patchwork Mon Dec 23 11:04:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?S=C3=B6ren_Krecker?= X-Patchwork-Id: 13918771 Received: from mout0.freenet.de (mout0.freenet.de [195.4.92.90]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E084199FA4 for ; Mon, 23 Dec 2024 11:09:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.4.92.90 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734952191; cv=none; b=BvuT9N28BZWImdJ23j/xM2SwHSIKSdd3oy02ErYhNVRbpIlYQqqfsEg0gMVjYwlxyWVqipt8KcvGJHnUPjP1aU2yMc+4E1VCOpeomIzkcVfZUDtiku6AjM32Yk2Q4R1ZI/pXyleNSngFG4XYp319b/1F4EOGLBG9p+56CZkt4fU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734952191; c=relaxed/simple; bh=GAs7RAu8TZe+wmBCkENTpUGya2ho9jR/+uD1UbJzX9A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=uutz284GhmhSzX94i0Y0YCT7xKDwZD3Uv/GQz6DwCWo0rAAZqcEDup5DgaGzyuQ5tYMiNt7ymBb2kLtGawSFbEcuvCmDLY6cJn+NzhlyhKuszHpwDAwa74co0nAn5LZo2a3uDJra+8hlHlGAKEaXP9hsTy7gqoHz0p5BPBahp1M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=freenet.de; spf=pass smtp.mailfrom=freenet.de; dkim=pass (2048-bit key) header.d=freenet.de header.i=@freenet.de header.b=QnYsL2Ak; arc=none smtp.client-ip=195.4.92.90 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=freenet.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=freenet.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=freenet.de header.i=@freenet.de header.b="QnYsL2Ak" Received: from [195.4.92.126] (helo=sub7.freenet.de) by mout0.freenet.de with esmtpa (ID soekkle@freenet.de) (port 25) (Exim 4.94.2 #2) id 1tPgEe-0042gR-9m for git@vger.kernel.org; Mon, 23 Dec 2024 12:04:28 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=freenet.de; s=mjaymdexmjqk; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=b6CMf94hWqinn1WiMMNMI2/53yVM/Fvnt3CMwY2WX0k=; b=QnYsL2AkepqPVEnPtjYaQoSx+f 30yVRF16omHQAQlq0UEnZb6DTS1DfUDaDVkuO9lA3+TM1pzIy8ga2xj98YePX+WcEbjaM9xzLLMuk hXJLFf2I5ljn4XpahiucCldASA4s3mdBlnqel3m2wx+ewtZNnecu4JYTlDcoLU/H7AZM1lJBy5hZw pxg4bPwZPOTsZh85VrXAOiibB98pvka+YGml2VjFZj8uN/9Gl3exjpZGrtM1BKxcfE9kP6dPJ2Emc Z3VyHGncCS5BA6aFBCXrN2zomslkx9TAMD8ro6LxHrFUj9XWATjDrkbwgphBuzbxFgjvQDlKEhK11 qQWVwL5g==; Received: from p200300e2e705fb00dacb8afffee0ca63.dip0.t-ipconnect.de ([2003:e2:e705:fb00:dacb:8aff:fee0:ca63]:53566 helo=soren-pc.lan) by sub7.freenet.de with esmtpsa (ID soekkle@freenet.de) (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (port 465) (Exim 4.94.2 #2) id 1tPgEc-00BYML-VB; Mon, 23 Dec 2024 12:04:28 +0100 From: =?utf-8?q?S=C3=B6ren_Krecker?= To: git@vger.kernel.org Cc: =?utf-8?q?S=C3=B6ren_Krecker?= Subject: [PATCH 2/4] date.c: Fix type missmatch warings from msvc Date: Mon, 23 Dec 2024 12:04:05 +0100 Message-Id: <20241223110407.3308-3-soekkle@freenet.de> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241223110407.3308-1-soekkle@freenet.de> References: <20241223110407.3308-1-soekkle@freenet.de> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FN-MUUID: 17349518669BFD4AD2FCC1O X-Originated-At: 2003:e2:e705:fb00:dacb:8aff:fee0:ca63!53566 X-Scan-TS: Mon, 23 Dec 2024 12:04:27 +0100 Fix compiler warings 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. Signed-off-by: Sören Krecker --- date.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/date.c b/date.c index bee9fe8f10..8ae19f9ecc 100644 --- a/date.c +++ b/date.c @@ -1242,7 +1242,7 @@ static const char *approxidate_alpha(const char *date, struct tm *tm, struct tm } for (s = special; s->name; s++) { - int len = strlen(s->name); + size_t len = strlen(s->name); if (match_string(date, s->name) == len) { s->fn(tm, now, num); *touched = 1; @@ -1252,7 +1252,7 @@ static const char *approxidate_alpha(const char *date, struct tm *tm, struct tm if (!*num) { for (i = 1; i < 11; i++) { - int len = strlen(number_name[i]); + size_t len = strlen(number_name[i]); if (match_string(date, number_name[i]) == len) { *num = i; *touched = 1; @@ -1268,7 +1268,7 @@ static const char *approxidate_alpha(const char *date, struct tm *tm, struct tm tl = typelen; while (tl->type) { - int len = strlen(tl->type); + size_t len = strlen(tl->type); if (match_string(date, tl->type) >= len-1) { update_tm(tm, now, tl->length * *num); *num = 0; From patchwork Mon Dec 23 11:04:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?S=C3=B6ren_Krecker?= X-Patchwork-Id: 13918772 Received: from mout0.freenet.de (mout0.freenet.de [195.4.92.90]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C476219E98B for ; Mon, 23 Dec 2024 11:09:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.4.92.90 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734952193; cv=none; b=gxC6W7WDDVSVp+z2VUv+4DgG39acHsPhQxKf7UEF7OqWEp/SLYgxtrB2BOWiurIx2QZG5/fTycd0FtB/VBe5I9V29CoUeuqmyOe6SARAokhFhuXorBAlSy1x0r3yiBHy4S8404fnjDHF+D/WB4a69uMA794JEUce/QG1cilh1Sg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734952193; c=relaxed/simple; bh=zaKEjxO6/Q1NBsSP4Pi9PCM5WxcoejkpCMRkXnMjOms=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=h54Y9PzCNtHu3J1M8hZHNr2UqAC2SIAVwfxu0o37bmnW6XWgUOgBFFZtAJ5HHIvPqpdtRB/VJXnkRRJrCMa0q435J5A900GHKa16ow8MLTbP/XdBV+fhlGZdQE4+oq2dMkqYPkqQucSrmkTVeZJAqkW60/dOdWpnRyRT4ZvSLHc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=freenet.de; spf=pass smtp.mailfrom=freenet.de; dkim=pass (2048-bit key) header.d=freenet.de header.i=@freenet.de header.b=s2Kf7alY; arc=none smtp.client-ip=195.4.92.90 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=freenet.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=freenet.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=freenet.de header.i=@freenet.de header.b="s2Kf7alY" Received: from [195.4.92.126] (helo=sub7.freenet.de) by mout0.freenet.de with esmtpa (ID soekkle@freenet.de) (port 25) (Exim 4.94.2 #2) id 1tPgEf-0042k6-PW for git@vger.kernel.org; Mon, 23 Dec 2024 12:04:29 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=freenet.de; s=mjaymdexmjqk; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=lkkDaHelX2wTe/2PGgnm4qXgdU3e6K2YPpcG0dFcnaU=; b=s2Kf7alYRp7ldgDZ5GGCgpqxAS Byw73nL6Cdc39R8Ye0X2puMGzTuBcdh+vS2V9QZKwtysuxblWdVFaIj79ZUmDx9aMrNtIr3jQatpt muWqgh+14AOk9tUa6yN18HA3eO4W1DjOD1X55xfq2UosNmlGBKX+1EwP3KBfD1OtCH2kO01xXpF/p 2RYmSXAuYS8V0W1aP5f1nGH8VDL7ky7xKyckN2EFD8aW212EHVuzJZZaKrox6vy0MVedY+oZv6i1W 7GD8oGTDAwXjwwCfElrLJ9H5od3vDn2q9AcZeYCYsWu5bKT01hz0+i2nt098X8OfRwSJQtVrwgvgN oBaw2Bnw==; Received: from p200300e2e705fb00dacb8afffee0ca63.dip0.t-ipconnect.de ([2003:e2:e705:fb00:dacb:8aff:fee0:ca63]:53566 helo=soren-pc.lan) by sub7.freenet.de with esmtpsa (ID soekkle@freenet.de) (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (port 465) (Exim 4.94.2 #2) id 1tPgEf-00BYML-Fi; Mon, 23 Dec 2024 12:04:29 +0100 From: =?utf-8?q?S=C3=B6ren_Krecker?= To: git@vger.kernel.org Cc: =?utf-8?q?S=C3=B6ren_Krecker?= Subject: [PATCH 3/4] apply.c : Fix type missmatch warings from msvc Date: Mon, 23 Dec 2024 12:04:06 +0100 Message-Id: <20241223110407.3308-4-soekkle@freenet.de> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241223110407.3308-1-soekkle@freenet.de> References: <20241223110407.3308-1-soekkle@freenet.de> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FN-MUUID: 17349518693F917CCDD974O X-Originated-At: 2003:e2:e705:fb00:dacb:8aff:fee0:ca63!53566 X-Scan-TS: Mon, 23 Dec 2024 12:04:29 +0100 Fix compiler warings 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. Signed-off-by: Sören Krecker --- apply.c | 37 +++++++++++++++++++------------------ apply.h | 6 +++--- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/apply.c b/apply.c index a3fc2d5330..5bb0b0e78e 100644 --- a/apply.c +++ b/apply.c @@ -413,9 +413,9 @@ static int read_patch_file(struct strbuf *sb, int fd) return 0; } -static unsigned long linelen(const char *buffer, unsigned long size) +static size_t linelen(const char *buffer, size_t size) { - unsigned long len = 0; + size_t len = 0; while (size--) { len++; if (*buffer++ == '\n') @@ -687,7 +687,7 @@ static char *find_name_common(struct strbuf *root, * or "file~"). */ if (def) { - int deflen = strlen(def); + size_t deflen = strlen(def); if (deflen < len && !strncmp(start, def, deflen)) return squash_slash(xstrdup(def)); } @@ -1087,7 +1087,7 @@ static int gitdiff_index(struct gitdiff_data *state, */ const char *ptr, *eol; int len; - const unsigned hexsz = the_hash_algo->hexsz; + const size_t hexsz = the_hash_algo->hexsz; ptr = strchr(line, '.'); if (!ptr || ptr[1] != '.' || hexsz < ptr - line) @@ -1130,7 +1130,7 @@ static int gitdiff_unrecognized(struct gitdiff_data *state UNUSED, */ static const char *skip_tree_prefix(int p_value, const char *line, - int llen) + size_t llen) { int nslash; int i; @@ -1157,7 +1157,7 @@ static const char *skip_tree_prefix(int p_value, */ static char *git_header_name(int p_value, const char *line, - int llen) + ssize_t llen) { const char *name; const char *second = NULL; @@ -1312,15 +1312,15 @@ static int check_header_line(int linenr, struct patch *patch) return 0; } -int parse_git_diff_header(struct strbuf *root, +size_t parse_git_diff_header(struct strbuf *root, int *linenr, int p_value, const char *line, - int len, - unsigned int size, + size_t len, + size_t size, struct patch *patch) { - unsigned long offset; + size_t offset; struct gitdiff_data parse_hdr_state; /* A git diff has explicit new/delete information, so we don't guess */ @@ -1377,7 +1377,7 @@ int parse_git_diff_header(struct strbuf *root, break; for (i = 0; i < ARRAY_SIZE(optable); i++) { const struct opentry *p = optable + i; - int oplen = strlen(p->str); + size_t oplen = strlen(p->str); int res; if (len < oplen || memcmp(p->str, line, oplen)) continue; @@ -1429,7 +1429,8 @@ static int parse_num(const char *line, unsigned long *p) static int parse_range(const char *line, int len, int offset, const char *expect, unsigned long *p1, unsigned long *p2) { - int digits, ex; + int digits; + size_t ex; if (offset < 0 || offset >= len) return -1; @@ -1464,7 +1465,7 @@ static int parse_range(const char *line, int len, int offset, const char *expect return offset + ex; } -static void recount_diff(const char *line, int size, struct fragment *fragment) +static void recount_diff(const char *line, size_t size, struct fragment *fragment) { int oldlines = 0, newlines = 0, ret = 0; @@ -1474,7 +1475,7 @@ static void recount_diff(const char *line, int size, struct fragment *fragment) } for (;;) { - int len = linelen(line, size); + size_t len = linelen(line, size); size -= len; line += len; @@ -1542,11 +1543,11 @@ static int parse_fragment_header(const char *line, int len, struct fragment *fra */ static int find_header(struct apply_state *state, const char *line, - unsigned long size, + size_t size, int *hdrsize, struct patch *patch) { - unsigned long offset, len; + size_t offset, len; patch->is_toplevel_relative = 0; patch->is_rename = patch->is_copy = 0; @@ -2131,7 +2132,7 @@ static int use_patch(struct apply_state *state, struct patch *p) * the number of bytes consumed otherwise, * so that the caller can call us again for the next patch. */ -static int parse_chunk(struct apply_state *state, char *buffer, unsigned long size, struct patch *patch) +static int parse_chunk(struct apply_state *state, char *buffer, size_t size, struct patch *patch) { int hdrsize, patchsize; int offset = find_header(state, buffer, size, &hdrsize, patch); @@ -2490,7 +2491,7 @@ static int match_fragment(struct apply_state *state, struct strbuf fixed = STRBUF_INIT; char *fixed_buf; size_t fixed_len; - int preimage_limit; + ssize_t preimage_limit; int ret; if (preimage->line_nr + current_lno <= img->line_nr) { diff --git a/apply.h b/apply.h index 90e887ec0e..bb01ce7dbc 100644 --- a/apply.h +++ b/apply.h @@ -166,12 +166,12 @@ int check_apply_state(struct apply_state *state, int force_apply); * * Returns -1 on failure, the length of the parsed header otherwise. */ -int parse_git_diff_header(struct strbuf *root, +size_t parse_git_diff_header(struct strbuf *root, int *linenr, int p_value, const char *line, - int len, - unsigned int size, + size_t len, + size_t size, struct patch *patch); void release_patch(struct patch *patch); From patchwork Mon Dec 23 11:04:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?S=C3=B6ren_Krecker?= X-Patchwork-Id: 13918769 Received: from mout0.freenet.de (mout0.freenet.de [195.4.92.90]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76A1C1990DB for ; Mon, 23 Dec 2024 11:09:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.4.92.90 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734952186; cv=none; b=qWg9hhmCZSN7ZoDrihlxXfijB/CfBOnMKWhgr+sV7ivTmYcyTGti2sNIBysNKO+VefQ1qVJlWbUfdEEGV6KusoDlyybErF0QNUzu2QGawfU2h0g8kgQEupSVJ6onN/GtQbdOGn9nuN/eGvFtXqwqBZABACPkJ0jo1/N8cuYlllI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734952186; c=relaxed/simple; bh=WbnE62eIMQY31ZpRU6F4icQ2avB/aHQyMil4+b3hM3g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=BNAfl9F4rHpdBdc8XvFBW8Lors2axPymC5DpEOJQ7B+HfNPBpVwGqB9mGHd8caSrYbuiKzH4cSKf/P1NHXQNCXO2LMSvhvxQvwMIkeKEaa+ii9iy2TqH/YWfWL8fliE2UjQVIg3NqbzB4fh/fIiAql78eqvmE1OP5+tbDwBrrYE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=freenet.de; spf=pass smtp.mailfrom=freenet.de; dkim=pass (2048-bit key) header.d=freenet.de header.i=@freenet.de header.b=aIGAwG9S; arc=none smtp.client-ip=195.4.92.90 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=freenet.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=freenet.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=freenet.de header.i=@freenet.de header.b="aIGAwG9S" Received: from [195.4.92.126] (helo=sub7.freenet.de) by mout0.freenet.de with esmtpa (ID soekkle@freenet.de) (port 25) (Exim 4.94.2 #2) id 1tPgEf-0042kM-Sp for git@vger.kernel.org; Mon, 23 Dec 2024 12:04:29 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=freenet.de; s=mjaymdexmjqk; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=wlG6Dd4NQp0emPL8kA+L+lok4vOM7hf5bTyKLSZ2e3E=; b=aIGAwG9SemAtfYUsqfQ+O9ztR5 +UL8HSuZrwuvmUecLaTdOihvW6STqrbfmnjkWTykiEFLHkBFzma9/OoJu7RzxU/pMNt6uTGUnF4Jb eluRNP28I0enuexAbEGlQ5rfuU5GsuGazz2hkU1z/YtTsL/sSOTLFNucUIMppwAt3c1YtExYc2ABP LDDhcgpxNWWneZo/KELxXctYUWjncUe8EfycbeYI4HUL8KI7LtnUHVRBZYeJ681Rctlgm1HFFV4Ng F6/ozX4a1kiITSdC1aA9Ktz7yCuTOl4vfFVH8bL7Xm5v1hnoWnNVnEpFCWmSmxx0Cgj4VTA9uKj5U qwnrnw4Q==; Received: from p200300e2e705fb00dacb8afffee0ca63.dip0.t-ipconnect.de ([2003:e2:e705:fb00:dacb:8aff:fee0:ca63]:53566 helo=soren-pc.lan) by sub7.freenet.de with esmtpsa (ID soekkle@freenet.de) (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (port 465) (Exim 4.94.2 #2) id 1tPgEf-00BYML-Jh; Mon, 23 Dec 2024 12:04:29 +0100 From: =?utf-8?q?S=C3=B6ren_Krecker?= To: git@vger.kernel.org Cc: =?utf-8?q?S=C3=B6ren_Krecker?= Subject: [PATCH 4/4] commit.c: Fix type missmatch warings from msvc Date: Mon, 23 Dec 2024 12:04:07 +0100 Message-Id: <20241223110407.3308-5-soekkle@freenet.de> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241223110407.3308-1-soekkle@freenet.de> References: <20241223110407.3308-1-soekkle@freenet.de> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FN-MUUID: 1734951869E1D2075964CFO X-Originated-At: 2003:e2:e705:fb00:dacb:8aff:fee0:ca63!53566 X-Scan-TS: Mon, 23 Dec 2024 12:04:29 +0100 Fix compiler warings 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. Signed-off-by: Sören Krecker --- commit.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/commit.c b/commit.c index 35ab9bead5..3d363260f3 100644 --- a/commit.c +++ b/commit.c @@ -466,8 +466,8 @@ int parse_commit_buffer(struct repository *r, struct commit *item, const void *b struct object_id parent; struct commit_list **pptr; struct commit_graft *graft; - const int tree_entry_len = the_hash_algo->hexsz + 5; - const int parent_entry_len = the_hash_algo->hexsz + 7; + const size_t tree_entry_len = the_hash_algo->hexsz + 5; + const size_t parent_entry_len = the_hash_algo->hexsz + 7; struct tree *tree; if (item->object.parsed) @@ -1114,10 +1114,10 @@ static const char *gpg_sig_headers[] = { int add_header_signature(struct strbuf *buf, struct strbuf *sig, const struct git_hash_algo *algo) { - int inspos, copypos; + ssize_t inspos, copypos; const char *eoh; const char *gpg_sig_header = gpg_sig_headers[hash_algo_by_ptr(algo)]; - int gpg_sig_header_len = strlen(gpg_sig_header); + size_t gpg_sig_header_len = strlen(gpg_sig_header); /* find the end of the header */ eoh = strstr(buf->buf, "\n\n"); @@ -1530,7 +1530,7 @@ int commit_tree(const char *msg, size_t msg_len, const struct object_id *tree, return result; } -static int find_invalid_utf8(const char *buf, int len) +static int find_invalid_utf8(const char *buf, size_t len) { int offset = 0; static const unsigned int max_codepoint[] = {