From patchwork Sun Jan 26 12:58:50 2025 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: 13950675 Received: from mout3.freenet.de (mout3.freenet.de [195.4.92.93]) (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 C5FB146BF for ; Sun, 26 Jan 2025 12:59:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.4.92.93 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737896402; cv=none; b=bL6OpPoHiHCsXet/ZW2/pYpZ0EW5Ia48cbNBXYB+NOGwG0sFxapARbElcEoCfSDz/O3tbAixzfGIEH7zRsGAPLihrNYMeZ7obgLPRns7ZilOZnZK1wFsn3Wf4eAbvXyGgeJmmWDpGzUVWRUGCBCTJHSgVk1rm7Nrbp9cRGd0brg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737896402; c=relaxed/simple; bh=Eg1Ub5ioWmudowdm+mEoqlte6wo6Mvt4aV5ZGF/o25I=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=eFLEKfZV83gT9k5Kp+WcDLK94YvoMNYwkre6MYXLTDHErqXyztqmspMPpGWP4B10hcbTGMtQI4SGwGVei6Ah6htmofHHHW2bm39EMN2lBrrK9vmW0js2TuYNQr51xwCYK2kUStADFdwkdzal0llhElMHBYHLSf3YUIZ1wmeTLgo= 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=I5dqXXYU; arc=none smtp.client-ip=195.4.92.93 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="I5dqXXYU" Received: from [194.97.202.53] (helo=sub8.mail.fnrz.de) by mout3.freenet.de with esmtpa (ID soekkle@freenet.de) (port 25) (Exim 4.94.2 #2) id 1tc2E1-00EmPd-PT; Sun, 26 Jan 2025 13:58:53 +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: Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=3jzfFgbqyo7aV7LaySd9WcqP5Sp+pHT39X8Lj1EbI8E=; b=I5dqXXYU5Ufl/MvsKsBzqznZoX DTT8bCBA/Q3y0NtZuWK4LR1vSEvHj2tvzbbqsgAMafNvRBdPlDFpU0lka+xN2skU4Z6mDNsnl2Wfo f5XdhBj5TLOOPWgAIu8q5rvozS7hTwWjC6NSNKPevSWeBZyPfR+vAaQpQYjAlGPBsUYNj/ABoxcgU pYzffEaCvYUJclC+6Lpm/k4IeWMMBx0oDruhMwfXrMcOxz+01j6S1d66AcDhPPeLWTQ/VtLRBvSOR BUs7D3VzFMCjnRc0/7V2eaelgnL8X08nzQO2t8ietxGsl5wReuvHUIy0Ed/LA2xevgo8yQR2Wec8h SUzruvUA==; Received: from p200300e2e705fb00dacb8afffee0ca63.dip0.t-ipconnect.de ([2003:e2:e705:fb00:dacb:8aff:fee0:ca63]:49204 helo=localhost.localdomain) by sub8.mail.fnrz.de with esmtpsa (ID soekkle@freenet.de) (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (port 465) (Exim 4.96 #2) id 1tc2E1-008RKU-1k; Sun, 26 Jan 2025 13:58:53 +0100 From: =?utf-8?q?S=C3=B6ren_Krecker?= To: git@vger.kernel.org Cc: gitster@pobox.com, phillip.wood123@gmail.com, ps@pks.im, sunshine@sunshineco.com, =?utf-8?q?S=C3=B6ren_Krecker?= Subject: [PATCH v3 2/4] date.c: Fix type conversation warnings from msvc Date: Sun, 26 Jan 2025 13:58:50 +0100 Message-Id: <20250126125850.3195-1-soekkle@freenet.de> X-Mailer: git-send-email 2.39.5 Reply-To: 20250126125638.3089-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: 1737896333651569745F97O X-Originated-At: 2003:e2:e705:fb00:dacb:8aff:fee0:ca63!49204 X-Scan-TS: Sun, 26 Jan 2025 13:58:53 +0100 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. Signed-off-by: Sören Krecker --- date.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/date.c b/date.c index a1b26a8dce..0a3fafc8a4 100644 --- a/date.c +++ b/date.c @@ -1244,7 +1244,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; @@ -1254,7 +1254,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; @@ -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) { update_tm(tm, now, tl->length * *num); *num = 0; *touched = 1; From patchwork Sun Jan 26 12:59:45 2025 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: 13950674 Received: from mout3.freenet.de (mout3.freenet.de [195.4.92.93]) (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 2507946BF for ; Sun, 26 Jan 2025 12:59:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.4.92.93 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737896396; cv=none; b=MlfY83RbFxPA+aiuf08q13JA8++7vt5FNoYtFrr5FoneZQajwWZqXb87if3MkqttMh88gPH81uh7F5JpL4KB7evWi2gArmFUn5ncTOSA7G03Kcvy05WLtgl0kHbaJ6B0AiYkfjhNQmBb5itFKss0clkx8Q4uEuhrp7pZyET4H94= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737896396; c=relaxed/simple; bh=9M5r7VlJvbsl/CqatIX23Oj8CrONDdbND/ihf6qd+30=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=EeUDavJ+JB9SWSbor4iWiWFNAY2WqLGGrXInJbewif9PBs4VJQofA4xvi4GV4K8S8x5+BOHQ4BAv05t6BvnatHlBnKmefSRKocn9xBlyMb9xYV6ljKhNfDpWrxlHbcAWO6umDeeaY6bylllk8hpsh7wpzP8J31J2BpkR5EJW2kY= 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=bUkEiT4C; arc=none smtp.client-ip=195.4.92.93 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="bUkEiT4C" Received: from [194.97.210.52] (helo=sub6.mail.fnrz.de) by mout3.freenet.de with esmtpa (ID soekkle@freenet.de) (port 25) (Exim 4.94.2 #2) id 1tc2Ev-00EnWg-5P; Sun, 26 Jan 2025 13:59:49 +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: Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=AN9cdzo6TIIqIQmHVxUvUo5XR54I66z7FM3heGpfDM0=; b=bUkEiT4Chus79EM0fDP0qiqUbo ZQ1+jDA8alWGAVGfCcodUSndkWHqNKmImyZ3OH83VpNHvnfAmFq4g3K//7+FTjmbZ3t5Pqzr1+Mn0 0XybwI3HHqawvHfnOrqOa22R/33eJcUdyqb9DzhASy1vZd1jkZYdaUx3u/JZhUE8EvvIHCyXFpIOk pvTQ0JiPoQ8bnl9KNEnOnh3++n926PjuLvr+GANQDe+AdPYl/xYRXXFwsBIpAamh+Xuya+PBajanT PmJHaK+1s5VSM/qxmwBoFKEJDo3uRFF6RPg0hfsqiri9C3StLxmLd0ictLiZ/3CpFljT2DT3KjvAH iHbJa8Vg==; Received: from p200300e2e705fb00dacb8afffee0ca63.dip0.t-ipconnect.de ([2003:e2:e705:fb00:dacb:8aff:fee0:ca63]:58466 helo=localhost.localdomain) by sub6.mail.fnrz.de with esmtpsa (ID soekkle@freenet.de) (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (port 465) (Exim 4.96 #2) id 1tc2Eu-009NhH-2r; Sun, 26 Jan 2025 13:59:49 +0100 From: =?utf-8?q?S=C3=B6ren_Krecker?= To: git@vger.kernel.org Cc: gitster@pobox.com, phillip.wood123@gmail.com, ps@pks.im, sunshine@sunshineco.com, =?utf-8?q?S=C3=B6ren_Krecker?= Subject: [PATCH v3 3/4] apply.c : Fix type conversation warnings from msvc Date: Sun, 26 Jan 2025 13:59:45 +0100 Message-Id: <20250126125945.3241-1-soekkle@freenet.de> X-Mailer: git-send-email 2.39.5 Reply-To: 20250126125638.3089-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: 173789638876D03EF0E756O X-Originated-At: 2003:e2:e705:fb00:dacb:8aff:fee0:ca63!58466 X-Scan-TS: Sun, 26 Jan 2025 13:59:48 +0100 Fix compiler warnings from msvc in apply.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 4a7b6120ac..b896889505 100644 --- a/apply.c +++ b/apply.c @@ -414,9 +414,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') @@ -688,7 +688,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)); } @@ -1088,7 +1088,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) @@ -1131,7 +1131,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; @@ -1158,7 +1158,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; @@ -1313,15 +1313,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 */ @@ -1378,7 +1378,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; @@ -1430,7 +1430,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; @@ -1465,7 +1466,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; @@ -1475,7 +1476,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; @@ -1543,11 +1544,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; @@ -2132,7 +2133,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); @@ -2491,7 +2492,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 Sun Jan 26 13:00:38 2025 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: 13950676 Received: from mout3.freenet.de (mout3.freenet.de [195.4.92.93]) (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 3B38325A642 for ; Sun, 26 Jan 2025 13:00:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.4.92.93 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737896445; cv=none; b=Jg1PasRoNn6ESILwSFMyMgXe4D3AbxXKr1TsJzyeFNtK4MHFEEhuqXTkrZ7yXpYENn8mcKsK9vN/OeiZZfoYeCUXaRtDIVYlgj5lnwIMX5LPaZ8mHMJmLfiwfyJ32cF2JvOA0IvheI2qIPZWjJAsTEGMDFIwc6PWgnz+VHCWt0w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737896445; c=relaxed/simple; bh=+Uw5rig4DYr3NXDVPZebxujyy0Vp8L5oNk0h8kIaLVM=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=EbbHgFdJPLCg/0c8zt0MMBAJBMsRSPxPa7arfZhOApWwZyme+cbDN8yQi545koNDrvUx1GAcPKEiBLO3xyKODdQUfGHkMlN22oArVuahLnb87txeKKskassda3+IOIC+FG+Lst9TfIIFCKdhczmlXO8NLB9CYZzTXrWnEcSa7Q8= 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=IA7lNfa/; arc=none smtp.client-ip=195.4.92.93 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="IA7lNfa/" Received: from [194.97.202.51] (helo=sub2.mail.fnrz.de) by mout3.freenet.de with esmtpa (ID soekkle@freenet.de) (port 25) (Exim 4.94.2 #2) id 1tc2Fl-00Eoc3-8d; Sun, 26 Jan 2025 14:00:41 +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: Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=5YkF2cpLZJ+DrMjyWHRTkPQIOs3ftI6ohcQrRDFz1qE=; b=IA7lNfa/fSZzyzWdbWMQDKsK1K 7GhiI/VPS2NWYk+ucsoFfYwiOOfUJ1VoeYf2TCIoByQHV2Vz9CkCtNonwx3WEwlJ2cMBTCxOz2S5F jP3+hG8zWeSGKAQnwyRZTEoDNoJx91KLZ4XOLVOefwC2t3B/1G+aGE0ZRLpmlAlJvlX2lRsLMgxKP 2TGvQ9v1IOu1ojIh1PWVnrw3vKUWkLcOLjyjp0D8QQ53YxqUB9qzpXTTctZVYhhUDoDcHObd92ulS xJZn78zbW+GK5neNL5SAcDieDCpSNwLVhvBf9owhJp7asYH/8JlDRltMJzEnxuKPDV5QZJeEReKRf o23njlmw==; Received: from p200300e2e705fb00dacb8afffee0ca63.dip0.t-ipconnect.de ([2003:e2:e705:fb00:dacb:8aff:fee0:ca63]:53548 helo=localhost.localdomain) by sub2.mail.fnrz.de with esmtpsa (ID soekkle@freenet.de) (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (port 465) (Exim 4.96 #2) id 1tc2Fk-0095I2-39; Sun, 26 Jan 2025 14:00:41 +0100 From: =?utf-8?q?S=C3=B6ren_Krecker?= To: git@vger.kernel.org Cc: gitster@pobox.com, phillip.wood123@gmail.com, ps@pks.im, sunshine@sunshineco.com, =?utf-8?q?S=C3=B6ren_Krecker?= Subject: [PATCH v3 4/4] commit.c: Fix type conversation warnings from msvc Date: Sun, 26 Jan 2025 14:00:38 +0100 Message-Id: <20250126130038.3277-1-soekkle@freenet.de> X-Mailer: git-send-email 2.39.5 Reply-To: 20250126125638.3089-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: 1737896440E86B2E9076C8O X-Originated-At: 2003:e2:e705:fb00:dacb:8aff:fee0:ca63!53548 X-Scan-TS: Sun, 26 Jan 2025 14:00:41 +0100 Fix compiler warnings from msvc in commit.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 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/commit.c b/commit.c index 540660359d..c9cc56bd9f 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[] = { @@ -1539,7 +1539,7 @@ static int find_invalid_utf8(const char *buf, int len) while (len) { unsigned char c = *buf++; - int bytes, bad_offset; + size_t bytes, bad_offset; unsigned int codepoint; unsigned int min_val, max_val;