From patchwork Mon Jul 8 09:23:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: karthik nayak X-Patchwork-Id: 13726316 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 3481D433CA for ; Mon, 8 Jul 2024 09:23:30 +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=1720430613; cv=none; b=nx0oSB/L0XiWxhYQHhtowpRXIeUmuLkqvSr4XYZlpQGx7dyuGViWpztUUXA3p52/Fd7sFbNNOvmUyFFr9xR6A/adWe/gKDytoWpyZ448bGcKb0EOWXKdZ9Ld1C3K/aKrtUAMe0Uutb9wXMXxuJc9cPy3pkfDDIhUGvWlJpeOjfc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720430613; c=relaxed/simple; bh=Gqs0VQwsfgRA2lK8SCn/i68gVXoNG+1qWEpW07/D61k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uU8uUcZZYcZt615OhZsLSEViP5Txdh19g+s5a8qWlQuYNYEfUyLvAPXNU7KoRjE5fzfiSw8RDCNa335B2xX6xm8Qi9VyW1WgJlJAWiGKc7URSSbDqhaaCdu+EDmLD/CyVW138hjoHKMG+4WV/GKbuYtF5/0Dt5mlp8aEOIxtqLs= 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=be1M7XPN; 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="be1M7XPN" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4265ff0c964so11792425e9.1 for ; Mon, 08 Jul 2024 02:23:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720430609; x=1721035409; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dGcMb6BAXpBImfiOAFXGemoJ0A4QULj+Nih/JoSKkps=; b=be1M7XPNkC1zb3q2/Tv0LcRrwWam+WVPerXcAV4Q09FC/1hYOXdsenjL3dHlayE4X3 d7ZifqwgS2i50T2HXvuq3eoeWrWfOUWhkcBIqm0S01Nq/1YZCp0qogVGO/wRXrjf2/r5 LqkYxIWvEMDmKoeI6sGYmIepzshauC8DcymF8AzMC9ksC7Kf7Nbi26vEIphaPmfkZ5+k 81LKd5Uoo83p58c5QSZVbvGvdSudexZY61rRDwYNUfyN39vATz3t9Hv33GhDOimJLFgQ Kaq5UdfYveeux2mKlQqMQ2oNl03rDy4SVflctc32Wnu47h3a2+rXZckyO1DfvQxSJyiv KZlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720430609; x=1721035409; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dGcMb6BAXpBImfiOAFXGemoJ0A4QULj+Nih/JoSKkps=; b=tqdRGAChw5dS1ykyWWSu0S5rRn8t3qkI5WA5SE9IvfR5KjFQNrgei6/QPiNEGAB35K eGUwMrV6OxsiFyilPomYWhYb4DmfOT7oeZdykkpUB2sXy2E6FxizcL+vXonom+a7DbBm yeVud7zTCIMUITRBZ0wTQHdAlqqAXUoMeaJ/q2tjM6Dalu2qolrv0QQ7DsOx12WoC1Df P1UTOR2AzMBPP446/OCRNnn97Pc9+TOkoCDBOd64GicrMzE+afH60Azv7LW21l0jlrzU B7cg5IkeI0l2RZXDjLPm35xEuj2SJOga96Wi1L2+aimWDTJfclRYdyTHx4SiEdoqfaXJ 1quw== X-Gm-Message-State: AOJu0Yy8FhGBuWyGPx2BSqZoTbAzGMy4kOY2eZhRmAqyYGILk/r1uwwE mJOtVFGG511Bo1P4cSoGZe6pkA1SjZT4ts7iveI6dZdUGoeKi8o3 X-Google-Smtp-Source: AGHT+IEbGlCqy29merhADgD1ybhUsPL3ef5chsoWoctSd5kSgZiL6Pn/ddLALJ2k26q3YFQcF/1xXw== X-Received: by 2002:a05:600c:3592:b0:426:632b:c2aa with SMTP id 5b1f17b1804b1-426632bc350mr28390295e9.16.1720430609472; Mon, 08 Jul 2024 02:23:29 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:1d0d:3d35:3ae6:ef05]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4264a1d5116sm158259935e9.10.2024.07.08.02.23.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jul 2024 02:23:29 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: git@vger.kernel.org, jltobler@gmail.com, chriscool@tuxfamily.org Subject: [PATCH 1/8] clang-format: indent preprocessor directives after hash Date: Mon, 8 Jul 2024 11:23:09 +0200 Message-ID: <20240708092317.267915-2-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240708092317.267915-1-karthik.188@gmail.com> References: <20240708092317.267915-1-karthik.188@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We do not have a rule around the indentation of preprocessor directives. This was also discussed on the list [1], noting how there is often inconsistency in the styling. While there was discussion, there was no conclusion around what is the preferred style here. One style being indenting after the hash: #if FOO # if BAR # include # endif #endif The other being before the hash: #if FOO #if BAR #include #endif #endif Let's pick the former and add 'IndentPPDirectives: AfterHash' value to our '.clang-format'. There is no clear reason to pick one over the other, but it would definitely be nicer to be consistent. [1]: https://lore.kernel.org/r/xmqqwmmm1bw6.fsf@gitster.g Signed-off-by: Karthik Nayak --- .clang-format | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.clang-format b/.clang-format index 3ed4fac753..5e128519bf 100644 --- a/.clang-format +++ b/.clang-format @@ -96,6 +96,12 @@ BreakStringLiterals: false # Switch statement body is always indented one level more than case labels. IndentCaseLabels: false +# Indents directives before the hash. +# #if FOO +# # include +# #endif +IndentPPDirectives: AfterHash + # Don't indent a function definition or declaration if it is wrapped after the # type IndentWrappedFunctionNames: false From patchwork Mon Jul 8 09:23:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: karthik nayak X-Patchwork-Id: 13726317 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 4B8444D8B6 for ; Mon, 8 Jul 2024 09:23:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720430613; cv=none; b=ICjTUcsLFlUqlwJHNmbkcVyQGklfbJaoJVgmlAiZcPWV2SBoZpOw8suT2P+zsaavu+iqs+riEZk2empSuxfoDlFnwHbAad6hRc7ynJm8nmFxRhMTyAeSFP/XWCBL3SVg8pf8UhDe08/fKb1c7v6TRanlQOtDUoiTL3q3NtWQspo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720430613; c=relaxed/simple; bh=rYLSmW92LWpGMgOgvTXGMYv9BXgMYJjw8OEXTDbrCZA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CtTxo5PzQYuJZp+2abd1PJO1iFGfGiSUFozgusm3NOAiQJIlf1su+ibA5je1ZetBsixIqc7P8GqiY2ufTPjMNd9VTARPUF3+8bmdfubeXGUvSAOLXG4pk7i8t4fPT8YMnlUic1d8eg3pd3J9sPxXAtLW1El91pm+8W397FSC6xk= 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=SdEFcTjI; arc=none smtp.client-ip=209.85.128.41 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="SdEFcTjI" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4265ff0c86eso11026395e9.3 for ; Mon, 08 Jul 2024 02:23:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720430610; x=1721035410; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KgCNkYwb6YHIDARQWCtaR6yrWUTjYfwaSb3ScX0X54Y=; b=SdEFcTjIeET0iGusCXbjuvn0wRaR57BYoZqePJjR03xWIPxNTPrtPNT6MyMHiNg5q3 9I/Dt/MLvSxGSQ3V8JeViw6ew3fNVlfXRJ3wGyY/YbSZWCUimUcYHZUxzZCdvmE982QV O2Ikn8tsMFnkdfTCqG4OO9rKZzEKnwpgKwyg0qJXqNdvHdVx1zlSaXBbWbo50L/WSGU0 6facEcr8C0u7lJfc4keIBhunymuygGw6+BlpO5rCiPqmTj3YRiUWMFOwC7WIrucBRfsb SgcHa+QDOvri3fRKAQylZDq2zXJ9vEdemUAXYRd6ktKV04J07NsAI+XXz/eWthPNTQWz 1xJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720430610; x=1721035410; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KgCNkYwb6YHIDARQWCtaR6yrWUTjYfwaSb3ScX0X54Y=; b=mMRObckKqoDX1UcuPTA1Vu3md/XpPbqbaOIiK3kGuHKOv8bR3toibSMx+hvtoqsbK/ GQR8CnRilbWMEgkOeJrXT/+Oj3/7zt8sdx44Tlnj4KHkRJCGlzxBKNdn9E/YA6zfs978 hDsuAQC6W9SKlaqTX8PHC+2ee7qlsAjWkly+4ZOElw+DKTKm6UulNBgyhb/217IereJ3 hECH052r9qDaGqEqQpSsng5xpxvjUI3o87sVqQ3+cCfuD4tz+h66gpUdXBjfzP02gwzu HeRbge0X9kO9jKy4N1Rzn1Syv9+vPTuJZULFqvbl//vrb2aGZdxzIsCaA9yBOYofcT+5 w/Pw== X-Gm-Message-State: AOJu0YwAwJC3Vtk3MfgU5V0FPIn7Xi3KNCeSTovTqrHAfSJLcFozvvwe QTH3i3OOtsOQUe/aaO9cqQtwkj+Zl53swLMKpD4CLt80SlUwm9B8UNeSOm8A X-Google-Smtp-Source: AGHT+IGAyItnfFlmXtHrTuic38VzBt6w9GbjDLx6rL40+2JHSfK5G5JAaaKuZDA2x28A1ogaOL9Z9g== X-Received: by 2002:a05:600c:a69d:b0:426:5f02:7b05 with SMTP id 5b1f17b1804b1-4265f027ba1mr40978215e9.2.1720430610374; Mon, 08 Jul 2024 02:23:30 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:1d0d:3d35:3ae6:ef05]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4264a1d5116sm158259935e9.10.2024.07.08.02.23.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jul 2024 02:23:29 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: git@vger.kernel.org, jltobler@gmail.com, chriscool@tuxfamily.org Subject: [PATCH 2/8] clang-format: avoid spacing around bitfield colon Date: Mon, 8 Jul 2024 11:23:10 +0200 Message-ID: <20240708092317.267915-3-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240708092317.267915-1-karthik.188@gmail.com> References: <20240708092317.267915-1-karthik.188@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The spacing around colons is currently not standardized and as such we have the following practices in our code base: - Spacing around the colon `int bf : 1`: 146 instances - No spacing around the colon `int bf:1`: 148 instances - Spacing before the colon `int bf :1`: 6 instances - Spacing after the colon `int bf: 1`: 12 instances Let's formalize this by picking the most followed pattern and add the corresponding style to '.clang-format'. Signed-off-by: Karthik Nayak --- .clang-format | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.clang-format b/.clang-format index 5e128519bf..803b274dd5 100644 --- a/.clang-format +++ b/.clang-format @@ -72,6 +72,10 @@ AlwaysBreakAfterReturnType: None BinPackArguments: true BinPackParameters: true +# Add no space around the bit field +# unsigned bf:2; +BitFieldColonSpacing: None + # Attach braces to surrounding context except break before braces on function # definitions. # void foo() From patchwork Mon Jul 8 09:23:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: karthik nayak X-Patchwork-Id: 13726318 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (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 30C0D558BA for ; Mon, 8 Jul 2024 09:23:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720430614; cv=none; b=eqhnAXad/dBnTLn7JDbEKpHNQjFcHK0sR2qTMFkvydHXLCaWm9VaPAV4UdKTHjxMgiQ6uOyXBBdjiaH5YvxArBcXOPgpWHhQKgDwC4hpORj/j36LbeflLge8LPtunsP/vmAVT/34/4KZs6NnPNoBGuizg7hHW6cvNwbYVs10EaI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720430614; c=relaxed/simple; bh=d0q9Hxhdhih/ajxSMaLCUPyuyuLRA2BTAnO2lFVa1tQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=npjWOK3549T8adu2Su4wdjM31rLIVWOCjThvUlGIeaRzNaRtINEjbAF835w4HrcFVkVghZlDXSV2o2qJsXwyL9BvZxiJebsByCFJvCInohdJuD+gSEQYbh+yCnHWAMFsmYEqXw2THvQLgYDU/DAOE/80+q7AYKDvV1//R1WkP8Y= 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=UDjZ2Q9M; arc=none smtp.client-ip=209.85.167.47 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="UDjZ2Q9M" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-52ea33671ffso3271049e87.3 for ; Mon, 08 Jul 2024 02:23:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720430611; x=1721035411; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0t/ESDNXetP4dVwGA6sk7uZ9qVhzzo6pAPar0bUuRKE=; b=UDjZ2Q9Mt8PG0AnmWOQZh54axSe3cGKuuqnEsy15kSCNmTTygykn141xq0N88TZ+jH nQ8t7S0iviFgVVDOtU/lOWokolZV6qz7Ek+3mouGGm5t8VNuowz9CnP0Sj0RRZTmSa95 ODmirXuZjGTcyR3KKyir/cYOqoLnp+fVjCb/kRSXlafRibRdQIPgM7U4ZxVtSEhOmL5t k0CS9zz6ilqXrYZQguE02TgaO6mvrjopxCx9yDW8V6BPknM+8fThakr4pQwx1J+xddgq XF9LGgy8E4Oe7MItc721v71fNss1i7QGnd5fX9Vw0CTKKipF8sHLDWLVDBymdsovjDRU vUhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720430611; x=1721035411; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0t/ESDNXetP4dVwGA6sk7uZ9qVhzzo6pAPar0bUuRKE=; b=Xu52L9k3uMcsGP11q1FIy5UkAV/5Ki3t0SGCsJqpOhLaHo7iJ73OlYtnBxlQ9FEv05 jgEs5vja+Bl1Ya08hebgTmHsMU1UehdmQ/M5ynr2g45s6ucjQuPTKIJRx2d4OObzU/4L GSyXS06nKBUj7ruZGVVC9gAtxFzUDqYlgL5xcDEFPhUH4ATswaEC/TY9bAIBdIyFcqKL rtM8hi6oqDhWc/RBFFa4TxNOUCiKD8z5IGacplOQ7XB9OBgRZ96/UgmxjQ8Z7Hu17gjX ZbTd8ZWZSaQbTCW40Yy/1RJ+pFtUeCnTV51Srs+64Vij1765/uqo00pIBTcTdKTggfk/ iqTQ== X-Gm-Message-State: AOJu0YymV/y8n5H1P0pTTL0rpCfUwarsUwmpj+j00OzKKnnzgt/xwPHV 7YfLKlxrIdz8bAf3hk108QGAhxLc30qLk3Gp9pnu2h9+abM1bLP3 X-Google-Smtp-Source: AGHT+IHFFTOBBDa0WBEObuLvlmyaS4dTWzGbwOY5aPovv2lzfFVxJROy5T5xJBFzgNgzKTP4xP/oJw== X-Received: by 2002:a05:6512:3282:b0:52c:e07d:229c with SMTP id 2adb3069b0e04-52ea064c57emr7653694e87.22.1720430611196; Mon, 08 Jul 2024 02:23:31 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:1d0d:3d35:3ae6:ef05]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4264a1d5116sm158259935e9.10.2024.07.08.02.23.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jul 2024 02:23:30 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: git@vger.kernel.org, jltobler@gmail.com, chriscool@tuxfamily.org Subject: [PATCH 3/8] clang-format: ensure files end with newlines Date: Mon, 8 Jul 2024 11:23:11 +0200 Message-ID: <20240708092317.267915-4-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240708092317.267915-1-karthik.188@gmail.com> References: <20240708092317.267915-1-karthik.188@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 All our source files end with a newline, let's formalize in '.clang-format'. Signed-off-by: Karthik Nayak --- .clang-format | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.clang-format b/.clang-format index 803b274dd5..4c9751a9db 100644 --- a/.clang-format +++ b/.clang-format @@ -106,6 +106,9 @@ IndentCaseLabels: false # #endif IndentPPDirectives: AfterHash +# Insert a newline at end of file if missing +InsertNewlineAtEOF: true + # Don't indent a function definition or declaration if it is wrapped after the # type IndentWrappedFunctionNames: false From patchwork Mon Jul 8 09:23:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: karthik nayak X-Patchwork-Id: 13726319 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 A305359167 for ; Mon, 8 Jul 2024 09:23:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720430615; cv=none; b=SCkbS7KV17ZqFeUleWFRKk+v5FQYfp5VYM4vpCtUwTHdn1QzxpwFYwA9sUuGwzLTCTMRC+QdgL0hu2bwaD2srSxsmbadXP8lbFXgBV6qurh1Cew8nBajpbaYeV6VBEAAlS6cvDJPqgtOVuHOvHdloeQNtZ1NIhDVxqF1w090E4w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720430615; c=relaxed/simple; bh=dsalWAx03TwmHNKuDDxxXM6DZF3G7lGrB7wXLyX6BuA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eFSB418aXd6hK5xP70w4MC+wFOuwhZbW6fGL7RXNlJCupO2m6xIUXDN/IUjcRALO1j/MsJdfUsgGe8xMuJ/CDY62ZCRrUwUQlFM229uvSah8unbx74BtFk4wTnr5VWExUAXLJgPE5Uru2sqB3M99bResC98ZztU8vvZcqLFxC1w= 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=T2halYQZ; arc=none smtp.client-ip=209.85.128.52 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="T2halYQZ" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-42662c21289so8795715e9.3 for ; Mon, 08 Jul 2024 02:23:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720430612; x=1721035412; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8JHGziRgakNVZ5DwXy91iJK9uggV/+EZQns1CJL4VNw=; b=T2halYQZaEjksTbAuwKTZaETRsDhn+iN1gvuWa2+gql/Bj15xgVm3Z9ehwo6sNbLrT Dle95ku1pyKX7lDoACCW2ZnTdRGlAzThuVizMJ4yQ8qFSbzy2zyCEjB40gQ3ffHKuLwi kf+tbTI2113M6aY0eEnhDeTqK3ovairHrnLmr2+Stbgf2eTQsJFzMnwA1AW4bUKKBQJO uqw0CsXMfbB5Y0e9LsIAsyXS3SWvgiXtGG4RnZrG2iBDMe15h6LY6SzFyJ1cZD3WHKs3 EIj9jQy3z2ObTxq4z+ic8x9GcWMKK3k9np8hVSqagI4hW/gF5PzU2pAdobAdyBjE95QV 4uaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720430612; x=1721035412; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8JHGziRgakNVZ5DwXy91iJK9uggV/+EZQns1CJL4VNw=; b=bYstS3ZZARvhr1QqECsEkRSx6i+5IJYuKS1fgD8/PyqGSyY9C8qRHaZsWVZYc7EQbD qw5LAjAVu8oRBhdIMtVr5nZoxDaRQXwhj3rI3fZhb0aKdQt4Sv8ix4fP69jX+fC2eShQ HAs6+r0PhQqRAmhw6pqKMIN+t9U7CjqQlr5hZQstNWiaKddewpSIvZPco94+M6IX3/d/ qi1Gddxm9jQKCK/a6Xwm/sTmHuQ2GhzB6NCTVHTM9TfAEIARYTs5+V2RRzBROBDq8u3T 1TOfF2ImxG/SnrJDmqFdckHJfK1b3saLbxQjTOKY/o+lREPlHNzWEpCbV1ksKU2+/E9r gccA== X-Gm-Message-State: AOJu0YxXI7B25G55yMcSRiv5uttIqRGn3UoLNu5KGS0yRE2B0TKZr6S4 w/m80fPn4NqTRr5NdSDkbH7DpspJRUrZay1ttgiKkugu1nscM4N2 X-Google-Smtp-Source: AGHT+IGNk6T0eaQrU+VAwPI/cbYblajrGStLToZBJz+7wOW4NnCHmL/Ar8AE7q+q/kf89VEbe1ppPA== X-Received: by 2002:a05:600c:4811:b0:426:6e95:78d6 with SMTP id 5b1f17b1804b1-4266e957ac8mr1708215e9.4.1720430612059; Mon, 08 Jul 2024 02:23:32 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:1d0d:3d35:3ae6:ef05]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4264a1d5116sm158259935e9.10.2024.07.08.02.23.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jul 2024 02:23:31 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: git@vger.kernel.org, jltobler@gmail.com, chriscool@tuxfamily.org Subject: [PATCH 4/8] clang-format: replace deprecated option with 'SpacesInParens' Date: Mon, 8 Jul 2024 11:23:12 +0200 Message-ID: <20240708092317.267915-5-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240708092317.267915-1-karthik.188@gmail.com> References: <20240708092317.267915-1-karthik.188@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Replace the deprecated options 'SpacesInParentheses' and 'SpaceInEmptyParentheses' with the newer 'SpacesInParens' option. The usage is the same. Signed-off-by: Karthik Nayak --- .clang-format | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.clang-format b/.clang-format index 4c9751a9db..914254a29b 100644 --- a/.clang-format +++ b/.clang-format @@ -134,8 +134,6 @@ SpaceBeforeAssignmentOperators: true # } SpaceBeforeParens: ControlStatements -# Don't insert spaces inside empty '()' -SpaceInEmptyParentheses: false # The number of spaces before trailing line comments (// - comments). # This does not affect trailing block comments (/* - comments). @@ -149,9 +147,10 @@ SpacesInCStyleCastParentheses: false # var arr = [1, 2, 3]; not var arr = [ 1, 2, 3 ]; SpacesInContainerLiterals: false -# Don't insert spaces after '(' or before ')' -# f(arg); not f( arg ); -SpacesInParentheses: false +SpacesInParens: Custom +SpacesInParensOptions: + # Don't insert spaces inside empty '()' + InEmptyParentheses: false # Don't insert spaces after '[' or before ']' # int a[5]; not int a[ 5 ]; From patchwork Mon Jul 8 09:23:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: karthik nayak X-Patchwork-Id: 13726320 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 D849B6F067 for ; Mon, 8 Jul 2024 09:23:34 +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=1720430616; cv=none; b=Ttx6W9ZsLWIdfqTFM9S/uigWC7vHdveToZeHLEvIiOutlX9cvJFt+NN7MZrlvUgVq/bQ/63Qorc31v46SgRGXJb+SQ4Re8k+rskci1ImtsoOTXt0IggpgvH2kGr76l0mJg8+7px8qxXbkKMvl7V9FFXO0uP0kDJZDP/eBC1s8p4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720430616; c=relaxed/simple; bh=ShaXCRJFUbB+ItEYBkd5/a90Y/kuoPbJFa+gDF5CtXw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Nhb9Jxb0iYYXrZndWlNOaAyswhXEWzE6lyL8h5R8nCnfZXxauxeI/X6HQ7G9cT/HMOwI2j6NKIpkRPrrf+ksHdoFFVm+HCzDDOhWEA+lOLCWY7Rq7yvr7csOkhLAo4/x0xrjrOBiafzYI/gy3/8mg0i8ZLxC1JjOd9YGwfaUXAc= 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=T4uzu7mk; 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="T4uzu7mk" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4266bb98b4aso4066885e9.3 for ; Mon, 08 Jul 2024 02:23:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720430613; x=1721035413; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cjtC9NY8+SlWOLskgKymhAmQ7oMn5OK4giKmRPuFLoM=; b=T4uzu7mk9yiUnvqT3sGgo3dcMNgM1ZqBrq1jFgMkFMlFo/Pf1zgkiILSlpQ0riSNxV 5I1QLL9sVdZHXKYvMzu6aTx2TXZn6jG+/OVPfHDa8B20cVMCFdVyN5PZPyDHdWdAZMBJ IG7k5946oiyDfKL/yOVe2ulryFAEUiz9xR7wE8D7FLMOtBL3s2DB5Dx2PRATScJMqp6I LnqMALT7+sk+V227FK4sBD8QzdDz5UZ6GteLEmi1NGJIw0yXOgD3MGqbOZtTObSXeXqg qGyW/QfZnFCmsqcj6Vw1/tH/iGujGAB+sUKkkZgOfSPh72kl4HEVKZbMv8MQ9oITsM8P Zkig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720430613; x=1721035413; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cjtC9NY8+SlWOLskgKymhAmQ7oMn5OK4giKmRPuFLoM=; b=l6vuKenSK1E3mltGwgBblVMQZTnYvQp+cz26UCpWlAMBxT6CmsE/oN9ZzzbCZ517Az 5LG9dPa1uBfmxn8lF1R2ff5E+/nQLK1lBRWEAWbJKg6Fte/qMbXmGcRLzyTo0C/MPNBX x06N4jIG0GK1ReeaGrbTP7lFvuLDiNfdvLtEw5w9PIq93dLvBv66UMGQ4aFnRqjfLADb IKSzDrH2tApkK8uaRhmnCTxdkq7NWz8HBUJMz+bNjQrlz2u/UOx4MPhIhuaEawNTFhub hUjzx6XKEEH1eZlnw8+3B9r+NeznVAqOYcCzTicFxvLPTqyaEd+BX67iEQ8w//8QW0VF nKng== X-Gm-Message-State: AOJu0Ywl/Be0qr3yFYE6mKuxB3lWjFm8tYOaS/gpe0aTb0iPLu8uBJOF m9s4ZoE3nmYiLDC3emS8vDIID3F9J8c00xbKBa9Kn4oqItdemzbs X-Google-Smtp-Source: AGHT+IEajYs8JZWT/1XxNu0ZP9xvKIkg4eCbnR1fAlGCKxOowsWu3tqGXyAwJc6Eadd98rFPIvIpPw== X-Received: by 2002:a05:600c:424a:b0:426:5b76:13bd with SMTP id 5b1f17b1804b1-4265b7614b4mr64623355e9.38.1720430613059; Mon, 08 Jul 2024 02:23:33 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:1d0d:3d35:3ae6:ef05]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4264a1d5116sm158259935e9.10.2024.07.08.02.23.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jul 2024 02:23:32 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: git@vger.kernel.org, jltobler@gmail.com, chriscool@tuxfamily.org Subject: [PATCH 5/8] clang-format: avoid braces on simple single-statement bodies Date: Mon, 8 Jul 2024 11:23:13 +0200 Message-ID: <20240708092317.267915-6-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240708092317.267915-1-karthik.188@gmail.com> References: <20240708092317.267915-1-karthik.188@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Set the 'RemoveBracesLLVM' to 'true' which ensures that we avoid curly braces for single-statement bodies in conditional blocks. Signed-off-by: Karthik Nayak --- .clang-format | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.clang-format b/.clang-format index 914254a29b..1a5f0c9046 100644 --- a/.clang-format +++ b/.clang-format @@ -117,6 +117,11 @@ IndentWrappedFunctionNames: false # int *a; PointerAlignment: Right +# Remove optional braces of control statements (if, else, for, and while) +# according to the LLVM coding style +# This avoids braces on simple single-statement bodies of statements. +RemoveBracesLLVM: true + # Don't insert a space after a cast # x = (int32)y; not x = (int32) y; SpaceAfterCStyleCast: false From patchwork Mon Jul 8 09:23:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: karthik nayak X-Patchwork-Id: 13726321 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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 34B8D7347E for ; Mon, 8 Jul 2024 09:23:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720430617; cv=none; b=B3Pa0LXvlvH15bpXZbe5HmGsAjomVN6B1kUZ96MaksbVgBb6mMEEesYadfdbNBan/eh0T5CiOB7z+kMwGnWztVS6kmLXIb9KKjMlhiv6UoESZU0Y6WqwpRspZEpmV7n664WFqwStPgEFvUAZRPjiZDXjlyn3PaYqzN07FwmXPh8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720430617; c=relaxed/simple; bh=z8m6nQw9Cqs3TGJOX9K8BOwQi4cggyNslh0bZrnppEM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=flY3mEMTX6MUoPrbWhq74giyzMZsTDJIIr/WXXn132ru08oWFWxkT+5QYOvk54yToeDB73xGvNma82Z6lhBosOAglMtvgxo0Ag8xUdQrBQELbMm5QWR3KdSw35w6vt/9qrXC+Q/Z+lwfVQx76O0ivt9S8vI141Uyj5o0RV9s8/s= 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=d5L/ri0Z; arc=none smtp.client-ip=209.85.208.175 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="d5L/ri0Z" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2eeb1051360so685281fa.0 for ; Mon, 08 Jul 2024 02:23:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720430614; x=1721035414; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6ukjiI8tND/nPwf0O8/p4MeqDzu4bWts+8pfWc649w8=; b=d5L/ri0ZZtYl8ESDs8tHofwve/OKZPN7hIg51ORscYaSR7W+cNBRCcbz7u4rM5GgAh PaPQNug+73JcXc4XbOlcBP2xF1UhePKObwMawxux49nXtkZNWzcnrIGXZJoL/eFGBU/Z 74GQ+NUhysTruSUZpffTxA52TULcys04ZpCC+mftsQQmdsCukMpWpDTPVS3tAxR7LpBA fMvBV8z1HiN0NsHaVCVyiciP6IMvktLBJhRzHvvUgQqKRh4iFhFWat94gCLZIgj1SAFQ l9SfsVwv1aw7rDtS5JhgiD+kMTs7cpCVjz6pAgqC5Mm/GV7qAk1q/aLCWswjyIWZy3H6 j4Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720430614; x=1721035414; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6ukjiI8tND/nPwf0O8/p4MeqDzu4bWts+8pfWc649w8=; b=mbp0CFzrW4XF4roQnP4Q/N6RYHJgPP0SP7U/Xm90OuFEcGRQbMjt6jW4VwaBMoOPyZ kHi9vdh+eZO02BlAnmjhumWCCaopPqWXG03jmUgXiaK2NVLmaNRjXAnixr4Vz/SaqN3l p2Xm/X380o03tPYl9n+jM0A2KxEPziLr8JAOAlflXJb4AYAlBzchoWmLwxUBViG3cpz2 e3ktovrTdvQAPXJoDpbJJkbss8Ty7ZUjbV/Tj8/Jdo+oI0vjUb6Aayqg2h23sg/UOvja Zp/ONpfm1xPdQ+O7jlw9H2N9UQ9+29hUegFJWspvKVlwQRa4GqGBR/mF8t1UlSy/sU6i cM1g== X-Gm-Message-State: AOJu0YyvwxLsPP09ttwQL13qRMg1Fj3iUydJk/E1zmEZcFq/VnoQLTP+ 8ffsvJqojV9GpsEREavfQiqLIK6OptLUt6sqHIUqhTC5BCJ9/vsh X-Google-Smtp-Source: AGHT+IEeNhZUqCuqWNTKBcvdTNd9Bjclr2U3qh/EDR6jhuKZ8jwItXzMydXBLiC3pQHlkh8FCatcvA== X-Received: by 2002:a19:ca13:0:b0:52e:9423:867f with SMTP id 2adb3069b0e04-52ea063a4fdmr8082114e87.36.1720430614124; Mon, 08 Jul 2024 02:23:34 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:1d0d:3d35:3ae6:ef05]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4264a1d5116sm158259935e9.10.2024.07.08.02.23.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jul 2024 02:23:33 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: git@vger.kernel.org, jltobler@gmail.com, chriscool@tuxfamily.org Subject: [PATCH 6/8] clang-format: formalize some of the spacing rules Date: Mon, 8 Jul 2024 11:23:14 +0200 Message-ID: <20240708092317.267915-7-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240708092317.267915-1-karthik.188@gmail.com> References: <20240708092317.267915-1-karthik.188@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There are some spacing rules that we follow in the project and it makes sen to formalize them: * Ensure there is no space inserted after the logical not '!' operator. * Ensure there is no space before the case statement's color. * Ensure there is no space before the first bracket '[' of an array. * Ensure there is no space in empty blocks. Signed-off-by: Karthik Nayak --- .clang-format | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.clang-format b/.clang-format index 1a5f0c9046..05036f610b 100644 --- a/.clang-format +++ b/.clang-format @@ -126,11 +126,18 @@ RemoveBracesLLVM: true # x = (int32)y; not x = (int32) y; SpaceAfterCStyleCast: false +# No space is inserted after the logical not operator +SpaceAfterLogicalNot: false + # Insert spaces before and after assignment operators # int a = 5; not int a=5; # a += 42; a+=42; SpaceBeforeAssignmentOperators: true +# Spaces will be removed before case colon. +# case 1: break; not case 1 : break; +SpaceBeforeCaseColon: false + # Put a space before opening parentheses only after control statement keywords. # void f() { # if (true) { @@ -139,6 +146,13 @@ SpaceBeforeAssignmentOperators: true # } SpaceBeforeParens: ControlStatements +# No space before first '[' in arrays +# int a[5][5]; not int a [5][5]; +SpaceBeforeSquareBrackets: false + +# No space will be inserted into {} +# while (true) {} not while (true) { } +SpaceInEmptyBlock: false # The number of spaces before trailing line comments (// - comments). # This does not affect trailing block comments (/* - comments). From patchwork Mon Jul 8 09:23:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: karthik nayak X-Patchwork-Id: 13726322 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 2522A74077 for ; Mon, 8 Jul 2024 09:23:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720430618; cv=none; b=YEtIg5IhO5I1fnxcQSlRapxtHJyJczhL+gxVTmcNOnGEs4kSs3mbXoohD4BL2C4+e6vVay92qtPApt4scCFMxiP6E93owK4me0RcltOpxlA2GsMwYPV5fC8mxkWfpmWMLd2bNaOLrwzrczY5oymeuEQuwNy5nZoIiQadzGLOTiM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720430618; c=relaxed/simple; bh=xm4ZloHydbKWdqpwlTZ7Ll/QmZ0cFJEBQAZp0WTF0rM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H2uuCDFVyAZfHAR1LCuACYemorb6UZ7x3QuOxJZJ3+LVsbBgvZemn4+EdjkRvLFTigCjYq/TmKmgP7zQ3yfMnfddYmfSC0xFybDkbIpaqPyyratO/SngHg/x8aiDMcMynI2Inka/Lx9pqisC0e1iItt89s+OqJZ20r5Np3pvuno= 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=GeezlEO2; arc=none smtp.client-ip=209.85.128.47 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="GeezlEO2" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4266ea6a488so481455e9.1 for ; Mon, 08 Jul 2024 02:23:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720430615; x=1721035415; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LBi2SePDUDL2U0in1AvntQvb90L94gT0MTYcEwNyyCk=; b=GeezlEO2FW3HbybMh3w83assPFv/oUIGqu3NHmS6FYN6poX2oSXLYPIjE3F+imvkj9 FDR+YZG7B3A3e56mYncmYKsIucjz6n6Msce/X+hI1Y7MEeYLG1pcZpsqGzldOvAmPYiF yWrMa3Uu9NvhYz0LXUr8uAhoeUuE1kDnDsFXCMVJAN/llcuY4UXUxjKubnGBBSRV7ZtS AcmZajXB0R80HxZVnh9ZOd4mLf3aY9vNOlfFrGfq0Tk/tAlGedZhzWoc9ADX1+XBLoiZ hmSLPw5+EQ5Frb5x7hwsHnQPFIZjf7Gk25jpye9iRmtsGv48276Ujq2zxTSpxCogEJp2 3eSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720430615; x=1721035415; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LBi2SePDUDL2U0in1AvntQvb90L94gT0MTYcEwNyyCk=; b=Rf1pUQ8vpA5AWxjdyiC0QcPGevHHLwSoStWyUfXvEaZvlFDQB+QbH2c+5GzmLr+2IJ /+SnWnyjFQYWLQGVNcwBKlfynF4dVoVE+88iokFQvIZRf6T/CESaGitivg0kgxe8mZRe Vg4k02EfTgmafjU+U7VEcGKZEGzHMUlw+BSui7P1QBYFsqH/v+bwVAVJnERf2Yd0aidE n3WfGJSLw08ANC8MYBu/KKGUl5qGW1VhB2s4zMbcJrRLWLqf7Z/zXttlanrGYIK7slg+ YVd6zc3IzERozA/EKTBoX4Kg+0XoMt4m2INAusJoRfUAujs4sF6oO1OJxml30PCy+MmW UNqA== X-Gm-Message-State: AOJu0YyRZHDhPOQhQR9QHHT42w2UgfZ09+W07oFK7JNwVcfCptNKtxSx KvFKLx5qh0t1dpRS7Ycb8XxdBo4vhm0V2y+NeH+ViNP3I/9tG59bqt6smy2U X-Google-Smtp-Source: AGHT+IFw1YCXba8vSLoPkyQ7XsNi/f9Mtg6WQDn50R10FL4VdR4HYq617ChOFQZLm4flOQEf7B3eJg== X-Received: by 2002:a05:600c:354f:b0:426:6714:5415 with SMTP id 5b1f17b1804b1-426671454famr26303865e9.30.1720430615421; Mon, 08 Jul 2024 02:23:35 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:1d0d:3d35:3ae6:ef05]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4264a1d5116sm158259935e9.10.2024.07.08.02.23.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jul 2024 02:23:34 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: git@vger.kernel.org, jltobler@gmail.com, chriscool@tuxfamily.org Subject: [PATCH 7/8] ci: run style check on GitHub and GitLab Date: Mon, 8 Jul 2024 11:23:15 +0200 Message-ID: <20240708092317.267915-8-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240708092317.267915-1-karthik.188@gmail.com> References: <20240708092317.267915-1-karthik.188@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We don't run style checks on our CI, even though we have a '.clang-format' setup in the repository. Let's add one, the job will validate only against the new commits added and will only run on merge requests. Since we're introducing it for the first time, let's allow this job to fail, so we can validate if this is useful and eventually enforce it. Signed-off-by: Karthik Nayak --- .github/workflows/check-style.yml | 29 +++++++++++++++++++++++++++++ .gitlab-ci.yml | 12 ++++++++++++ ci/install-dependencies.sh | 2 +- ci/run-style-check.sh | 8 ++++++++ 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/check-style.yml create mode 100755 ci/run-style-check.sh diff --git a/.github/workflows/check-style.yml b/.github/workflows/check-style.yml new file mode 100644 index 0000000000..27276dfe5e --- /dev/null +++ b/.github/workflows/check-style.yml @@ -0,0 +1,29 @@ +name: check-style + +# Get the repository with all commits to ensure that we can analyze +# all of the commits contributed via the Pull Request. + +on: + pull_request: + types: [opened, synchronize] + +# Avoid unnecessary builds. Unlike the main CI jobs, these are not +# ci-configurable (but could be). +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + check-style: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: git clang-format + continue-on-error: true + id: check_out + run: | + ./ci/run-style-check.sh \ + "${{github.event.pull_request.base.sha}}" diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 37b991e080..65fd261e5e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -123,6 +123,18 @@ check-whitespace: rules: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' +check-style: + image: ubuntu:latest + allow_failure: true + variables: + CC: clang + before_script: + - ./ci/install-dependencies.sh + script: + - ./ci/run-style-check.sh "$CI_MERGE_REQUEST_DIFF_BASE_SHA" + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + documentation: image: ubuntu:latest variables: diff --git a/ci/install-dependencies.sh b/ci/install-dependencies.sh index 6ec0f85972..46fe12a690 100755 --- a/ci/install-dependencies.sh +++ b/ci/install-dependencies.sh @@ -43,7 +43,7 @@ ubuntu-*) make libssl-dev libcurl4-openssl-dev libexpat-dev wget sudo default-jre \ tcl tk gettext zlib1g-dev perl-modules liberror-perl libauthen-sasl-perl \ libemail-valid-perl libio-pty-perl libio-socket-ssl-perl libnet-smtp-ssl-perl libdbd-sqlite3-perl libcgi-pm-perl \ - ${CC_PACKAGE:-${CC:-gcc}} $PYTHON_PACKAGE + ${CC_PACKAGE:-${CC:-gcc}} $PYTHON_PACKAGE clang-format mkdir --parents "$CUSTOM_PATH" wget --quiet --directory-prefix="$CUSTOM_PATH" \ diff --git a/ci/run-style-check.sh b/ci/run-style-check.sh new file mode 100755 index 0000000000..9d4c4089c1 --- /dev/null +++ b/ci/run-style-check.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env sh +# +# Perform style check +# + +baseCommit=$1 + +git clang-format --style file --diff --extensions c,h "$baseCommit" From patchwork Mon Jul 8 09:23:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: karthik nayak X-Patchwork-Id: 13726323 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (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 46F4D757F2 for ; Mon, 8 Jul 2024 09:23:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720430619; cv=none; b=QDijZIFS9nriACMtl3JxTaBZR1PqK2cnCpNhWG6ZS+Wo0aloUde3pdeCe90fuvt2ob8TSr75cf/VTaO5qY9lh2nPSBwXrXGoFqQULleKejK+jL+dyEqAUtPhlP/hGvc4RxfanoGQjoOrSJ6C6ooMbQqkLJMmrdEqAut+obzDe8c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720430619; c=relaxed/simple; bh=VeJxIRsjISRNbv5JYbmQu0zbRXh6VF4TW1TD6qQ2IJY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OEGPWzS780ZR1zdWvv3tS5IUWETaiYahrpvIu6ys2/AkbX/ePEzuMUbFH/dzjESuLoH4VAg/uUzKvQdM9Ztg/DfimiDvBiVdCkACYoalDoTWurvwVIJPQBbHurH7SVapItiaMxsTal1fuo3mFqRYYUECcxdwfrW16/+q4SQdWu8= 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=ENRC0RYz; arc=none smtp.client-ip=209.85.167.50 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="ENRC0RYz" Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-52ea0f18500so3589965e87.3 for ; Mon, 08 Jul 2024 02:23:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720430616; x=1721035416; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yJYAAQipJrEMzwO6yMCgrGXChfZGqcqlxIj3SuJWz/o=; b=ENRC0RYzzeZSH9Hw3Od80Ukw3+44DZbCY8mCvBnLZKiucqtyrM9vlBSJkaWkB3gBEJ oHGvOytKwaXrBkkmD+KiWngyTUlrSlVoipSuLYL65QD+z50mnzRrAKcvAaKvyxgo7sh0 aomd458vAXfNPUC0u7KqORlmUn0iuYrQlhTEh/a/T2n+JUxfp2JI+oniNr0dxCA1eRFa ulVWBNsrnbfR149YjRprqHXUEBrSXPJCL9g6ihmRhJaUFbfpXA6InodBAf7//NEMsACC 58Y8rU9Rim5lANpUR6VuAf/KHNVOAmNfGVy52slBFxuaTO/LTChMzKPxTBFFdCixlrky 2BSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720430616; x=1721035416; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yJYAAQipJrEMzwO6yMCgrGXChfZGqcqlxIj3SuJWz/o=; b=c/ymYGD05+9tUw1HzTUaZyLf+XxQa43WMUR/qionFWyCL6hYQXk0jyOsuEZQ0DGr3X IIubtywJu5tcz5c6c7kgX381MbXTi6DPPkgQalU9fzaK31jRSqA8c27cO85NWbX3lOfM 4ljKPePL67EstNcdzmkFBuHg2Iv8BEpU/Ybxd25nzwqJbF5iyhPIixD+Y932PjaXqrOg QaDXpPsco53Pz2KSul5TYIslRU068irMBV72896nCI0JgTG4Ytdt2uMsehMK27ro63J3 YqvMX2XRhnKVfbHOImcyqbgOTCAJNYhFkMA4fPf9FYmTZvY2j7yJnUGEb+aPY/gG7RSz 6ePA== X-Gm-Message-State: AOJu0YxCksYVpbtj7pxeHCwjwY49BP1lN01nK2nMHbgblNpVUqKC21de AImyMcUvpcDda/wWGMXo+E7JRjRo9sXazyGmJ6zMqxBXEJ20d8q/ X-Google-Smtp-Source: AGHT+IFSUWTjPZoBLqyg2tPZ8E4FPxnxhzJhfD2qs+IlM8HE/z6SGHh6kT9upgfpCmQ4Q2vBD7BhUQ== X-Received: by 2002:a19:a412:0:b0:52c:dbc2:ea1 with SMTP id 2adb3069b0e04-52ea061f5b7mr6717372e87.6.1720430616418; Mon, 08 Jul 2024 02:23:36 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:1d0d:3d35:3ae6:ef05]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4264a1d5116sm158259935e9.10.2024.07.08.02.23.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jul 2024 02:23:35 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: git@vger.kernel.org, jltobler@gmail.com, chriscool@tuxfamily.org Subject: [PATCH 8/8] check-whitespace: detect if no base_commit is provided Date: Mon, 8 Jul 2024 11:23:16 +0200 Message-ID: <20240708092317.267915-9-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240708092317.267915-1-karthik.188@gmail.com> References: <20240708092317.267915-1-karthik.188@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The 'check-whitespace' CI script exists gracefully if no base commit is provided or if an invalid revision is provided. This is not good because if a particular CI provides an incorrect base_commit, it would fail successfully. This is exactly the case with the GitLab CI. The CI is using the "$CI_MERGE_REQUEST_TARGET_BRANCH_SHA" variable to get the base commit SHA, but variable is only defined for _merged_ pipelines. So it is empty for regular pipelines [1]. This should've failed the check-whitespace job. Let's fix the variable used in the GitLab CI. Let's also add a check for incorrect base_commit in the 'check-whitespace.sh' script. While here, fix a small typo too. [1]: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html#predefined-variables-for-merge-request-pipelines Signed-off-by: Karthik Nayak --- .gitlab-ci.yml | 2 +- ci/check-whitespace.sh | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 65fd261e5e..36199893d8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -119,7 +119,7 @@ check-whitespace: before_script: - ./ci/install-dependencies.sh script: - - ./ci/check-whitespace.sh "$CI_MERGE_REQUEST_TARGET_BRANCH_SHA" + - ./ci/check-whitespace.sh "$CI_MERGE_REQUEST_DIFF_BASE_SHA" rules: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' diff --git a/ci/check-whitespace.sh b/ci/check-whitespace.sh index db399097a5..ab023f9519 100755 --- a/ci/check-whitespace.sh +++ b/ci/check-whitespace.sh @@ -9,12 +9,19 @@ baseCommit=$1 outputFile=$2 url=$3 -if test "$#" -ne 1 && test "$#" -ne 3 +if { test "$#" -ne 1 && test "$#" -ne 3; } || test -z "$1" then echo "USAGE: $0 [ ]" exit 1 fi +gitLogOutput=$(git log --check --pretty=format:"---% h% s" "${baseCommit}"..) +if test $? -ne 0 +then + echo -n $gitLogOutput + exit 1 +fi + problems=() commit= commitText= @@ -58,7 +65,7 @@ do echo "${dash} ${sha} ${etc}" ;; esac -done <<< "$(git log --check --pretty=format:"---% h% s" "${baseCommit}"..)" +done <<< "$gitLogOutput" if test ${#problems[*]} -gt 0 then @@ -67,7 +74,7 @@ then goodParent=${baseCommit: 0:7} fi - echo "A whitespace issue was found in onen of more of the commits." + echo "A whitespace issue was found in one of more of the commits." echo "Run the following command to resolve whitespace issues:" echo "git rebase --whitespace=fix ${goodParent}"