From patchwork Mon Nov 4 09:59:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elia Pinto X-Patchwork-Id: 11225313 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1FB6C13A4 for ; Mon, 4 Nov 2019 09:59:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EBF1921D7D for ; Mon, 4 Nov 2019 09:59:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="X3CYw2jz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727444AbfKDJ7a (ORCPT ); Mon, 4 Nov 2019 04:59:30 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:34139 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726633AbfKDJ7a (ORCPT ); Mon, 4 Nov 2019 04:59:30 -0500 Received: by mail-wr1-f66.google.com with SMTP id e6so14428664wrw.1 for ; Mon, 04 Nov 2019 01:59:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=9Bv6Sa/pPpzTh7PcHzB7QghBNPzN2NHdW081Foirntg=; b=X3CYw2jzxG2OGnRs7UAeWH5v2+KgtiuqBYjS+24RDNT21YMnamfvdmdAW4RyJKY9eh axnjhK36+e40/BZ408X6sAwvWU7tzljykWJ+NWie1u0I+3RCl/gj9f3F3CE5FpGj1AJ0 YgCovvA/AJ9LI2O6nVvaZKHcoBcj9cYZ1pCrKUxLPJG9jlrEAmbXa2gweej7wHkXowYm Xk523VMcYRd0pyAH2jTgSefjOJQmJ3wtjdG2Xib6tVUcgJ8niX4OWdWnt12b6ksIL2LF V4Tso2MuNJVKeUy69uAtRWK0McXrMQqbexKjucvBloizvYFzG89pubZMY7pfQQFxQ7mZ J0mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=9Bv6Sa/pPpzTh7PcHzB7QghBNPzN2NHdW081Foirntg=; b=Be+gorZy5/JF6ixIpuGDr/qwYZwowm2jFNzy6kA1od+6bJ7BCFsdgdYWfsZ7ko3wkM OZ/DZOV5ZA1n247kRL1Td8uoysAivxhQUo1r3IuF/EnJeZvvgsBbmW0ed6oSKGi4xGru XcUQaapDgrDMABEjh1iNqr4lb5CfgnbpbOZQM7+oJbi8Emn2G4QysUbdq+wVSXyTz9h4 ZMd8x7oaXo2rc3lbj2L2G0iC2gGeG0jKKIGW2iuHbFEvEdlndQ2OPlkzgxEturtqiDjq 8pOOr5oxFdnhWmIBCL+/ykN1fKYP6tyzxCscTgdBUua3GdHJBA9j8ee980UgPLqtSa8C b3qg== X-Gm-Message-State: APjAAAUNLHLjQ3DMBb6qk6myY5712IY8RsFVkPbYit2XkcRfRriLtBB9 EvAuH8pcAtftJ4P5ZkizfxqbJVx2 X-Google-Smtp-Source: APXvYqznmQKK+ozq7Mnb4wH0jEXwNj3oWSddDFbwmSfuxTF82PU2QPoG8Rek+WmMZNn/mPTjVjLq5Q== X-Received: by 2002:adf:d083:: with SMTP id y3mr21078762wrh.53.1572861567791; Mon, 04 Nov 2019 01:59:27 -0800 (PST) Received: from ubuntu2pinto.pd5x2phgis1evm2itoce0l41ib.ax.internal.cloudapp.net ([13.81.118.113]) by smtp.gmail.com with ESMTPSA id j22sm23382554wrd.41.2019.11.04.01.59.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2019 01:59:27 -0800 (PST) From: Elia Pinto To: git@vger.kernel.org Cc: Elia Pinto Subject: [PATCH 30/32] ident.c: fix LGTM warning on the possible abuse of the '=' operator Date: Mon, 4 Nov 2019 09:59:21 +0000 Message-Id: <20191104095923.116086-1-gitter.spiros@gmail.com> X-Mailer: git-send-email 2.24.0.rc0.467.g566ccdd3e4.dirty MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix the LGTM warning of the rule that finds uses of the assignment operator = in places where the equality operator == would make more sense. Signed-off-by: Elia Pinto --- ident.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ident.c b/ident.c index e666ee4e59..07f2f03b0a 100644 --- a/ident.c +++ b/ident.c @@ -172,12 +172,15 @@ const char *ident_default_email(void) strbuf_addstr(&git_default_email, email); committer_ident_explicitly_given |= IDENT_MAIL_GIVEN; author_ident_explicitly_given |= IDENT_MAIL_GIVEN; - } else if ((email = query_user_email()) && email[0]) { - strbuf_addstr(&git_default_email, email); - free((char *)email); - } else - copy_email(xgetpwuid_self(&default_email_is_bogus), + } else { + email = query_user_email(); + if (email && email[0]) { + strbuf_addstr(&git_default_email, email); + free((char *)email); + } else + copy_email(xgetpwuid_self(&default_email_is_bogus), &git_default_email, &default_email_is_bogus); + } strbuf_trim(&git_default_email); } return git_default_email.buf; From patchwork Mon Nov 4 09:59:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elia Pinto X-Patchwork-Id: 11225315 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2F4DE13A4 for ; Mon, 4 Nov 2019 09:59:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0846C21D7D for ; Mon, 4 Nov 2019 09:59:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZZOS9/S+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727796AbfKDJ7q (ORCPT ); Mon, 4 Nov 2019 04:59:46 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:55448 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726633AbfKDJ7q (ORCPT ); Mon, 4 Nov 2019 04:59:46 -0500 Received: by mail-wm1-f66.google.com with SMTP id m17so6622048wmi.5 for ; Mon, 04 Nov 2019 01:59:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UEXow+GLcFQdob2KSCXujhv+iVrZ+dqu9kyWHDqBLJw=; b=ZZOS9/S+V6dGCJSfX4SWn3OvCbEZ85WiQPsDsagHjp7PIFR8qy+snMJwez7H3smZEB uefzsk3FINftfYT+P4Fhn/fIVpA5aED7CQ7X7qADv97gEKfxv+Y+dAwMhKd/5g3Q2141 tQFSaWHR+l4xmob3gMf/nZEDQGf98vgYLSsSrxfxDmURknolDs01n7T6rtAXf0mh8pth Z8UWUKJ3VsYlT4UYw1xr4cYb4MOZAHu/XAOYT3cuQ7HJu1dahnGKxeqrX5Zh6Me7O34e ikCZqBMhntOwbkFE0svp/CM0JQkwv24AZg6U36HJfpyXc4hBI6/Dhb4yX3whB1hJ0C1D Qd7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UEXow+GLcFQdob2KSCXujhv+iVrZ+dqu9kyWHDqBLJw=; b=EHhcIqEgNej0gDzxJjtsJgXlQOz/s4867xGxRoorlN3jokhhiKnrYssZMoLeuFgOSB XIT9f/HoCu6xh23hXgPmHW3yCWNhcnZRuz++8atxqxNwILTErm8baAjERdGZE6p+8ufP dfHZTJjzpdAL2r+TYsEYhjyerZe0aJtELH2MFEsr1mDuerd5jqBZByzDHkR9cBIuCvpW yu3TV+2phG2LIpB5PfDeq2og/HojTNrymgkNAGAWrwVrRurQ1ElktlBIzbLtqwnIiaqT 1kvknG0YxsMY8Rw+LY3SBeHHg2ohh9Xsx0aII+M0N98QE8dtCMv3F98zXWRezrJOQ6eS lofg== X-Gm-Message-State: APjAAAVx8SUWPRSv0/oy/4wNawVuCWoUBQyjAkF2u6WZFAfdz5OPSuYm rGHo85+zJZ7vgQR/TJb3iDJfvsARcmGp0vJt X-Google-Smtp-Source: APXvYqyg8plx/GdaLuxTl4mi1hYLs7EReJPqXNN2DZkHGM54w77nmTJYH7gxC/AGt0tFbaJpbc6QSg== X-Received: by 2002:a1c:6308:: with SMTP id x8mr22279950wmb.140.1572861583416; Mon, 04 Nov 2019 01:59:43 -0800 (PST) Received: from ubuntu2pinto.pd5x2phgis1evm2itoce0l41ib.ax.internal.cloudapp.net ([13.81.118.113]) by smtp.gmail.com with ESMTPSA id j22sm23382554wrd.41.2019.11.04.01.59.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2019 01:59:42 -0800 (PST) From: Elia Pinto To: git@vger.kernel.org Cc: Elia Pinto Subject: [PATCH 31/32] commit-graph.c: fix code that could convert the result of an integer multiplication to a larger type Date: Mon, 4 Nov 2019 09:59:22 +0000 Message-Id: <20191104095923.116086-2-gitter.spiros@gmail.com> X-Mailer: git-send-email 2.24.0.rc0.467.g566ccdd3e4.dirty In-Reply-To: <20191104095923.116086-1-gitter.spiros@gmail.com> References: <20191104095923.116086-1-gitter.spiros@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix the LGTM warning fired by the rule that finds code that could convert the result of an integer multiplication to a larger type. Since the conversion applies after the multiplication, arithmetic overflow may still occur. Signed-off-by: Elia Pinto --- commit-graph.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/commit-graph.c b/commit-graph.c index a0f868522b..0be15f1cd4 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -1415,8 +1415,8 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx) chunk_offsets[0] = 8 + (num_chunks + 1) * GRAPH_CHUNKLOOKUP_WIDTH; chunk_offsets[1] = chunk_offsets[0] + GRAPH_FANOUT_SIZE; - chunk_offsets[2] = chunk_offsets[1] + hashsz * ctx->commits.nr; - chunk_offsets[3] = chunk_offsets[2] + (hashsz + 16) * ctx->commits.nr; + chunk_offsets[2] = chunk_offsets[1] + (uint64_t)hashsz * ctx->commits.nr; + chunk_offsets[3] = chunk_offsets[2] + ((uint64_t)hashsz + 16) * ctx->commits.nr; num_chunks = 3; if (ctx->num_extra_edges) { @@ -1426,7 +1426,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx) } if (ctx->num_commit_graphs_after > 1) { chunk_offsets[num_chunks + 1] = chunk_offsets[num_chunks] + - hashsz * (ctx->num_commit_graphs_after - 1); + (uint64_t)hashsz * (ctx->num_commit_graphs_after - 1); num_chunks++; } @@ -1454,7 +1454,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx) num_chunks); ctx->progress = start_delayed_progress( progress_title.buf, - num_chunks * ctx->commits.nr); + (uint64_t)num_chunks * ctx->commits.nr); } write_graph_chunk_fanout(f, ctx); write_graph_chunk_oids(f, hashsz, ctx); From patchwork Mon Nov 4 09:59:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elia Pinto X-Patchwork-Id: 11225317 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4E5B213A4 for ; Mon, 4 Nov 2019 09:59:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 299EB222D0 for ; Mon, 4 Nov 2019 09:59:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="P7xVu1pN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727913AbfKDJ7r (ORCPT ); Mon, 4 Nov 2019 04:59:47 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:42922 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727499AbfKDJ7q (ORCPT ); Mon, 4 Nov 2019 04:59:46 -0500 Received: by mail-wr1-f68.google.com with SMTP id a15so16248010wrf.9 for ; Mon, 04 Nov 2019 01:59:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZBEGzfb22bgr9/a5p7Q6yLV+a10GeNAN2KIKVQl/ebI=; b=P7xVu1pN1h72z/PNBk6pnfq3TE8f9ksAtoL+qAh80zweXvUj8dzJphDUQ2rRXkcwJ8 W3mhpm2GYSoZ7W9QYl3nY5BxWZz6Lrx2TMtrDZoTObQJ01tfNFRN2Yw/SWZjNZ+kXdA9 UCtzh2AoH0Bj/E/29OVtJZUhDTkLvHG8BLXplW/B3xYlpeNO0FL0ahSM3jap94Yf8QQ1 FsBdIq7mDU9uI8pE85zaU1ts2b2chNke1vJUeAid0RgVOlka5a2QDEXwo7icRc+HtKiM WvPH/kavmcbsICg0cMEY/5+P91neaG5weInTHIJ/LnvPiFe3TxfJcpqpO0pPyKDpJ4ZT wJWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZBEGzfb22bgr9/a5p7Q6yLV+a10GeNAN2KIKVQl/ebI=; b=pf0r5UTPZodqAz7YEgrT0Au5z5rq8NzdKMep+JmZVbFJNWxeIA2wsvKs/xMEMO67Nw VhDingBXjaqjFV1fWGIlmIjgmwQo5JJ8LrqUnmOPTY6ugbZGnf7un0dMrhQ9LrMFCmZJ RSrPs+Gz+LhC4CgdZjQfqB9LU/w/kuY+FaC7ADUFUmrbCQ8K6pkEh0CX9rkaQlEWpbTs XtpsbhK/7fn54o7n5sxbZMT6wKdoMuTSK/8RPYodNlb4JLSC/IZYe+KN7yzDyQwur9FL JjjQ174ZuPJXUd10XFAIr8+18i/IYXlUZcDZ/Aq9Gk4+OlkfoExWgJZxtxZIpAFe2tUn hG1g== X-Gm-Message-State: APjAAAUvqkSXCY88PHmK0NZo7Wj/2c7Vaevlpz2p8VH/OIg6b5gcfy3n +rNl/XLUOifpMthCWeiF3UrxcQXOBw32jLpa X-Google-Smtp-Source: APXvYqzVDWopMVzWX7kpSTVGF/7keHbGObC13cWEt+j5GtL6yoN7w02qW95KgiXYAP8ySKB9G9U5fg== X-Received: by 2002:adf:e542:: with SMTP id z2mr20697341wrm.338.1572861584473; Mon, 04 Nov 2019 01:59:44 -0800 (PST) Received: from ubuntu2pinto.pd5x2phgis1evm2itoce0l41ib.ax.internal.cloudapp.net ([13.81.118.113]) by smtp.gmail.com with ESMTPSA id j22sm23382554wrd.41.2019.11.04.01.59.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2019 01:59:43 -0800 (PST) From: Elia Pinto To: git@vger.kernel.org Cc: Elia Pinto Subject: [PATCH 32/32] date.c: fix code that may overflow 'int' before it is converted to 'time_t' Date: Mon, 4 Nov 2019 09:59:23 +0000 Message-Id: <20191104095923.116086-3-gitter.spiros@gmail.com> X-Mailer: git-send-email 2.24.0.rc0.467.g566ccdd3e4.dirty In-Reply-To: <20191104095923.116086-1-gitter.spiros@gmail.com> References: <20191104095923.116086-1-gitter.spiros@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix the LGTM warning fired by the rule that finds code that could convert the result of an integer multiplication to a larger type. Since the conversion applies after the multiplication, arithmetic overflow may still occur. Signed-off-by: Elia Pinto --- date.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/date.c b/date.c index 041db7db4e..b8dcbdbb0e 100644 --- a/date.c +++ b/date.c @@ -1172,7 +1172,7 @@ static const char *approxidate_alpha(const char *date, struct tm *tm, struct tm while (tl->type) { int len = strlen(tl->type); if (match_string(date, tl->type) >= len-1) { - update_tm(tm, now, tl->length * *num); + update_tm(tm, now, (time_t)tl->length * *num); *num = 0; *touched = 1; return end;