From patchwork Tue Mar 25 23:32:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 14029633 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1CD531EB5DD for ; Tue, 25 Mar 2025 23:32:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742945540; cv=none; b=TTUknouxVZ7WSq9qmuvwmIYszCGey2ejHJEoUUsnTmrTpJgW/bqGF+ubWG6omlIHIpkfe9D/whKWKv3PMxK8Bw9i/IJpg4wEcmkpF0PE4xc1LDwYg9XAzLl/3KROYtB1TAaISkbEvM43ocDRGcixSAHKEQhq6p4+k8cVKkf/yQM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742945540; c=relaxed/simple; bh=beia6WAgB33vVVZmnoTF98obrdZVu6Hz2GSVzDLnato=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=uVv5RNUNCkBmrgsqhrceAD9IE+Dxe1H3Lb17d3YNpqvkL4cnraGGSJWJsb1UhRkQOqPOTilbPHsJSUc9ZpFYKOBzJBqLLS4H5+DqVrQPbh6TCDX8Y5YLRqEOCcnvGfi9Pydeyjw+/AKjuI0WYPVhTwWeTi0WaLSbgPvx6VZhRMc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Odu42Dgy; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Odu42Dgy" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4393dc02b78so44673685e9.3 for ; Tue, 25 Mar 2025 16:32:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742945537; x=1743550337; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=0n8JRLlE/3sP02WOiOTD1GD/rQeYj+RlHtCWwaEejuw=; b=Odu42Dgy7is+GqX5m487gx0+xc7OetvHh2ibZNcLQFRfZcA9xYBlypqKZUJp0mDrET bcqTxkivxLpxnWgQ15/fxupfQ6OZV0AgV/XggU+FL3YuaSxFi+AJmxb9xgrCzJLwDTqh VuVAVgG5ylPiNfopvVIQZGLg1uT5FxqVPWOOp28TNTSLnSNFZhNQxgCRzHZBI+3akvNy OYcjgtClr9f5DeUPRAQZmC1csHTfVk20KnBHeez3fHZl6xSGYSLO67IOp/7c9xc4p0Kb aUANOqSRFmlLKv/+InxryuggDXPo+epnxNClr/FL57J1Gq2mMl0hL8gQNZ2bsnYlgvVP ciuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742945537; x=1743550337; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0n8JRLlE/3sP02WOiOTD1GD/rQeYj+RlHtCWwaEejuw=; b=R/M6KK0k5+b+KB9lPWV6OQOTRsiMYsAX7irjkIvrMTbLQ+JJ6Wc3q+suvzvwisIQLO w/efIv854AntQrj7nA96wSxN6UhRPpAoz8d3ybeeg+JeZSc+/nmAKSgDlrhHYpwzzgCf I83mtOkcbXhYxupjBs1B7GcYPJsf5fCfkp6QLl1TcrqjLD10GD+JHywy7CXAHbFseGRh tqMIdHRQOFLJOgV9Q1qGx6yrN4Q5hq1YJxuNubiqdjAT2xbZTDrHmfbkL9voLsHHPO4g 5WSXbL70f6IDHqV5OxL48wF8huEfzN7JAS7lxqyIwmydjjn6edoAgXxKKbjRQpKzo95t T0+g== X-Gm-Message-State: AOJu0Yz/S2WLE4jcuqAiTbDd1lIvaRBy1Ljd+0RAHjXdhaPporD+mSYb G2oO4L/LFU+638ue02DORvYC8GNA+AvaemE6Se5FQHZpB659PIQeLFtpcA== X-Gm-Gg: ASbGncvAYIZgDa4KFU1fjfKNf8CwbyOeyJt5FMR+Fy+1rFvLxdDYI7mwFCHAFg3W7vU BxZHF6jc0tUC6Il9XE9nbrOP4lsFWKoDUx+h1sJIYDWZV0VqkHw1JdfYC7VfWkP9OEX8coGoNOA +hPNRPuGSVdLQrjZUkmNs/cslQIXkX4yiv1rHieeyOSqJOd9YZOOeQizuoNsJnCm5ucPxufM01v 7MX3UdM4xP+S71r/Pg7AzwORqlfzdgkUkg+jVfHf3y7yGvzviQ4s8SvCU6Inr8UgAzATCV9ZaS4 pihv7TwWD3BQzVqTlG6//SfRP0lytXdGREoX2sq8oI8v0w== X-Google-Smtp-Source: AGHT+IFpRXnBN+aTrGexeHWsgPIwhXCQv95hKxzHmNMtrAJCRQUMhLqNO9iZbOMqg0oZdlymAWN/Eg== X-Received: by 2002:a05:600c:1f8b:b0:43c:f1b8:16ad with SMTP id 5b1f17b1804b1-43d50a4a938mr200372445e9.30.1742945536560; Tue, 25 Mar 2025 16:32:16 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43d4fdbd348sm164835035e9.39.2025.03.25.16.32.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Mar 2025 16:32:16 -0700 (PDT) Message-Id: <913c7a0d29699c2bd80fefcdc00879c400f1e7db.1742945534.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 25 Mar 2025 23:32:05 +0000 Subject: [PATCH v2 01/10] remote-curl: avoid using the comma operator unnecessarily Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Philip Oakley , Patrick Steinhardt , Phillip Wood , Karthik Nayak , Jeff King , Johannes Schindelin , Johannes Schindelin From: Johannes Schindelin From: Johannes Schindelin The comma operator is a somewhat obscure C feature that is often used by mistake and can even cause unintentional code flow. Better use a semicolon instead. Signed-off-by: Johannes Schindelin --- remote-curl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/remote-curl.c b/remote-curl.c index 1273507a96c..590b228f67f 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -1239,7 +1239,7 @@ static int fetch_git(struct discovery *heads, packet_buf_flush(&preamble); memset(&rpc, 0, sizeof(rpc)); - rpc.service_name = "git-upload-pack", + rpc.service_name = "git-upload-pack"; rpc.gzip_request = 1; err = rpc_service(&rpc, heads, args.v, &preamble, &rpc_result); @@ -1401,7 +1401,7 @@ static int push_git(struct discovery *heads, int nr_spec, const char **specs) packet_buf_flush(&preamble); memset(&rpc, 0, sizeof(rpc)); - rpc.service_name = "git-receive-pack", + rpc.service_name = "git-receive-pack"; err = rpc_service(&rpc, heads, args.v, &preamble, &rpc_result); if (rpc_result.len) From patchwork Tue Mar 25 23:32:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 14029634 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0EE001F12F9 for ; Tue, 25 Mar 2025 23:32:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742945541; cv=none; b=mmnqY59xSR/GQvPZUC88UyW6OZEOepCOF6jGrSi3UIISX6Qk5Nkz9/vZ6ZgRqTDQkbSLscxXedpBiMeCgFP98PXorbGg+ymwJQX6yqaCOoN1tkkm81PfNNE9gHn8t7yp7QaGP5/9ip3kK5lajD15mSLhONy89O/lUvnv3IVuCvI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742945541; c=relaxed/simple; bh=5eDboXlLY48klQSRh7ROAxKsGF5oZ0kBcpqQ2u9roxg=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=aGPIEe7sOKsujhNrd27HxDz4J8WnnQdjDxsRHFkMiP2Ic+DPH9fguBtrypzzzCUpe/adCkAbO0nl83UAzGSUldn5j/9L3fjLQ1Hu/I8dWiCIs0ETQadVov5Z2gE+2uW+huZo399W9cW8ZxmHtFa0QdrSWEdI3j4GdK1MPQy4jFs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Z2MyLR/u; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Z2MyLR/u" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-3996af42857so207479f8f.0 for ; Tue, 25 Mar 2025 16:32:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742945538; x=1743550338; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=1nZguIGcg25DdMGIUwc0IS/mZSObQwqLnttu/HYceu4=; b=Z2MyLR/uHua/4h6wHhsNmw7p6Sd4etvpctYEpXpo/4EVxCnHcLtZYgam9m5uRKjXLn 5HQwDQcQ3f5f3QqtyWRmWDdDkXA46PC13q4S0gRRfO6FGij1/PxQU4in/exUFnyZH6qZ VWccM0r16j/9t4jTS0QFMNDmgzEK/df23fqzqpixWCtWVsOe2XAAqj42x0JXKgiZFJuC 2i/oz5LQT8C6qp9C8LMDIlWUn+y63MAKtqIF4oGuhqt9pwSdFgclAfCSVZEXnnk9eGwN HvW+u6VVTyAY0eHUYitp3n1h9bGydmCzs833anqdOkB3kK2tYsRKLCrkTutbWDkIaepH 7V1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742945538; x=1743550338; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1nZguIGcg25DdMGIUwc0IS/mZSObQwqLnttu/HYceu4=; b=ndGnKory19K4XtKxFKGHbOy615EgXjacZAredI3/VHfTU5mxCMqbCda3OB3WPMJH8A I+Y6sQ9eCREreGoVX+B1ladpUvhGZ1GaO5JBCfUPgdo7dc+yykOzSTEh0+6WYUJlIT1Q /s+zC40rFwWIu9qrCvYI2J64glxPf1Dk3SClHodaWRPK1JH/xdhw3PMDjLBI1RBhQC8i s4xOJUAsgOBfPi1n46iTQFQQJUlHglGX8+FF1gtSL4YJqqxJL1Enemd3HrRn+O66HMMP ilSUzCRFdff62FoXOSyUr/s8PV2ddwzWDBHCeQLLZWcLk67sRJLqT/ZNPblnuE7SHCks XuVg== X-Gm-Message-State: AOJu0YwSlAve2v91eRE2S1RU+wb4rZl61o1i0G4m2FXLwDG0uRRMqYA8 cqHtnrCS3QegVkk+bkhOI1oBL/71fPhAldL1YPGcOUHloEdW6k0f0uxYLA== X-Gm-Gg: ASbGncuvw/ND0U8qY6Vn/VnuXnmtglRhemjs5XS70vGS9d1BvnduJ/HTy75f++qDlua sAMAev2GOaax+iTkamL6w1k3HRq5oHIOWvBbWCa4VSlPb2qRwf6y5ZgRu+OPjDUh7Uw/ooI4aMa EErYtYYF0ZLJHG0GIUCU/9gcngRBCRPsAHPbXAtxPwXCxTWVe9KKFGMoLB9+JC86NJ8ZsxM3cgm aCIAc40TslD3JWaN/GyAJ/heZrJZ3XRzf5IGCLmrlTL+De2Z28Tc9NE2peY7rQ1QIbPjtFhQxmm A2p2ET+ceItY/vwdDc28A+IhYo3pJiZINCZ2f0fwKITq+mcR/9Z3kMS9 X-Google-Smtp-Source: AGHT+IHGHXqcSYOEgE9U3GlG9Zo39R69pVms+QwfQOa0wf+MkTeVdFppuIqltswTGE79mz3YOsVG8A== X-Received: by 2002:a05:6000:2112:b0:391:2a79:a110 with SMTP id ffacd0b85a97d-39acc48cb13mr1238563f8f.29.1742945538007; Tue, 25 Mar 2025 16:32:18 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3997f9efc9bsm14776528f8f.87.2025.03.25.16.32.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Mar 2025 16:32:16 -0700 (PDT) Message-Id: <37ff88b8275cf4d6b0c715a99f4572e70d6e3729.1742945534.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 25 Mar 2025 23:32:06 +0000 Subject: [PATCH v2 02/10] rebase: avoid using the comma operator unnecessarily Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Philip Oakley , Patrick Steinhardt , Phillip Wood , Karthik Nayak , Jeff King , Johannes Schindelin , Johannes Schindelin From: Johannes Schindelin From: Johannes Schindelin The comma operator is a somewhat obscure C feature that is often used by mistake and can even cause unintentional code flow. Better use a semicolon instead. Signed-off-by: Johannes Schindelin --- builtin/rebase.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index d4715ed35d7..62bdf7276f7 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -1843,7 +1843,7 @@ int cmd_rebase(int argc, strbuf_addf(&msg, "%s (start): checkout %s", options.reflog_action, options.onto_name); ropts.oid = &options.onto->object.oid; - ropts.orig_head = &options.orig_head->object.oid, + ropts.orig_head = &options.orig_head->object.oid; ropts.flags = RESET_HEAD_DETACH | RESET_ORIG_HEAD | RESET_HEAD_RUN_POST_CHECKOUT_HOOK; ropts.head_msg = msg.buf; From patchwork Tue Mar 25 23:32:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 14029635 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6566A269D17 for ; Tue, 25 Mar 2025 23:32:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742945543; cv=none; b=dF8E7yt/gYHZaOwBQENMdsvw5aS4sncbhEAqc1yUxAeE/bgbKt/ENfbSjryg37sL/y+YawIHw3PvUCsprh+SQmYXhg5UoyHryaP+l1JETxVYULuScn2Xy5ZYZgUnDcz27/KQltuesFtddk/EwFaYMWR8HapFhC7R1GbVi1gvuNs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742945543; c=relaxed/simple; bh=Rx+IWFiOi9U+zBq+NO8Yynl5AN1JAJZERx/mjKSB+Dw=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=a6fJXsvClvBuMWFaADcKprz1bII0r79w8omRZr/xDRSnxxzSC8QMMPugCc2Ex73WDLVc205XuEQxr/fqD4CuhVG1OFvirjDr5zf4Oj+pQzD9i1d0X6CCLFENmUcsQIwntKrpnwYbxsDkmc09WHi+etVypW/1SD0XCwKVLQ4yh40= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DsPKPlIy; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DsPKPlIy" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-43cfa7e7f54so1941135e9.1 for ; Tue, 25 Mar 2025 16:32:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742945539; x=1743550339; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=NX862AUOw2XXDICLlVHZCE9L8Px+F8OVvarM9gB1oFU=; b=DsPKPlIyzLxAr5N2r8jvXA2M1y81pJV2Oar6wzmDD7RLsPN3kbNs6PJgDkbHrMWKpr 7CUK+RazPADxWUY08sou595anpPhL+RdOg3291A14sqFyCMUFi8GNX+n5PYqdp0WVIpV aBxAtMswyhLMod0gm85U7E9HFnc0XHpjV/aXDPoDAJ9Kn6rqz26WaMPp3GgKT+MumQ+/ Oh7oq/Z+Yo3gEoFpzcqlgFGPtDpx4aINvenAXSHAwsYoQUUHrDgOnyv9mQ3H3h4Ws1/O Wj1U44FSK0y2EWebuV7RcfETKW//CPdCDVf+Z617KEcoFnQkYL7sZc4ZuPPSznTLfYwo bNmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742945539; x=1743550339; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NX862AUOw2XXDICLlVHZCE9L8Px+F8OVvarM9gB1oFU=; b=dOA2kYUO1GcA5Mia6RM+F+7jRGp3DgGPU1NMjBz5jkCAlj4+TEHMToGaND8UZX+UhX P9JBqeVvv2vqH8KJDhml3DZpf4HBI/y6yJC9NQRICozI42+PAgyd+qtyaJAqzpQDgaXL hDnDxZr6A1KcYBXcjQB9SCmsJZbGcIjfqXUtAaAM91NJII6BIGSb/P1DiyCkY331j9yS GeKUY68505qmCJoYPOH4QrWKpaG/yHCvZDSvT2Cez5zyLjw6W+AWTkFVbA0zRrNBKB6N bRBP/gd0vHAZqSJLw4XEGjb8VD/vwL3bNskO3mTWZnBQ9sy9gpKp0hBAHF1Vzyxm2kAY DPVQ== X-Gm-Message-State: AOJu0YwNjTZm5bdXVgtuZkYUOS7UpIp2j6FjipiBT0pZn3gnEo0SkR2K h0+fb56VUfURYTYDLmwNhqBgDydbgNR3QBE0lTSlLUKoTC2TYSiY82/aaQ== X-Gm-Gg: ASbGncuviRdB3wZzIFekdMlLUzeoQ+Oc251JOJAJS+L4Z9bzIZgzppMH9yD8vZ1I6ho 8CyZSkCraqUdiKRRYRN8aix823Eysr2f7qeAXvG9sSJ1zmK8c4Xg+O+XfBiKusjEgA/dzW3zYyK mnWoKSDQ+vbM/QUs8NOixI5f1pe1GLD8AJ1TC1GS5oEsB/EoXMy3RF8Q5inEUiH2tAXFrbqfGrR WdpznASdAfgigds4j3pVZ/BDdxOEzH4MC0sVIt7a130TMBCECZNgfgDDQOBrQ2nPw8Gr9XsDe9L A5bPEc5Ee3J99UjABxapGHWL+4IYPSHPMUr8qGNpbQYTJw== X-Google-Smtp-Source: AGHT+IGbTXf4mEUZ/F3loGpZr5RlXQPiGLDawEbaU4BtULlqpjPN+uWwNmBF2VtQrjAtamHRud1xPA== X-Received: by 2002:a05:600c:b91:b0:439:9434:4f3b with SMTP id 5b1f17b1804b1-43d775fac8bmr17019145e9.8.1742945539033; Tue, 25 Mar 2025 16:32:19 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3997f9a5b66sm14817620f8f.40.2025.03.25.16.32.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Mar 2025 16:32:18 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Tue, 25 Mar 2025 23:32:07 +0000 Subject: [PATCH v2 03/10] kwset: avoid using the comma operator unnecessarily Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Philip Oakley , Patrick Steinhardt , Phillip Wood , Karthik Nayak , Jeff King , Johannes Schindelin , Johannes Schindelin From: Johannes Schindelin From: Johannes Schindelin The comma operator is a somewhat obscure C feature that is often used by mistake and can even cause unintentional code flow. Better use a semicolon instead. Signed-off-by: Johannes Schindelin --- kwset.c | 54 +++++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/kwset.c b/kwset.c index 1714eada608..064329434e5 100644 --- a/kwset.c +++ b/kwset.c @@ -197,10 +197,13 @@ kwsincr (kwset_t kws, char const *text, size_t len) while (link && label != link->label) { links[depth] = link; - if (label < link->label) - dirs[depth++] = L, link = link->llink; - else - dirs[depth++] = R, link = link->rlink; + if (label < link->label) { + dirs[depth++] = L; + link = link->llink; + } else { + dirs[depth++] = R; + link = link->rlink; + } } /* The current character doesn't have an outgoing link at @@ -257,14 +260,14 @@ kwsincr (kwset_t kws, char const *text, size_t len) switch (dirs[depth + 1]) { case L: - r = links[depth], t = r->llink, rl = t->rlink; - t->rlink = r, r->llink = rl; + r = links[depth]; t = r->llink; rl = t->rlink; + t->rlink = r; r->llink = rl; t->balance = r->balance = 0; break; case R: - r = links[depth], l = r->llink, t = l->rlink; - rl = t->rlink, lr = t->llink; - t->llink = l, l->rlink = lr, t->rlink = r, r->llink = rl; + r = links[depth]; l = r->llink; t = l->rlink; + rl = t->rlink; lr = t->llink; + t->llink = l; l->rlink = lr; t->rlink = r; r->llink = rl; l->balance = t->balance != 1 ? 0 : -1; r->balance = t->balance != (char) -1 ? 0 : 1; t->balance = 0; @@ -277,14 +280,14 @@ kwsincr (kwset_t kws, char const *text, size_t len) switch (dirs[depth + 1]) { case R: - l = links[depth], t = l->rlink, lr = t->llink; - t->llink = l, l->rlink = lr; + l = links[depth]; t = l->rlink; lr = t->llink; + t->llink = l; l->rlink = lr; t->balance = l->balance = 0; break; case L: - l = links[depth], r = l->rlink, t = r->llink; - lr = t->llink, rl = t->rlink; - t->llink = l, l->rlink = lr, t->rlink = r, r->llink = rl; + l = links[depth]; r = l->rlink; t = r->llink; + lr = t->llink; rl = t->rlink; + t->llink = l; l->rlink = lr; t->rlink = r; r->llink = rl; l->balance = t->balance != 1 ? 0 : -1; r->balance = t->balance != (char) -1 ? 0 : 1; t->balance = 0; @@ -567,22 +570,22 @@ bmexec (kwset_t kws, char const *text, size_t size) { while (tp <= ep) { - d = d1[U(tp[-1])], tp += d; - d = d1[U(tp[-1])], tp += d; + d = d1[U(tp[-1])]; tp += d; + d = d1[U(tp[-1])]; tp += d; if (d == 0) goto found; - d = d1[U(tp[-1])], tp += d; - d = d1[U(tp[-1])], tp += d; - d = d1[U(tp[-1])], tp += d; + d = d1[U(tp[-1])]; tp += d; + d = d1[U(tp[-1])]; tp += d; + d = d1[U(tp[-1])]; tp += d; if (d == 0) goto found; - d = d1[U(tp[-1])], tp += d; - d = d1[U(tp[-1])], tp += d; - d = d1[U(tp[-1])], tp += d; + d = d1[U(tp[-1])]; tp += d; + d = d1[U(tp[-1])]; tp += d; + d = d1[U(tp[-1])]; tp += d; if (d == 0) goto found; - d = d1[U(tp[-1])], tp += d; - d = d1[U(tp[-1])], tp += d; + d = d1[U(tp[-1])]; tp += d; + d = d1[U(tp[-1])]; tp += d; } break; found: @@ -649,7 +652,8 @@ cwexec (kwset_t kws, char const *text, size_t len, struct kwsmatch *kwsmatch) mch = NULL; else { - mch = text, accept = kwset->trie; + mch = text; + accept = kwset->trie; goto match; } From patchwork Tue Mar 25 23:32:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 14029636 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EEC4026A1A1 for ; Tue, 25 Mar 2025 23:32:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742945543; cv=none; b=toUYD03wemXYNWx54Pk00bTd4M1CS6XEj24SiosjMaaRB/c1BW+x8OIqKVvd4LFZcv1usPFzfjyz2FR2d8DG/IAggjows+mQ90SSgW9JYr9zG5vRtYV4Xdz/9+i6jgV5L+dbK9ivl4BLeUuXOxfEXl9gcspgv0BdEkPblcOJymQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742945543; c=relaxed/simple; bh=Pv9V94JOWDm/C5Hfi8rcT7S7ttM3/YIay+Hx1jlbqkA=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=P5Kh6Eqy/SvnKZQVvr1Kq3v1YlM/dJAjnKIdPRsQnHau0UaIl8qlNOPebNHPkPcpTsfNhuyQWAC5cA8rLVzsysz2Ap7auq05St5Ne160SJiwYOKVOzpWOTjhntHM1lh2aOwrXw0h94P1URfAQsCQI1hiDBDIWka4mkzia3xP78k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gewfesvS; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gewfesvS" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4393dc02b78so44673875e9.3 for ; Tue, 25 Mar 2025 16:32:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742945540; x=1743550340; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=+4IkiO6Glu7VZfepMK9AHTcNaz7euwVLDLmIH1KpWls=; b=gewfesvSZz/b2u7uFJo1Ng1KXsCxjb0Qcf/MBnHDeaDIgvrPl3875xS/uy/dhw5P3R zm0itfk0KC/KdjZPaNw5ywjg2lNO5oTtHEiPzM805wsD6IZwiKMh70PzQK/y1nzUUF0f GYvgFNrCUG0+ies7kXc+ZUk9SlqO0SGGuscR84wtytNULdUGyRG9VJs7og1sgo07xqaD 7EsqFYNwzPIj+xZRX3UaVIH5mzR1/rzGUbDsGv2ukFFZNNCCR8LveH3tZbdDZbakMC2x RvxyaZLx6HEcX24xzOcym7OklKLeV3Flj6TcAC3bhaV6d+53avQp5VpXpkjd1uHlzQa4 evdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742945540; x=1743550340; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+4IkiO6Glu7VZfepMK9AHTcNaz7euwVLDLmIH1KpWls=; b=C8v18yRefLUxBwDFZPxrXBgwdUPkFaaRmYAzfJhYL6Fy5HNCJRo52GIawcZkFG8Gqz MAAguU/PfcS5yq+GKINyhygJVTfyRw8zkOPi/vnuV5+2F1+ITb7vQoy1sf55hcLlpiHw eb2kffKKZZzcRBUek8NikHoNMXUvS5CCUIcUjWJEclGxj3KnTEmHI/mtbYorZ7WXoJw4 NjbHHpUIngsdUtZPBX8jPWM9runs2zv2vwLMdDtkj3xxI5iSGQzaWMybQM5KT6FHOzMb 9IALsbc2ePmzpkabA2VZ7d+0m0o5TyX0hPjmmOcADD310+zG36Y88RYzLNqF9Pyh2wML w9Bw== X-Gm-Message-State: AOJu0YzK0u//qf0OsJWOtkCkANwEaKYRAtwapaPVRLch5Yyp6hIFKQV0 1nrw69fL40RIGiaJMxJeUv8rqNYQEw77d47uVQrRI9QbjqbN7WCzI602ww== X-Gm-Gg: ASbGncvidbR8ImEXQGPMYp0t48GexS2BQp7C07fBOQDv2l0/DH9Jn1/Ix5qNhWj6i04 QbvYWS4Kw7+9Vr06FAeMTDhrZb2gmJA0YzfuTVmN/XR3PhGR2mF4WFKUFCy9HioBf3CGnAnxn9h z4tWtH3yJA+K0CZVMDS5fcoHvhA7Zy0IVJWzbnruJUu4/vXJCTBSpJbNayJ1ZHIWbB0BQwBJWPS 7lkZOMT/zyxR4smGK5Y9bg/ocfCHf0I+uICESHxkYx07LvxSHfE/HOxOtNmTBMuUQvELGOIvP9A 64D09gR7s0ll1C+pj8E4ogQTaViwVK0Md7DUqPjLehgZOQ== X-Google-Smtp-Source: AGHT+IGdyCODlzKNGX8wlRBjT6FdMp4yxhu/hFpSjErEZTjNpXGerT0Crs3QY5bc2e4SGDaoFI9OkQ== X-Received: by 2002:a05:600c:1989:b0:43c:fe90:1279 with SMTP id 5b1f17b1804b1-43d50a21402mr121537445e9.21.1742945539797; Tue, 25 Mar 2025 16:32:19 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43d4fcea400sm165719055e9.2.2025.03.25.16.32.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Mar 2025 16:32:19 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Tue, 25 Mar 2025 23:32:08 +0000 Subject: [PATCH v2 04/10] clar: avoid using the comma operator unnecessarily Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Philip Oakley , Patrick Steinhardt , Phillip Wood , Karthik Nayak , Jeff King , Johannes Schindelin , Johannes Schindelin From: Johannes Schindelin From: Johannes Schindelin The comma operator is a somewhat obscure C feature that is often used by mistake and can even cause unintentional code flow. In this instance, it makes the code harder to read than necessary, too. Better use a semicolon instead. Signed-off-by: Johannes Schindelin --- t/unit-tests/clar/clar/fs.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/t/unit-tests/clar/clar/fs.h b/t/unit-tests/clar/clar/fs.h index 8b206179fc4..2203743fb48 100644 --- a/t/unit-tests/clar/clar/fs.h +++ b/t/unit-tests/clar/clar/fs.h @@ -376,9 +376,12 @@ fs_copydir_helper(const char *source, const char *dest, int dest_mode) mkdir(dest, dest_mode); cl_assert_(source_dir = opendir(source), "Could not open source dir"); - while ((d = (errno = 0, readdir(source_dir))) != NULL) { + for (;;) { char *child; + errno = 0; + if ((d = readdir(source_dir)) == NULL) + break; if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, "..")) continue; @@ -479,9 +482,12 @@ fs_rmdir_helper(const char *path) struct dirent *d; cl_assert_(dir = opendir(path), "Could not open dir"); - while ((d = (errno = 0, readdir(dir))) != NULL) { + for (;;) { char *child; + errno = 0; + if ((d = readdir(dir)) == NULL) + break; if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, "..")) continue; From patchwork Tue Mar 25 23:32:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 14029637 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C82E26A089 for ; Tue, 25 Mar 2025 23:32:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742945544; cv=none; b=nK5c+l//0JTvxT1fjYXeXPAqCvLHpLL3H4HTV8c/zAHNmnA0vBZ6x0HouRNl0O4Dp4Zhx5O3feBwLK/QavkMjCWPHOI9noxKq8Gws8qNUFuYkbvud5GCzi1SvWUR0kz2qVDWeVj+226kjhm5A2F2asdyl3djYEVtMZZCu76V0Ps= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742945544; c=relaxed/simple; bh=1E2MIPGvJpZILgeR+y80nHde8v/+QmHjrMnRhTe5LRw=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=rpnk4y6ng3nrkEYmikih4omTqP1iRppDIWBLMOxWY0qVcI6zBxvS/vWzVEqZpjn3AryOSDf15oR3bHAQLRr8BXTNSTWTjBhqPe5pn4kyXJVDAQ0I+cSCNAWdELkGzqEfBN7NrYf2KNqrsVu3l9bOeyIDnP9klcdJc4K3Pdf+lnc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=femsx/J/; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="femsx/J/" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-43cf848528aso51925645e9.2 for ; Tue, 25 Mar 2025 16:32:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742945540; x=1743550340; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=zyKGogoHxgJZ9S+q2w13V3Jagh0709TpjxDMNF9xpPQ=; b=femsx/J/fvA2JY1LMMndY02ObA8hHDHcW+SKMiuyvScPiVqUhJA7mmsI7NfMWve4Vn eMxoKk5QRWJ+owsJfCZeQK9ey5lkpPvhO6ra0irDmKi1mLW+nfaf0uyODZRQe66R5fw3 xYM3lWORIITs63fHLVYyki9tbmzMiQHqmHDB/fJbXBxSEMwN7v+OyxCCESvNz5kjRe9R g55LWpuAtBwAkV9acIU6MgNKXMb51iI068/OGmzDwZSunMvRuTinix4bAkLfMCCmXMxr dah894xHeYcqjI/6L8MUwhu34pcmcwzND7/JYZs50ocHTJRgdhEA2IDjRMdu1GK9PhMs pfyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742945540; x=1743550340; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zyKGogoHxgJZ9S+q2w13V3Jagh0709TpjxDMNF9xpPQ=; b=jwcih0EHMJ3PeeOKxegex1BmAwxuYK0vbvhTFQIfldM6I20TPTVxojx3A84YhYBYwR vBD+mGvV7/VqaYs/vBEX84LFOTZXkiJdumNh89g6CbdzEd2DGb8oX8nmkAB2PHsKa07e FiNynJeTH+/6zjOZPgLRXdP24XsUmcNtyZYBmqs3ytrmJJor6kBPawzOqIRy+piZoRJS 06ruQW3e5linA40/ngcABo6xbNKSZQyxE/6flDAuT+ZJ2qA56tjpYq1r0xzgY6cZPKps 0lViZZ2CFOnlypyDxkLnfeglaksKREgfvnl+Ul5U/lItjlO3Qmoa5Q5t29ewH1nISs/2 EBOQ== X-Gm-Message-State: AOJu0Yw2NQeFWfEiR+x+wnX5YyxQkMT+IglOoUp04e5Bq8pmBTO/NXE5 8Ysl3zD5C0QgEbErr6R7RUgzcfhnj7Ah4RHdoAkZcbLy01bN4ZpjHhlKrQ== X-Gm-Gg: ASbGncsRqXSVMklwj8p441yHf5lQuKLsEQ8GeUHsBSi8vujahOTD/R9cVwfyy+MSG3i +X2R6o0/TL5VFiX4WH2vIgVzLAnTSXBiBqjs/TD/Tfd+xUcXdqMX0In5ejJkAyw0FZbopWLgXiO qPy24CYEb+6a2WPjOF0U2toikVpxCttjJ9A+eahL/dZaGvD4VUS7LT123mglERUA4rWKYVx77hv bOeHRA3p7QEz7JzYg2JppkDhGTVTebgJ4Eusi8FSLOml6JByavJqEcgwTGdoIr1iiuvNmoO5KB6 Gk9sA+uN8FVHq38Za9PNETbvbRM86HqYivCtc5Xeqh8nuEIgD9F9M9b0 X-Google-Smtp-Source: AGHT+IFHedwi5rTetGV49irT3VXDQmCCgSAMIB4LtZPFT/cK1ApbkhUSJKIRIZ0rJO+dUZS52rgSjA== X-Received: by 2002:a05:600c:3b1f:b0:43b:c284:5bc2 with SMTP id 5b1f17b1804b1-43d7836b764mr9330725e9.0.1742945540486; Tue, 25 Mar 2025 16:32:20 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43d4fd9ec84sm161860285e9.26.2025.03.25.16.32.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Mar 2025 16:32:20 -0700 (PDT) Message-Id: <7239078413f6a223105939af1b56e79b9d302f1f.1742945534.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 25 Mar 2025 23:32:09 +0000 Subject: [PATCH v2 05/10] xdiff: avoid using the comma operator unnecessarily Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Philip Oakley , Patrick Steinhardt , Phillip Wood , Karthik Nayak , Jeff King , Johannes Schindelin , Johannes Schindelin From: Johannes Schindelin From: Johannes Schindelin The comma operator is a somewhat obscure C feature that is often used by mistake and can even cause unintentional code flow. While the code in this patch used the comma operator intentionally (to avoid curly brackets around two statements, each, that want to be guarded by a condition), it is better to surround it with curly brackets and to use a semicolon instead. Signed-off-by: Johannes Schindelin --- xdiff/xdiffi.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/xdiff/xdiffi.c b/xdiff/xdiffi.c index 8889b8b62a1..5a96e36dfbe 100644 --- a/xdiff/xdiffi.c +++ b/xdiff/xdiffi.c @@ -211,8 +211,10 @@ static long xdl_split(unsigned long const *ha1, long off1, long lim1, for (d = fmax; d >= fmin; d -= 2) { i1 = XDL_MIN(kvdf[d], lim1); i2 = i1 - d; - if (lim2 < i2) - i1 = lim2 + d, i2 = lim2; + if (lim2 < i2) { + i1 = lim2 + d; + i2 = lim2; + } if (fbest < i1 + i2) { fbest = i1 + i2; fbest1 = i1; @@ -223,8 +225,10 @@ static long xdl_split(unsigned long const *ha1, long off1, long lim1, for (d = bmax; d >= bmin; d -= 2) { i1 = XDL_MAX(off1, kvdb[d]); i2 = i1 - d; - if (i2 < off2) - i1 = off2 + d, i2 = off2; + if (i2 < off2) { + i1 = off2 + d; + i2 = off2; + } if (i1 + i2 < bbest) { bbest = i1 + i2; bbest1 = i1; From patchwork Tue Mar 25 23:32:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 14029638 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 90CC626A09F for ; Tue, 25 Mar 2025 23:32:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742945545; cv=none; b=icaUWnHZw7BISTBwoSNeyMmK/PBdjwjXrWoziPv1hz2mknM4bHJ997n9nLRvG1aoQzb7EJpI0lNY+8VEqjV5VNbc/Qhk0tkot8euNLMcIKD8/VbSgWzbINqWISjcNDJvC65JEzA+wCdfNvJPSGNRLqOcw4O2o8hlOGu5GqK48Ig= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742945545; c=relaxed/simple; bh=WQbcE0p2PaGyzq+/CqF/4E9Lu4J+lRk0yEwi99iuCAw=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=OdJBr57vSUbYDlkWnw13/pRZ0b0hHtYmOo5ql/qS1z1iMIXMrbf1rC+ljmEhFN5BdD6AHtTDXV0fzCm+C5uF4rLJ0tzxTXrNL3FwhnTcza5lx6Cb6hiaTqGOnoBbIsWG8gMedXMvtL8YU6oVMimnBNl70WhBJiSNjyvVroi/yt8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QcOLbZzu; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QcOLbZzu" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-43ce71582e9so43194475e9.1 for ; Tue, 25 Mar 2025 16:32:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742945541; x=1743550341; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=EwNOiVATTsl2SGFPJSiFbDrs6C9cxGjObK2mMHHE7kc=; b=QcOLbZzuB1cooB/3u7mf2Ss1TD4BZUx/khUYY2zVfRoMhkocQ3lB4AOkuRQcU1NQgi qerBZER5tJBsUsqzxa+VhD2gSU0WRQ1TH8FkOx6w3URKK3B60FqrhYeRW5Ob2smjSJZM qtiEaO6SAcXcNUoKr69aW16jt+E5+UaciDQQRd2Yx3vW7LSXZxOL0RfkZImEDhTP6BN0 Ir7kxJMzcsSmXseI2ZLc8Ldv5e/hRGhaH1K6IEBqNdkc/37Yx6svMWDcw7fNGquicim/ dcmXWkXoI4b3fx/k7hZjv0o//ynokTXjlUu7jSvc0Tkv6C3DO9UlSO2ckibzfty31a/C H9QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742945541; x=1743550341; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EwNOiVATTsl2SGFPJSiFbDrs6C9cxGjObK2mMHHE7kc=; b=TSrPu6ziFZjaEQbfh95navodtj2jsJyBBUFPtufdGoD/ml+6mfcjSK5pnHLhB65RXN BfQS6bVAphh/ye1r7eEMbouMDy8SAqUalh+z9r4EhgnGKdSyo6LO8lo/GfLlAAbZ6Uk+ oGclzcJXFauniTqC7hYbNvK9SgKl8bKRNayc2+jEbqaFBk3xCzTTndAL0Dygb/jkCnf8 XY1UQD2xEg2VEi2aQr4yGhZ/gKqEv4KHFDwwpJKBTH84foJdicRBQUrwgeNfau/nyKux TubaPLTSyKLBZIXp/KsvedEz4f1Jw335bzc7Tq0rv6fvyNwHs6KYOiqNLdFBe9yEaOqk FLkA== X-Gm-Message-State: AOJu0YyIN3gnLxNhW711VnpGKfCnn4OBZp9vZtfZW7+Rv1P6p8DX7SoN zLWOq9Hou+wf0khlsJOiEUOYQDCCCGGv0RBaZhhIhyIrBxgOMJIU65w4sA== X-Gm-Gg: ASbGnctfuuA4gJIK59TC4GIPah0CR1T+axl2KuyE4mCxRl6uyqEaINpa5fcKv3hNiKl uc3dtJYPlDzQJ4ONEsmKErTumDKMSoIuWVfsN9R1m0ZNsgnpQ3ythDHN6l70Q0l1TY693lly8Cu OTlecYr4yDuL6d6cbkzTRdI/JpB1/iyPW/M3Sic9vM6OPUMs2oViasBgY9uaggcRM3/qgIx5L4o B0FgYWec2RJ96nCk2eRBik5TFb15o3qpadvbnUFxp1Qrg2k3AmhalJygCPfOJ/c9J0SQmSRTF9m LZ2Cg29PfLlkGTGzxOoO7hZplHFV35i73z6BjgI88t0zyw== X-Google-Smtp-Source: AGHT+IFAOltEw72o4vm/aRLslbLxfXf5VAZzoDLno/t0pTdtrUaqVch+Xkk1F/t2YNvxrL/GJ157Cg== X-Received: by 2002:a5d:5f85:0:b0:390:d6b0:b89 with SMTP id ffacd0b85a97d-3997f93c41fmr16550401f8f.50.1742945541474; Tue, 25 Mar 2025 16:32:21 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3997f9e65f0sm15116942f8f.74.2025.03.25.16.32.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Mar 2025 16:32:21 -0700 (PDT) Message-Id: <5e0e8325620395196608a0851f1f6fc9408f6090.1742945534.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 25 Mar 2025 23:32:10 +0000 Subject: [PATCH v2 06/10] diff-delta: explicitly mark intentional use of the comma operator Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Philip Oakley , Patrick Steinhardt , Phillip Wood , Karthik Nayak , Jeff King , Johannes Schindelin , Johannes Schindelin From: Johannes Schindelin From: Johannes Schindelin The comma operator is a somewhat obscure C feature that is often used by mistake and can even cause unintentional code flow. That is why the `-Wcomma` option of clang was introduced: To identify unintentional uses of the comma operator. Intentional uses include situations where one wants to avoid curly brackets around multiple statements that need to be guarded by a condition. This is the case here, as the repetitive nature of the statements is easier to see for a human reader this way. To mark this usage as intentional, the return value of the statement before the comma needs to be cast to `void`, which we do here. Signed-off-by: Johannes Schindelin --- diff-delta.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/diff-delta.c b/diff-delta.c index a4faf73829b..a03ba10b2be 100644 --- a/diff-delta.c +++ b/diff-delta.c @@ -439,18 +439,18 @@ create_delta(const struct delta_index *index, i = 0x80; if (moff & 0x000000ff) - out[outpos++] = moff >> 0, i |= 0x01; + (void)(out[outpos++] = moff >> 0), i |= 0x01; if (moff & 0x0000ff00) - out[outpos++] = moff >> 8, i |= 0x02; + (void)(out[outpos++] = moff >> 8), i |= 0x02; if (moff & 0x00ff0000) - out[outpos++] = moff >> 16, i |= 0x04; + (void)(out[outpos++] = moff >> 16), i |= 0x04; if (moff & 0xff000000) - out[outpos++] = moff >> 24, i |= 0x08; + (void)(out[outpos++] = moff >> 24), i |= 0x08; if (msize & 0x00ff) - out[outpos++] = msize >> 0, i |= 0x10; + (void)(out[outpos++] = msize >> 0), i |= 0x10; if (msize & 0xff00) - out[outpos++] = msize >> 8, i |= 0x20; + (void)(out[outpos++] = msize >> 8), i |= 0x20; *op = i; From patchwork Tue Mar 25 23:32:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 14029639 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3791269D17 for ; Tue, 25 Mar 2025 23:32:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742945546; cv=none; b=U6wGw7vzYsNKFUd8faY7BA3Vw1A8gMIpWsQkt+WtsweovtaYsizDpch6ZAUDenkYrK124nFwbFdRYxkN3ocBBLgfUDySthQXftlBRio4wuslY03zOq09ps94tu/pZzw70ghBBSkJDb71QBq/pDgeDyQuSh3ABiQgrx6fc6+w+CM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742945546; c=relaxed/simple; bh=CDKvEKQ72ZvfRX4UpUcQ61D9cSY/Mz66iuGBG+Kn29E=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=WBdLp/WcOGulx98Dtm3uuP1LPK3fBxr5ZgVENtPxiVlxP83YipdQgFSfAHBM9H85N9ZjbdZVtTe3IG6GzJY7KOy03wl3boFZnGjjD9iLSucSYOE4JU6kU4i0ms4GstqeZv1othtPd53G0GNj64VyzJTJUMGDNo8HQ/JHKLDR+pY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OmlKBZ1H; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OmlKBZ1H" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-43cf0d787eeso64734165e9.3 for ; Tue, 25 Mar 2025 16:32:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742945543; x=1743550343; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=91Ofi4EEKua14rkw4vA93jknHfMel2rpm0w1atB5pM0=; b=OmlKBZ1Hl7tHt0zJzO0EvayVHuJx4xaW0yGTh9p2EgUYi9eV2mRHk+LkOP+5NboIXx 4+KfFoFm54Vy+w5g9Gv8yBDfKEyvM2eH9Ha/Wvh7Gy78yZlb5SicSD6TO6pKNyqpVHhs SPTWnvojo0TeHjRCFNq7lMGOOQpkxcY6cL6wB2JmKnRadSGN6v5NGrBM0MPyt6wAgmGz 2CNLzIVX/3XwkqUl03GgfPt/T6FSvdEAHyv6810X8dYZie6xFG9KyQZwqwCowsqnm4Mm 87WmWmdTtZ4owwXaqX7JKevv4fcA06ySSEVqVYL0L3XwlYP9X7aOH7x/gvSBk0uOGhQA 6rsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742945543; x=1743550343; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=91Ofi4EEKua14rkw4vA93jknHfMel2rpm0w1atB5pM0=; b=tSjnekqLag9UuklEOKRnGy1//Lc5ub24KYIQ6kvrZa1n76p29gCCoBa5LU6oa9Wn8E M1pmJRtjge1fXsDXXLzftIeh3WMYdT3lwScBIpOtImI5UudEysC0L5ZzOSaeknkQf4UQ U6oJ0oeZPcFw6GBt+g8EnvfHElm3LRvQXu+5buQFC8stv4+fm7I4jl42zBqhUZe9AQIH resKg6n7Xav3Dbt3yaH8+sETtNY8a9/zu0yiUJbgzr1BKd4VAXj77NBL5iaFL0vaJaid 1bniWXLQk3mSJWt4u0t8I7EQExmCe60QCo3tDLOVXiGMGnshLtowUrs44XNBoFAMcwmm i2Ww== X-Gm-Message-State: AOJu0Yx0i8TkHhUP06mw5gubFxQv51hVNoCvW3cl8cMCo2DkqSSCNimt H0btzxnvR4F5k1KZmwA5nNcoxYN/gd/6PMYkygaui3SSxM5Y2H7fHFqgZw== X-Gm-Gg: ASbGncvKaILHrFOlK66PI3C95YQ5x7pYSJzzLE/IyM9CHZhAIhdk8N7eroUO1/N3XqS 8bi34bKdw8S0oF8TTb/SeF4tYcb4QHBkyyIFXZbZt3VGvOPk/tkmfr4DvR/tOIjctiqetC2CrR4 /tZCC1GCclFfF80T0KPWCf2DLdfSFdSOSftXaqMz5G9TsxMTBP3MGOTMk53Z9YT7vIhT7KllC/y 4Q16TnFhzCguvdAVOvcdgavI3/IEOA9tSMFmosZ1H8I8V7G1x/KjbvEfVy9q0xG5GYwsFbu4Vez X3B/rYPJaLrodSIOyjynuqEKQwQhCSeAoekTfTimIMMHVw== X-Google-Smtp-Source: AGHT+IG0AztcULwieNvpj5AVNzX1hYTJ6WXuRvd8iBsZe0duCU6sqxOaCcbfw2L9jtCBnQRZdXlNXg== X-Received: by 2002:a05:600c:a00d:b0:43c:fcbc:9680 with SMTP id 5b1f17b1804b1-43d50a3444fmr163908165e9.25.1742945542461; Tue, 25 Mar 2025 16:32:22 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43d43f556afsm213262665e9.19.2025.03.25.16.32.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Mar 2025 16:32:21 -0700 (PDT) Message-Id: <9a6de12b8076266fb0c88f6b658c20d37409ce13.1742945534.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 25 Mar 2025 23:32:11 +0000 Subject: [PATCH v2 07/10] wildmatch: explicitly mark intentional use of the comma operator Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Philip Oakley , Patrick Steinhardt , Phillip Wood , Karthik Nayak , Jeff King , Johannes Schindelin , Johannes Schindelin From: Johannes Schindelin From: Johannes Schindelin The comma operator is a somewhat obscure C feature that is often used by mistake and can even cause unintentional code flow. That is why the `-Wcomma` option of clang was introduced: To identify unintentional uses of the comma operator. To mark such a usage as intentional, the value needs to be cast to `void`, which we do here. In this instance, the usage is intentional because it allows storing the value of the current character as `prev_ch` before making the next character the current one, all of which happens in the loop condition that lets the loop stop at a closing bracket. The alternative to using the comma operator would be to move those assignments from the condition into the loop body; In this particular case that would require the assignments to either be duplicated or to introduce and use a `goto` target before the assignments, though, because the loop body contains a `continue` for the case where a character class is found that starts with `[:` but does not end in `:]` (and the assignments should occur even when that code path is taken). Signed-off-by: Johannes Schindelin --- wildmatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wildmatch.c b/wildmatch.c index 8ea29141bd7..ce8108a6d57 100644 --- a/wildmatch.c +++ b/wildmatch.c @@ -268,7 +268,7 @@ static int dowild(const uchar *p, const uchar *text, unsigned int flags) p_ch = 0; /* This makes "prev_ch" get set to 0. */ } else if (t_ch == p_ch) matched = 1; - } while (prev_ch = p_ch, (p_ch = *++p) != ']'); + } while ((void)(prev_ch = p_ch), (p_ch = *++p) != ']'); if (matched == negated || ((flags & WM_PATHNAME) && t_ch == '/')) return WM_NOMATCH; From patchwork Tue Mar 25 23:32:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 14029640 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF6AA26A1DA for ; Tue, 25 Mar 2025 23:32:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742945547; cv=none; b=uwSexG5P6AantWuKwPQpAbIqb65vFt40KQE4K7iVGxxD9v410KxZ6fRHNT8k9PfMR2/nBfJIwMCNvetCHmEw0zykq0KLaaBZDSzt5XzUhTPLSdFxystPlUvBDRoZsA7t3+lKqmmfD8n3ugIuByxq7RT00SjvlEoI5OoEANjs8+w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742945547; c=relaxed/simple; bh=vvk9ntWeQNtdrMdNOofVne2jExdehtMKyWCjUK9OW/E=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=WfP5mTDh9ZLRBSOyL2G3w3SdiJUAYOHGC+1bgNr9OMIfbXOnmTJX6NxWQUeQscEhBWHlO3RirS4u4oYQnU2wTzXJZc0ErhM4zhZdsmWHcZ1uhhwaRNtvFung9Ptza34tqWL5DRx+ol+dynoUmlc/dC+At8VkJlrxGHyBbKh6IVw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=buuSy1mG; arc=none smtp.client-ip=209.85.221.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="buuSy1mG" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-3913d45a148so5031164f8f.3 for ; Tue, 25 Mar 2025 16:32:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742945544; x=1743550344; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=N68L1TkrReIgM3ZQq6pPf0NhGCdwRZzpEY5tSQYZ+I4=; b=buuSy1mGhBbjW8VC5cipzBcnMKZpYRwkvE49HjJ+MkbziQJLYxEEDJjkgSa4/CaxiO qhFaDyniCSM8E+XVVNZqZCY93jdFgHtWTS9uGRHiVwkOGSUDOFkuMTw7sDBTGSmL3zc7 zXeR8cMIRfw7hPs4XKX5gA1ByKpkw6plZg6bRpF0t7/+6UNw7GKeYIhK9ukWdKnW1P28 hckWYAtthC4YEWso//1ZlBp1xExqlO5NIstGwfZPK7my4vFEdHrZ90Ufnaff5R+aluPd OF9SkYTgEzB1ACOsGYWkmCridqHPtrgrhemmSFvcF9qT/Ijp80xYoF6fA9qqzB3TFMf0 3kRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742945544; x=1743550344; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=N68L1TkrReIgM3ZQq6pPf0NhGCdwRZzpEY5tSQYZ+I4=; b=lSJXSuZK+oZLhtbblCtoF+qcmWQo+VsvgCL8zI8Yz7EUDRjkqvw8CYp26oZj7uJOE+ JEuYFmfBswBVk0E4Um19iiO2jr5x9BQjhpoGqCaFp7FSCm7HdCK8KPpGL6eeK+03LBea BfGUtdwNZjWQ9/ADNYYVZ4wLHZmPFGm1nWzZaAogUoGS88WpHLtRB+lPuh3qT9h5TR89 XsLBiAPS3Ev5kdPd1stQlt0zf5NpgtkuloWIGfHiiiJ0ekoQ89xVF5qSP00Ielswv81H mmDqsQREuRcwk9FpWEVEP40xvaWxKyyYECr1iAE6kBZWayk86MnLCgb820t3zkNXUrq6 naoA== X-Gm-Message-State: AOJu0YyMMGydyrEumUNkTtCDHmcham95BWCILDrWf5HNJp1UpZY+LtTr h5TMwWS1YZqJLGiKHyOgWfjA++S/AWakGQ9bu9EA3xN+coJcj9le3Z+y0A== X-Gm-Gg: ASbGncvafHG9QndRLve2jwtaK9QTgfGCC+n9oY2W0TD42BvRCApAyrFOy//RgsEFIFD rOTOXPPn9jvKBRSP9GnOzmBxoOA7ehC8upKoa1qQ4rCq58YTYou0zDpDkZ3/yF2h4DQUTd/W8Kc /EsKmxhSxdw5CtEN3KWMXrVlztptCcx8B8iLs6OCkPD5qRMfzAz2opJHJSdsGXnT+LZYbudcrb/ BnmZolVjKEk4ZUKE0qBCDep9xBq/6qWEydXac5EypnVAF5nq4v5UpYBulWHtJWOqsWhFqgKQ9+F yDhuioDDH5ODOz38D8ILWafh3vzbUa6fL6xrSGkKmSY8lQ== X-Google-Smtp-Source: AGHT+IFG/EB8a+WXPOdra3p9t3wCf/I9vi8GXPRgmczQAXZhC4PQvLDNsBnBBrxJ0YWCMaPqkBhcvA== X-Received: by 2002:adf:9c88:0:b0:39a:ca05:54a9 with SMTP id ffacd0b85a97d-39aca0554c5mr2697663f8f.29.1742945543556; Tue, 25 Mar 2025 16:32:23 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3997f9a3b4bsm14870922f8f.25.2025.03.25.16.32.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Mar 2025 16:32:22 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Tue, 25 Mar 2025 23:32:12 +0000 Subject: [PATCH v2 08/10] compat/regex: explicitly mark intentional use of the comma operator Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Philip Oakley , Patrick Steinhardt , Phillip Wood , Karthik Nayak , Jeff King , Johannes Schindelin , Johannes Schindelin From: Johannes Schindelin From: Johannes Schindelin The comma operator is a somewhat obscure C feature that is often used by mistake and can even cause unintentional code flow. That is why the `-Wcomma` option of clang was introduced: To identify unintentional uses of the comma operator. In the `compat/regex/` code, the comma operator is used twice, once to avoid surrounding two conditional statements with curly brackets, the other one to increment two counters simultaneously in a `do ... while` condition. The first one is replaced with a proper conditional block, surrounded by curly brackets. The second one would be harder to replace because the loop contains two `continue`s. Therefore, the second one is marked as intentional by casting the value-to-discard to `void`. Signed-off-by: Johannes Schindelin --- compat/regex/regex_internal.c | 7 ++++--- compat/regex/regexec.c | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/compat/regex/regex_internal.c b/compat/regex/regex_internal.c index ec5cc5d2dd1..7672583bf7e 100644 --- a/compat/regex/regex_internal.c +++ b/compat/regex/regex_internal.c @@ -1231,9 +1231,10 @@ re_node_set_merge (re_node_set *dest, const re_node_set *src) for (sbase = dest->nelem + 2 * src->nelem, is = src->nelem - 1, id = dest->nelem - 1; is >= 0 && id >= 0; ) { - if (dest->elems[id] == src->elems[is]) - is--, id--; - else if (dest->elems[id] < src->elems[is]) + if (dest->elems[id] == src->elems[is]) { + is--; + id--; + } else if (dest->elems[id] < src->elems[is]) dest->elems[--sbase] = src->elems[is--]; else /* if (dest->elems[id] > src->elems[is]) */ --id; diff --git a/compat/regex/regexec.c b/compat/regex/regexec.c index 2eeec82f407..c08f1bbe1f5 100644 --- a/compat/regex/regexec.c +++ b/compat/regex/regexec.c @@ -2210,7 +2210,7 @@ sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx, /* mctx->bkref_ents may have changed, reload the pointer. */ entry = mctx->bkref_ents + enabled_idx; } - while (enabled_idx++, entry++->more); + while ((void)enabled_idx++, entry++->more); } err = REG_NOERROR; free_return: From patchwork Tue Mar 25 23:32:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 14029641 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8870826AA83 for ; Tue, 25 Mar 2025 23:32:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742945548; cv=none; b=OlURITvnJe1crg6M9NGZBVKRpAk7+fztxyjCGKYVfcxZb5kxHKOdJck1IroSHU9OFMyTqi7so4pQ0C421d76wj4T+IcFKq9LH8oERBbUz4NKxMoiw3rPxE39KIZeH7qcJEmdWKLt/AOkOvrXay4jgw7qv/i0DTSs3F4UTcrbWmc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742945548; c=relaxed/simple; bh=jUNo3HVS7J+gSGac0n+fXPtR5JSEeD3RgUyY28+PAbE=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=r/C+lJJbakMNU+noGEsB4kvOq+yxDSUJPg0TEJQjHCtPn9XQkkJegv+6Nu6srM9HXuiXp1fltCgxGXUUvL28XQBpBk6Y+QgUNUlLfW8gJSfWVg2XQ+euUVWLtZWmoO2bdvl7WRcvq/JUpJOEKmLvV4zmDh/b1f98aLGi4ci/3H0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RyJd+XGF; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RyJd+XGF" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4394a0c65fcso55649975e9.1 for ; Tue, 25 Mar 2025 16:32:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742945544; x=1743550344; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=p1sC7oekF1HMLBo7RsoiGdAavqxiv2wKDRWJHd9d3Gg=; b=RyJd+XGFBoJY5BCCe1KkPSMLIKO2A/bttjop+/FCUQnVQJ0hZVJ+HmLXfV2Fo9rLah 307ZqvQOtOjTYHSw+JP9u5/b51A5vDBWOBkK+vk/gQ5faFrcE31M9QaSc8OmgTuu8Oq9 De1RakhuLAs0MvgozrnRWU9mqRuaRQQnIf6Qsvh0d+QrHVHTn7XBe+8JlySJOtsSuAfq NRRKz91ty4QZGsTtWIxLVmoRR0CNLge//I1fD6CGNRTpm6lHB8flh5W+Wcr7l5eBnk1c Eru8pukP3foM/KoGhYKEbNMRnFcRdxGn7nKyxc0x5KqjMEpcW4EQ6jAEOMRWCr3k9QvI OwbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742945544; x=1743550344; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p1sC7oekF1HMLBo7RsoiGdAavqxiv2wKDRWJHd9d3Gg=; b=IWLJYUhu55YB8y8P2HsMY2IeJ2Yq2pTMBCsZXfw8REoze+eqCdZ2EejGNbDmsblmxd 8MWMh4DSeRNa1XM3muzZ+LTXKi0LttA53wH8CyRCrRBTPeRH743oyw4wmxwUAqIvgGOz W7PGcO/g1NhcOnbM/FglVcvS/874ba3reKOKK0joQx4YYCbHXffHp0z8FOYVaZwl1kYl vA5tLe4RLCcL71D2zVpK2ogZnpxNnQ2f6L1+o9pn3IPmmGVouwL/e7GE/Kdo91vLJTTf vLNzXl+QFLos+cS1vtAik1LS+pS7el5pbJYdotdTGvmf4Cks3X8smchfhRu8fuBhIdXI hJaQ== X-Gm-Message-State: AOJu0YxLkTxHbbQptS0/ShgL8panYFlbA2v4QQ9iTLwBoTTVtkiA5Lgi Gyf/l1o/0aoR+X/7cxG5+yRpLjmXxeOWY1E5k+E3RLDNn2cfM7VK7C72iA== X-Gm-Gg: ASbGncsbk2dIoKe855daLkDKjVdOi8N+wUN0pUU5x5Mnv6xdfAgr4gu9QQfO6J1nKZt gU8yUn3W5tPuQZDU30FiqYP8XJfXcqmA8gtDBjIHJnHP6mvZ9JxW4PSO+MN7hT1fXhd/fTcO2B0 vTK7X2BWLgt5oJ5tFm64btkrlBjGzShQCnLJF7T0MWDhPIfflfC5C3CXefkw0w0cd8+abpTD/0k TrVmTRUt9JGe2v6de00G7a3JuCG83dR5aOwm62WkGNd7DRt/WEFQLukasEsKeoWZtltwvRxGRR8 FOdz7/D4JuwH0qDhMq2ZcPpt4fzTQYSvr8Xiktvbl0C3xQ8+qe0D3xuj X-Google-Smtp-Source: AGHT+IHD/NiGq18GOl6MpstgNsKmbEaW2ty5D1eaM7SzVTy7G+cgGx5TLzFVEnWLS6LuvvlvNbWd9g== X-Received: by 2002:a05:600c:3502:b0:43c:f969:13c0 with SMTP id 5b1f17b1804b1-43d50a4f8d5mr186412655e9.29.1742945544352; Tue, 25 Mar 2025 16:32:24 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43d7ae65761sm2103095e9.0.2025.03.25.16.32.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Mar 2025 16:32:24 -0700 (PDT) Message-Id: <91f86c3aba9d19d5df11661675fd6c2cc049e191.1742945534.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 25 Mar 2025 23:32:13 +0000 Subject: [PATCH v2 09/10] clang: warn when the comma operator is used Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Philip Oakley , Patrick Steinhardt , Phillip Wood , Karthik Nayak , Jeff King , Johannes Schindelin , Johannes Schindelin From: Johannes Schindelin From: Johannes Schindelin When compiling Git using `clang`, the `-Wcomma` option can be used to warn about code using the comma operator (because it is typically unintentional and wants to use the semicolon instead). Signed-off-by: Johannes Schindelin --- config.mak.dev | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config.mak.dev b/config.mak.dev index 0fd8cc4d355..31423638169 100644 --- a/config.mak.dev +++ b/config.mak.dev @@ -40,6 +40,10 @@ DEVELOPER_CFLAGS += -Wvla DEVELOPER_CFLAGS += -Wwrite-strings DEVELOPER_CFLAGS += -fno-common +ifneq ($(filter clang9,$(COMPILER_FEATURES)),) +DEVELOPER_CFLAGS += -Wcomma +endif + ifneq ($(filter clang4,$(COMPILER_FEATURES)),) DEVELOPER_CFLAGS += -Wtautological-constant-out-of-range-compare endif From patchwork Tue Mar 25 23:32:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 14029642 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4015326AA94 for ; Tue, 25 Mar 2025 23:32:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742945549; cv=none; b=ZDgqYU0UEHFKCwYy8lcYNlRR1avhvN0j3YbFz8Gzc9uN87FONZtQxuPIERXyi+i7nBtbbVaQVCF22uxzf27A8+mNrbvnSApfAv62bcvXfFyLc4s626NtVKCfGDpuTHyVDrV4/nMNUIpLKWJ/giSni+20DdV3EPi2gKE/tk5L+0w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742945549; c=relaxed/simple; bh=iRwIeu4aNkIDlaA+bXIdED/dHydBvNrnAhLlbcF4Ozg=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=THRHFUlebUKWBrbYBEX94lRvfXaCWI0DzVw/ZzKbw1YFqrAAWi+wWm6m3LF8J8PWlTmOyg1LSB5EFpvdUzHVSX7a/nKmAjmNxeFPzdDSKvz5Xtps+GqWn7cmxKQrNnmfVTXbf4hEG4kkFaEmwCHjKXgwl20J1UESV5VsFRqDi/M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LDMAgXSq; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LDMAgXSq" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-43cf628cb14so1976475e9.1 for ; Tue, 25 Mar 2025 16:32:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742945546; x=1743550346; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=BYkXSbdsNk8toO4gnz5+KubGjU0Tchu08ZiuqSR93UI=; b=LDMAgXSqnX7blo3+QICcpj9TMvqboNwbETPbRufuIHTQk73/+gb1y1FBIixJ+trt0c s2ary7sYPOo9QKCPe9f8HtSYeAmabxNZSRpwPAJVIQJOLJSv9kXYg17BtWbXy9pXWd4F FPfnF/sp6Voc96Ri2fHzgJsYmsKbZCstRMYOZA0eo2NdZV8SvPeFWk7AS6wUDMPryMEj zmOdiUW1kaZ7g2QrTnFqXnELnPykBes1aBkMIf5c2ngI98MmT46j2PgL7Dzu9YBjpKtx +6OUsdwPbR93ixCwQcsPfThsu1XpvF0KcSyMvV7naa/gfEJ6NOl3VxibRSobRJL7/RK0 rWlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742945546; x=1743550346; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BYkXSbdsNk8toO4gnz5+KubGjU0Tchu08ZiuqSR93UI=; b=C9HoHAwH66rec0tOzeQOYyv+/qzxM3Szhdqwj2NRu7ddqJbly46qdZOOGGePiKVEX+ 6XPf8wBfkdtCGolm/r91pyvysanya6RMaPejlYMkvfDuKgMES4Ay8VHKxWuyPMrFp2jS wsYBI6GKfbgm3S3x98LN3XvY28ZqvxHNxFdyWH8mfCmGcCqZ486fPBxMZJvjkaqpVdyP Ki1kUqlj6N2yG0pdltZB3bw/iRB2zyYjDb7g1ti2S3I2ipuUf46PH9bC/vS2DOohw7vE AAgTk2jzGvIBEMsYr/gRPlco4mkw4YSEr5BYMoxC2t2h8csICYsfdkmiMTeqxrygnT+j KmtQ== X-Gm-Message-State: AOJu0Yxgky2IQf1VpHhIDsh9Jw/FEwpgqbvFm81e4Dqvk9iY8FPlVLHi wrHx5BmgslMB2SttqJlVbKh9iXJVyEPcxoIBDvMfbr6zh3YopIli0Ghayg== X-Gm-Gg: ASbGncvR9diAm6oB+F2haGq3eILSQ7BHTp4yI14+ktvXWsVD5nDvALa/tuL4S9XiP6W x3q8RjWegPHSGrGAPnu8iLu1URIVze0WNzBmkMEW4ArtkOTKL2wx5nnr9FyS1ti1cfCvYaJ4KP+ ee1FHRRWV8ugGMDXVvXQtZx8EfoHWOu8Kxo7HID6tT2zpy/xAhL2c54kogfKpxLp4YTvNzpeVSs q1VJDk6PpihCR9GBvlzDPCQAM/HbuF6Rs9LLx3emQpQCg9hqPJCon3slhUeDDq0047kbJNv4bjI V697gIMbrdi+I6q8zltPWCQhZVYn26kI//d/mPBDlpsEIg== X-Google-Smtp-Source: AGHT+IEYPXGi9//1wWmdMMQl51DwdJNhtSuvJTi3xINT7YVOqr14hPBPQ8hnkIpD1cjMBvp8IEGVbg== X-Received: by 2002:a05:6000:18ae:b0:399:6d6a:90d9 with SMTP id ffacd0b85a97d-39acc46dd97mr1353349f8f.18.1742945545442; Tue, 25 Mar 2025 16:32:25 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3997f934812sm15065403f8f.0.2025.03.25.16.32.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Mar 2025 16:32:24 -0700 (PDT) Message-Id: <2f6f31240fe6ce5f8efab662af477540a0f966ca.1742945534.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 25 Mar 2025 23:32:14 +0000 Subject: [PATCH v2 10/10] detect-compiler: detect clang even if it found CUDA Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Philip Oakley , Patrick Steinhardt , Phillip Wood , Karthik Nayak , Jeff King , Johannes Schindelin , Johannes Schindelin From: Johannes Schindelin From: Johannes Schindelin In my setup, clang finds `/usr/local/cuda` and hence the output of `clang -v` ends with this line: Found CUDA installation: /usr/local/cuda, version This confuses the `detect-compiler` script because it matches _all_ lines that contain the needle "version" surrounded by spaces. As a consequence, the `get_family` function returns two lines: "Ubuntu clang" and above-mentioned line, which the `case` statement does not handle well and hence reports "unknown compiler family" instead of the expected set of "clang14", "clang13", ..., "clang1" output. Let's unconfuse the script by letting it parse the first matching line and ignore the rest. Signed-off-by: Johannes Schindelin --- detect-compiler | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/detect-compiler b/detect-compiler index a87650b71bb..01eca3a781d 100755 --- a/detect-compiler +++ b/detect-compiler @@ -9,7 +9,7 @@ CC="$*" # # FreeBSD clang version 3.4.1 (tags/RELEASE...) get_version_line() { - LANG=C LC_ALL=C $CC -v 2>&1 | grep ' version ' + LANG=C LC_ALL=C $CC -v 2>&1 | sed -n '/ version /{p;q}' } get_family() {