From patchwork Sat Jul 13 13:45: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: 13732413 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.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 3D669446A1 for ; Sat, 13 Jul 2024 13:45:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720878325; cv=none; b=MF2SgYR0oehQ9szh5b50+mSqfuXhF+7SpkGMxGKquAlE3P5XKHPhjlEVWo9K5a7jD4pQ74L+uHg7nJXmDeN/YuyXxpeDXjRCPEIGyfrza52H/AuXvQk9MWyAbK8lLo/L9C5k0E/weWxD14vMsXYNTv49sf7d3DYj+01YrXrCkPE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720878325; c=relaxed/simple; bh=fXYkwyyNJCLwx/1+LXMILAXgVK2bnFuuMMrPjySB8G8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gRsMewhTOrpoLSdZWNdVtr+pVZvXs/ie+nc56Y7cmppGAkE2TvbcFNV0HGDu74vzJePgK5kwcEX6bGVXIRzz+vtgSKBCVwZy18aPzhYuoPWkC836OauiEDyFlD45K179bca+Bsd2LpvxDxznBggvXW3X7RrXQBQ2OlDaqo3jFTI= 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=k9Uk8nVZ; arc=none smtp.client-ip=209.85.221.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="k9Uk8nVZ" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-36796d2e5a9so1749446f8f.3 for ; Sat, 13 Jul 2024 06:45:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720878322; x=1721483122; 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=IXE3MYu8CxgvrX1p6ggHUE0kt8dF7SAUpXUFx2O4fgw=; b=k9Uk8nVZ4GljDFeQ5da1YUfulwhzUDfqifh25CH6ZRq9hTgTxTgZi7qtHkz1QWNYSg 0Z7zAejJ1Q336QyD3cB7EHeWYE0Nv445hfDwoLZVVfIFDMTeJ+4kirplitrB4B4oytQj pcUzO/VC4M2eiq9DxcHI7zW/CH/p3S4XHY/+yU2e1RVj/Oq4dEk7dO9rGm5nyNnpmNN0 R+DYKojGQcLN3BgoRHS89JkxtjqXnh5hwXyQnkWoZNPWYo8/n4Iyd8VEsFdAADSnAh2l nGIAJ2KGqjljh93vvJ9kC5NqGG8uTmqnYY0C6BknEgnTQrNdQdD9eFm1k4GCdIGgt/OD sROQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720878322; x=1721483122; 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=IXE3MYu8CxgvrX1p6ggHUE0kt8dF7SAUpXUFx2O4fgw=; b=U2k3iilG3mqaaHosfvR4xwGx/ZigE4Pg1sQHrSL/Pu8eVrWt7Q8ZNUkfFGTF3b+s2d EAkwDjLNxEbTj7Z5uO5MKAxZy7IR5VMBSVgiwdxOunSh5gSJWqVnLOsVXKCS3DNZ4Tz3 PF9uJ1ox1ifoUf9wPr3HGaFy8HpkXzxV99qLVbgxSJtoEKrxfNI5I5s5jqb4rEB2ET46 OnCM7/jRkhf6MRgT5rVP4BYp3mUvnc9/Czlj2gDsMV7TR0gg927fytpZYlIi3FW7LLQ1 MoN1qWHqIXqdk5MEDhA/ZVKU5fxRaAf8teKSYCIbPAaYNeqJ4owUfdftSbS1v8QNmLkN xchA== X-Forwarded-Encrypted: i=1; AJvYcCVuc2V1VP+4sUwx42dRsFp5RX+6bsDGxIPX2jhny9G/zdA3fv81Fc6Db45B3meaRdm/dCP7Ehhmq7xPjNrcrGzLO/71 X-Gm-Message-State: AOJu0YzvUi6PeLmFTO8zsjOSEb8q23UYcSRdXMkfc4PDVWSwKGXzdJTM cZU1/0nYNIQgmcUPEIQRpa+WirAEM178pL0BScdPcqMjOGbjNOQ91XcZn6cd X-Google-Smtp-Source: AGHT+IE7aRQqK1ff7hjDyYrbDGL7x1d3YjeGU4PSVE8zTUFuJFtU7ysdsQUiTcAnKQmwOaeES+zqJQ== X-Received: by 2002:adf:f348:0:b0:360:7887:31ae with SMTP id ffacd0b85a97d-367ceacb451mr9496911f8f.54.1720878322304; Sat, 13 Jul 2024 06:45:22 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:cb20:918b:a998:e5da]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680dab3bd8sm1440325f8f.13.2024.07.13.06.45.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Jul 2024 06:45:21 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: chriscool@tuxfamily.org, git@vger.kernel.org, jltobler@gmail.com, phillip.wood123@gmail.com Subject: [PATCH v3 1/8] clang-format: indent preprocessor directives after hash Date: Sat, 13 Jul 2024 15:45:11 +0200 Message-ID: <20240713134518.773053-2-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240713134518.773053-1-karthik.188@gmail.com> References: <20240711083043.1732288-1-karthik.188@gmail.com> <20240713134518.773053-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 Sat Jul 13 13:45: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: 13732414 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.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 2DD894502F for ; Sat, 13 Jul 2024 13:45:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720878326; cv=none; b=t7aotuqHwlCbr/ubb5ZJYwb9ef8rMWMFPGEwQkWMNCe8W15LxwYnn2Tzydosytcs5WFvSFdSdMIasKaQDfBlppIrz9P04zoDQxxxWwV1PCdvkxjN8O5NpW4ja/m16CSf2+M4h3VAsPyyDDwaUwfteYFmXv6QtT1W+SmcEPpw6DM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720878326; c=relaxed/simple; bh=c57a5FZo8oc1XwZXmAykTqE3C++vUFM1nNGdVk7APJg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AzXjcHz6+eLM9c3Jkyb910m9N2a7HuQeyqqKA2kZU9t58R3rowYEvgVhxFSz0jtKVIZ5n9bdWgrs442i9CeHwTGnASunB/VIqmXGl3PVZ+eoSQITAolXeRBJlx6jQijct0KXjzXNM+geFwAQq4s5Lws4V0vnjfNqI5EBpOKSvuc= 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=Q1GooAO4; arc=none smtp.client-ip=209.85.221.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="Q1GooAO4" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-3678fbf4a91so1499289f8f.1 for ; Sat, 13 Jul 2024 06:45:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720878323; x=1721483123; 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=dGFI5dxykS0Ye5JgwzTOfeSKS/2TqbyMZWuGeO3hO3Y=; b=Q1GooAO4k4NPGIuUlWP1F0cknktGEXAl1L42W1KmP844hgOTcMmWAWWVZlh7/n5riB VU+dhJ+D36+5VFp42c5y89Dn3U6aBvIYCkjbOArA7aK0dWcG2/B6pWtnOl7ZdBdA3bHl X+FGxGlVXZlwjpdWrrPaWRrMBgJRGmKI+4ak+JN0ycBlCfuPSUUzJyMaE9/XN1xYSe27 7udrSw5melP4eFOhlkkdkFjYUDnlKiALXbXSY8atALAgfelWLrJWPkv3HKd4cHi2xRDm FzBNfNlP5dLnW4RqP8j9VtECxtktzPHsB/poXFidi8MExtNsLAFE64F9VXeVmrhsdRqF DkoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720878323; x=1721483123; 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=dGFI5dxykS0Ye5JgwzTOfeSKS/2TqbyMZWuGeO3hO3Y=; b=m/1EMeyb2Pdp6fQwaEsFGokvJx7kaWvqnWOEU4lHoLRQ9KScxgR3e7rHncrbqze/iI xXa7ZWzEbdCYaKUKwSxKw8s76tfN2OaJhZPwUQQyK8Po8EwP7NP1UUWGZ4TikKh8pChG Jc7r4zUk6wnPC3LScF6Wo8QfIl/Co+7724P+gErKVtMFuKf8eT0VHtIJHUnuP9KdXlSQ ik10jAuVaLO2VUlt8DHE3VFlcVoR3PusFDYq9mY0CVPIUsRBS3iQjkEAc6jJyr/boAXa uz94koObz1NEIl2Jv99kd/2uePCJVUGTubZ+R2cP1kDMS/Pj23gml8oCCNYMUnN6jq/f 5WBA== X-Forwarded-Encrypted: i=1; AJvYcCWj1as8DyX/x0DVX4aiZNXMHZuHK+/tUTH/xzrI0vorAVFrT1bbjQv1q8ro9S1BKJTSlAhLLuTodnTvPWmGgdx4aniA X-Gm-Message-State: AOJu0Yz24oITo3cy9X/9zetkKfGGqv7vk84noCksE7uwyON0XcLRkwDs tLAaaMH/6a8vyI9s6Yu3ZfeUP6AwKAZGSBB+1T+efFvDACz6iXdi X-Google-Smtp-Source: AGHT+IHcUfQ1u9Lc2P+Jz+2xR+fUkCVlda6M/yzfdzjqGfNnNKiF1zoN8B8dZvU7lvj+8Pv0q6F/Bg== X-Received: by 2002:adf:fece:0:b0:35f:48e:fe59 with SMTP id ffacd0b85a97d-367cead9455mr9592571f8f.66.1720878323549; Sat, 13 Jul 2024 06:45:23 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:cb20:918b:a998:e5da]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680dab3bd8sm1440325f8f.13.2024.07.13.06.45.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Jul 2024 06:45:22 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: chriscool@tuxfamily.org, git@vger.kernel.org, jltobler@gmail.com, phillip.wood123@gmail.com Subject: [PATCH v3 2/8] clang-format: avoid spacing around bitfield colon Date: Sat, 13 Jul 2024 15:45:12 +0200 Message-ID: <20240713134518.773053-3-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240713134518.773053-1-karthik.188@gmail.com> References: <20240711083043.1732288-1-karthik.188@gmail.com> <20240713134518.773053-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 Sat Jul 13 13:45: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: 13732415 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 3797613A25B for ; Sat, 13 Jul 2024 13:45:26 +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=1720878327; cv=none; b=LgGUGnhEqmEqk14ZPHFp3gMSb+1QbjgpADMOrD/8xyizOyoEc9fa2e7YK4bcUjl6oY/e4Jz6nQx6vWe2XGbECv+KNCwzOt2C+aTa4U4HoFiQIWda+BhoUFt1Mi42BeJbOoF2jPLl0xwDShmEyY1QXGU+SqM7fnL3TpiRKtP0x14= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720878327; c=relaxed/simple; bh=mGKp73t1gDNv5XhEYpbWC9ylOVN74pdxUlMqwbrFvRs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KVzU+iSOxl2wMTM0dr8VV5aTnTl120MZ7PL8xmAzO8SrbXA8KpGmrmko228LnX+iMM6E7kQ2V0b9QTLsUyFzZT5X9lkXsmydE3id7kqUigQ21KPPj+51yGGVgQHVfDOTEfwwKcV2VimNBtStQKrw16lP4RlJIqqRSS0tJILdLFc= 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=MfGU+66W; 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="MfGU+66W" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4277a5ed48bso20910165e9.2 for ; Sat, 13 Jul 2024 06:45:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720878324; x=1721483124; 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=QEj4J1duXKauf+ZuSbER3cN37XrHK4JaDZdLoIf88LY=; b=MfGU+66WfsLZc3Q8vz9+mWJLCk077pGW0H4y8l4RG1q2Z2xySJppu3/3EkS1UBWNHN 4/RTLOg8sZ/kQ2CcogBQA8ooaBn+Lu8BzCHAu7JmFJBNNo+jhF2yOmK4kalpRRYQnWrm 4+YtWjwQUVhPIpzESpVhQg1l8j7WO/YH2mc9+Bnr6y7myFIwCg5pY6xvfmyNXUYuKsur WNl3/uSIiwEQASeVGT4VsC3of1r0M5fTiFBWg3i9C4wZDvWMSCxyOItiVfxbKCKSDPCa Yp8Q/lk6NjkvnQAb7juOtb+cpDJWXU4CH7i2VM/iOGnxtiIhd1VeLqNEJeWkcZ+IUmvS xKpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720878324; x=1721483124; 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=QEj4J1duXKauf+ZuSbER3cN37XrHK4JaDZdLoIf88LY=; b=fkx5WFhJGN/ZBGYT+Anapp5z5vRePu2rrixOH04vyMhFBe/hpylmyR4Q6i728W/Xc9 NrIGrU12Z5xHhi85n7QcEoWOZzoWMu8db8+kbbKMMiXFGtXsBjQ1yE73zATDCHzOS7og YH1Q80uFyn9c4Yq2HfzJrOCBwO4YWxqblCixMieWt8ZXRwXKEj2X8IpBW9Tv3IuMwE+X wVBBVRS9GoMtW9jk5RDqv6KZTm2rufCIo8qcfOXkjh6EEDkK7KV3AVcoVEVALhiceemC Gr4GXNnHeHNbKmSWEGHCSDGUtWFuq9auvORd+0ZnXNEOReWTESsCFam3D0INh4FQREaU ZXMw== X-Forwarded-Encrypted: i=1; AJvYcCV5vFwLQDrK/VbMkW0NyNrAGpLSTDI92bj43QCaluAP+K2LBAlc/Bzbn7W4s8u5PXj0sDMLgkX/IRA6dJqlKzINFEum X-Gm-Message-State: AOJu0YwV8K74G9tJPio72NiKXuIVFuUtLYD9BolZ6SgpkdsG7EzomIrC pJacekwCol/YyK3QuDpO8GFeZ54wIv+dMuoz33X4PrK7ifh9Cc6yRFbrBNwK X-Google-Smtp-Source: AGHT+IGhTj8fD0tUqpbWVKpXLHMpHAaTfvk8DSlizobxXavTQOIlMnBqJMbBIjrR5PUQB/RHK59s5g== X-Received: by 2002:a5d:47ac:0:b0:367:9769:35a5 with SMTP id ffacd0b85a97d-367cea4606bmr12888552f8f.7.1720878324479; Sat, 13 Jul 2024 06:45:24 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:cb20:918b:a998:e5da]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680dab3bd8sm1440325f8f.13.2024.07.13.06.45.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Jul 2024 06:45:24 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: chriscool@tuxfamily.org, git@vger.kernel.org, jltobler@gmail.com, phillip.wood123@gmail.com Subject: [PATCH v3 3/8] clang-format: ensure files end with newlines Date: Sat, 13 Jul 2024 15:45:13 +0200 Message-ID: <20240713134518.773053-4-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240713134518.773053-1-karthik.188@gmail.com> References: <20240711083043.1732288-1-karthik.188@gmail.com> <20240713134518.773053-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 Sat Jul 13 13:45: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: 13732416 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.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 9B16213A411 for ; Sat, 13 Jul 2024 13:45:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720878329; cv=none; b=LcgLln+NOl6QbBnuVMhddMpd5KxzW2nbIBxwkzwpg4WCjvqrdAeoCNJiHSQ/EjoOX+TGo8W56gUsiwQuhhT5Qa2Zv70qM2EtGNC8AtiuQUo643u4U1Pzlx6OeZ9bc+kZlND51V4kQogj1Grwa9Z+7n8Qst8YhSexCIUAFRZVpw0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720878329; c=relaxed/simple; bh=S7Zo/NpUORndOH2vsbJ5V3SdVDxmqCwBMRY0KwgBPmI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YdCCLMCFZsBMDVhMlOwrp/WlrKtlqRFRnRfHzmYWrrDzIshiqztuX1wj+8eedXysGNoNe8hibZGrYofQabFo+i/N7Zy7OObsNuk8OWj6SettBasSyJShtOnD4J3x5hi4tiTUQZxTPu17R5bfdh8EtXPpN/loXHIDGLv5bcG8QlE= 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=a+ccya8g; arc=none smtp.client-ip=209.85.221.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="a+ccya8g" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-3678fbf4a91so1499303f8f.1 for ; Sat, 13 Jul 2024 06:45:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720878326; x=1721483126; 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=0wNgL1+hL+/hGwg4Th2qpdX12s/4q4BWBjTK648i1So=; b=a+ccya8g+z3Ng1fTeW8oQP5P7yEBgaXLJ5VwZ96ao08ZYLd2yFuCtlo+ZouIHHYyNh /3+Sx8N2zQMnBKFB+0Zp4wlR+wt9wofqhCgfeHyKJZA9c8upaTfVJHVfdvF/oBqU1hFo QXH5077q3bxsBl/lxpplMagYFzGc4nOvmnZVg5lDa+O/YbefuVMvpOpkCfwroThnExF0 YHw9PdrDaSlTZuDYKVI605G3gD3VGWMEIsXcLsTrgrpmTGmQzyX0znYoQmmFGCNjUsG9 Y45J8GQdaA0qYIYmqvhX3YwFZsc5zl+jjrJgZbn019eNvwmMQTH/9/maoJZbTtQoBxCO tBsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720878326; x=1721483126; 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=0wNgL1+hL+/hGwg4Th2qpdX12s/4q4BWBjTK648i1So=; b=kTeDNdr00qi1aD4r35DTkRrdd8eMXdrgQYt9wcnjHXXJYXXwZVQzYUxi/vFFg3Wnx1 JAMxsAmTx6qwWTUkc+Hk6Q/9uKBspoI8N0l3UfVXQ6Yg/9gdGeSJUkT8l3okkY598xGl 2LYiioPkTvEmmswAEOxAUfa0Bn5+JmFEBdvOYYVFo3eQqGDk1AusReJWxlwUWqFZ3VOB mlV+3P/AY0QpqOpUU+Ww1q5JqPVA2LzkL3sqP0jRtCt5ZCUnhMO31oEiX6f9tgO0NG2f fiGrM45Jsyg5C5TN4rSRUlrWnFH7H2v231Ov95Crrgw2nSH8P5kYkLmzUdPjcV06E3p6 iV0g== X-Forwarded-Encrypted: i=1; AJvYcCWcLBI3bVGu7qsfjsbZu8mOLSV4DGYe8Nsrw1tqIBwautMVNERquWecT/fRfBSi0NXs5T78laK9mhtqzPRwyMrDVEWF X-Gm-Message-State: AOJu0Yy8XlUVs2u8cVHQWTTN83nBgbFllfqMd1iTMBkGkWViA1o4a5dv YBO3gDY+GdEWOztvb/iDBKFgf2bNytOhTdnB1d4bEKNzMMI9psh3 X-Google-Smtp-Source: AGHT+IFaiLYhiKlf4EhzihAO/hyGC7F28feOsQWOQ8mEV6zM860dhEaDRGQItMhOw5Fy7xT4LlepSA== X-Received: by 2002:adf:a79a:0:b0:367:951e:595c with SMTP id ffacd0b85a97d-367cea7386dmr9753782f8f.19.1720878325832; Sat, 13 Jul 2024 06:45:25 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:cb20:918b:a998:e5da]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680dab3bd8sm1440325f8f.13.2024.07.13.06.45.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Jul 2024 06:45:25 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: chriscool@tuxfamily.org, git@vger.kernel.org, jltobler@gmail.com, phillip.wood123@gmail.com Subject: [PATCH v3 4/8] clang-format: replace deprecated option with 'SpacesInParens' Date: Sat, 13 Jul 2024 15:45:14 +0200 Message-ID: <20240713134518.773053-5-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240713134518.773053-1-karthik.188@gmail.com> References: <20240711083043.1732288-1-karthik.188@gmail.com> <20240713134518.773053-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 Sat Jul 13 13:45: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: 13732417 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.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 C7A3713A889 for ; Sat, 13 Jul 2024 13:45:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720878330; cv=none; b=nQCuxbaZWXtKhyonIiXxpm/tdsS/FE6/WgHeYHvxob/lyu/WVPf8MD3hWN/+94Yuc6HEvSUSRC1tCcBddGkhSzzp58IOdCqi/9K7f6DQPP1u30DEs13yJ5bjaj/yTGv37ZDyecg0kUdc1hB73rq3UeWRsJOrG1PuTQ0S3/TH1G8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720878330; c=relaxed/simple; bh=NKLRjRIvuJP94W+tCj4VNJ0/Xh/FWZbhInoDE+UGwyQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ClGXz6E1fYE2jykctLRKHKp6iCJYcaI1QaLYQfZOHnM5vjZhwaUi4vf4FScgg87UnTB2tYvLo7n3uXbTpkl8eQuK+LOwKLHpfBmg0kkLqZGmFQt3w6NzkFtGZMCEtTR9L/EGe4wRC8yOlh+G1mJDZxgEwTNsfVYvefCcbX+Bya0= 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=WFxF5znA; arc=none smtp.client-ip=209.85.221.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="WFxF5znA" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-367818349a0so1638067f8f.1 for ; Sat, 13 Jul 2024 06:45:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720878327; x=1721483127; 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=KWpRRpBwnZmw3yWd0ypb6JPNeFDHxwHjwgCkp69QJus=; b=WFxF5znAQUHYP/3r2vUJ9Kpgq2dpq1FBsLAb1RmQewb9bxCXbf877qzLixjTmdc9fN OjqFkoqyataVWwHdzLuNkc6cfwyobcg0wjW+ZPCEIR836BYPTc/CB81fYZmSAQok7Dmb hOqlldTcJNf5D2wRFJulbExs2wPJb66YZFqadbv1zso5KRX5SsOQUHyGNH09+4pVxbvu BOsinMQcVGUcnzmrnqotCkZN3vdUqryJwmBNzbw0Pif/ueoGGq8MJjV98ajrQo0P1O9I XwrJ6zGUyKp9vS11RB8JRE1M+HovIzjUypwFJy+Q27WarZTn+Kp0yDX4lZ/B99SoF07g 8uZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720878327; x=1721483127; 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=KWpRRpBwnZmw3yWd0ypb6JPNeFDHxwHjwgCkp69QJus=; b=eDrllkvuNNnPb9DP6brrF9VHKzLQcFdLJzO/PvCt0dt4FViBjOJ1YpKP7jykA/v8Zz cepnSYUiaYNIYBQhsXwSNsbIsUAjHWKkWeaKa1C2EhBR94rkZkxaC83EOqrFAP8IIwmz TDX0cpFrp7shHNHhft037NosywpikQj9MdX4WNUm7BQMckFpQSr49UGIslAiG51GBXm2 FnG3HIjaSoycI0MlEtVnrVTR2NgXxkEey+Q8AtSW/Y0rf1Y25pFedZIAwx4LDZIdwYrl 5H1CWylRVZ/nsTPc9itI+9KX9MJMtjyJbfCG7df69SFuyvZtGWldgO1N/hOVWLMHeNgW H5PQ== X-Forwarded-Encrypted: i=1; AJvYcCV7Ig9ZZoRYEGwtvI7xqs40sHPAxKxcmoyEHyGNuo+LHPgVvjBJPZwcPZRbT0B+o2T0clk8zeHT2pC/1QE+qMxVUEqo X-Gm-Message-State: AOJu0Ywl/ZgDke0Pdj2gY/0rd27ppqqnj0wdeGhBQAEG1FVBTiv7hXhz HOo2/jfTN5Jpa2TFDIkDiTub0o0jK8oS1ofcd+uRX3LFuInAPVEj X-Google-Smtp-Source: AGHT+IFbryThF5soWxj4jy+cuNMQtrk75pkUE8GiwEoAOGGMHlIzt563idvcVgF85tw6BoHD9+oV9Q== X-Received: by 2002:a5d:4750:0:b0:367:fb86:c2f9 with SMTP id ffacd0b85a97d-367fb86c436mr4576767f8f.30.1720878327097; Sat, 13 Jul 2024 06:45:27 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:cb20:918b:a998:e5da]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680dab3bd8sm1440325f8f.13.2024.07.13.06.45.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Jul 2024 06:45:26 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: chriscool@tuxfamily.org, git@vger.kernel.org, jltobler@gmail.com, phillip.wood123@gmail.com Subject: [PATCH v3 5/8] clang-format: formalize some of the spacing rules Date: Sat, 13 Jul 2024 15:45:15 +0200 Message-ID: <20240713134518.773053-6-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240713134518.773053-1-karthik.188@gmail.com> References: <20240711083043.1732288-1-karthik.188@gmail.com> <20240713134518.773053-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 sense to formalize them: * Ensure there is no space inserted after the logical not '!' operator. * Ensure there is no space before the case statement's colon. * 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 914254a29b..a0dd1f2eb9 100644 --- a/.clang-format +++ b/.clang-format @@ -121,11 +121,18 @@ PointerAlignment: Right # 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) { @@ -134,6 +141,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 Sat Jul 13 13:45: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: 13732418 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 C1A2D1386DF for ; Sat, 13 Jul 2024 13:45:29 +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=1720878331; cv=none; b=t1aU/bhmBkwJQUSSEBgWcKmWIq2czETeydNn6CPXcVFVKHKaKQffCTQrYvLDAB24WvjBIny0VC3FUIb5xm5x9zUPauY/KJqtqhDM+S5F8T9JlR794aToV9qieyzJ3fGYbBWezE5l/Zl2NGDTNiWC8IHBjW2u9nOjG5lHRaEYoxU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720878331; c=relaxed/simple; bh=aGdl7VU6fu87AxZSW/5vme8YBNWVlJShsiPuSUTfeuA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R53sxB6H/YEelEa2oG0d4Jyj9wwaEjQzmzCsk3Z1eWdOAZfKOZAqvZjbDDA1ieVV0DEqBbbMbuvR3SA+Tjc81bkvztwfoI435nBcccS37HvBQdCQCaQNo7792k+q0d3+rU+/O1duZV7tzblJXKKJ8E5kAnOTzqfCceI+H2/ZFz8= 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=m0JFdv2c; 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="m0JFdv2c" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-42793d4abbbso19619675e9.2 for ; Sat, 13 Jul 2024 06:45:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720878328; x=1721483128; 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=51UjLfdboabiYtuKEd6+VeM1Ku67vBrIRynYFTxwLuI=; b=m0JFdv2c+QYJfsLP5jqtzoHnfm+r/FMHMULUZIlelVOWcmax3T+L18nOyXywdnyEXs 8jJrI4kZLm8kMviqykZF+8+sqS/3ujakFw/eOUAh6LJ/yyPUbaKKgL6YZ7kKZxUTiIpc b04V+4O4loIUSChEnMuheCEPag/U4xW9Abn0QAZD1MP7oOr6va9N+GwMveOQ3FgM9olg mOcWFQx8bxl9Lmv/IilMvjWdG4c/jpZQe9B8kNuPBMXVWntsF9f7gH/GeKmjklr0yTic ZKc45JdAoGmrwaKq3UAknARjcl3dEiVH1ifNp4NC4AxULv3XMN2nFG9+dJEdaJotGa2D 9OaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720878328; x=1721483128; 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=51UjLfdboabiYtuKEd6+VeM1Ku67vBrIRynYFTxwLuI=; b=c9ZJ8SIW6RbI/dSnAtqcTn4xW1EASFUJzV5cgC9DqeNEgB34o+z4ozy5LHtEPDqXq1 7Qez/Ry0uVBrX+ya7lBtmGfC+O4pGzIxl/sYLcue1/mADnfqlu7rqWdaUYcx6IjXujj5 b7LvXgYfTfusPSbFfbCH98COWng0t3icGfm9GAzjcs2353127/ZlgOXW1KM4tSjj6/TQ lEEcA70iKKYwvHLgn3xJWsNstMpXYyOIKubVtGFMMMGfOyucCxM/eYujgrLQqDrO57wI uCs3mvT22AkJcuAxVywMuvQXxb/rcvwke/5byobpj/E1FYw/IILhrg6BswYrTpuh4jjw 57Jg== X-Forwarded-Encrypted: i=1; AJvYcCWMcVBwfpqsSrl4mJsSmvg5c4iIZo4P1mhTZWEApuKhaP9hGstmsi20+cjGdJedgvUArsQymV9tXOGA+qldvwIg9D64 X-Gm-Message-State: AOJu0YxvmLPjnUwbUL7vm69QntONvJyv6XR+iBynt/k3PL9Rx2Ei9CUa mi3PY5lA2Tz2ijQmzpPVc55MaGgTJh9R++fyfK9xsXzeUryprgWAgoVLfIvH X-Google-Smtp-Source: AGHT+IHrDf0XRK2AihY0ZDiBtXRgSs7gVVnndwKF6PmSOej/vlIUTF46bmVQaQoZNLUV+ZX02uXUFQ== X-Received: by 2002:a05:600c:2247:b0:426:5dc8:6a6a with SMTP id 5b1f17b1804b1-426707d7fd6mr97289135e9.21.1720878327970; Sat, 13 Jul 2024 06:45:27 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:cb20:918b:a998:e5da]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680dab3bd8sm1440325f8f.13.2024.07.13.06.45.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Jul 2024 06:45:27 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: chriscool@tuxfamily.org, git@vger.kernel.org, jltobler@gmail.com, phillip.wood123@gmail.com Subject: [PATCH v3 6/8] ci: run style check on GitHub and GitLab Date: Sat, 13 Jul 2024 15:45:16 +0200 Message-ID: <20240713134518.773053-7-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240713134518.773053-1-karthik.188@gmail.com> References: <20240711083043.1732288-1-karthik.188@gmail.com> <20240713134518.773053-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. For GitLab, we use the 'CI_MERGE_REQUEST_TARGET_BRANCH_SHA' variable by default to obtain the base SHA of the merged pipeline (which is only available for merged pipelines [1]). Otherwise we use the 'CI_MERGE_REQUEST_DIFF_BASE_SHA' variable. [1]: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html#predefined-variables-for-merge-request-pipelines Signed-off-by: Karthik Nayak --- .github/workflows/check-style.yml | 29 +++++++++++++++++++++++++++++ .gitlab-ci.yml | 24 ++++++++++++++++++++++++ ci/install-dependencies.sh | 2 +- ci/run-style-check.sh | 8 ++++++++ 4 files changed, 62 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..14f9d3dc8e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -123,6 +123,30 @@ 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 + # Since $CI_MERGE_REQUEST_TARGET_BRANCH_SHA is only defined for merged + # pipelines, we fallback to $CI_MERGE_REQUEST_DIFF_BASE_SHA, which should + # be defined in all pipelines. + script: + - | + if test -n "$CI_MERGE_REQUEST_TARGET_BRANCH_SHA" + then + ./ci/run-style-check.sh "$CI_MERGE_REQUEST_TARGET_BRANCH_SHA" + elif test -n "$CI_MERGE_REQUEST_DIFF_BASE_SHA" + then + ./ci/run-style-check.sh "$CI_MERGE_REQUEST_DIFF_BASE_SHA" + else + echo "CI_MERGE_REQUEST_DIFF_BASE_SHA should always exist!"; exit 1 + fi + 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..76dd37d22b --- /dev/null +++ b/ci/run-style-check.sh @@ -0,0 +1,8 @@ +#!/bin/sh +# +# Perform style check +# + +baseCommit=$1 + +git clang-format --style file --diff --extensions c,h "$baseCommit" From patchwork Sat Jul 13 13:45:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: karthik nayak X-Patchwork-Id: 13732419 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 AA81613A411 for ; Sat, 13 Jul 2024 13:45:30 +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=1720878332; cv=none; b=tpMwApAsb//W7FCq9GS/MlJrqSf4YukY8qxTAgQ+uiab1SYUAlj09GaMOC/eiVR8wCX2Tc07a06kwFx1lUm2fbGWX7yOy+L69g9q9JaUVWXNPKlGCV+lUj+TfyFEleP5Yhapf43NKRG3NdfqWawsd5jW3rc4sk3zRP5jVLSEHdU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720878332; c=relaxed/simple; bh=krxAM8P0Xd8jzQgWMTv4y8IruzbtSA7t9AhLurZyFk4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rCS5qwDqy58Dg+mHF0CPGb3mTlc9R6+Zx20KTcM2B77LF3tnN3qUCH/93pCUNUtNr+IbJ/sxLHznQWhcHzlfQYFhbz6H3HAEm5rHa92XjUkOqzeoMGDdE1x+kiEh5tYQ8JcDSHFswxsFdkztuxs/twSD1m77J1b9MtMJbzm3oQ4= 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=YiUG0uY6; 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="YiUG0uY6" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-426526d30aaso19816885e9.0 for ; Sat, 13 Jul 2024 06:45:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720878329; x=1721483129; 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=gZJir4sNNdcJ/TphbPyVDtPS9PromycX/J6csVA69UE=; b=YiUG0uY6iYJ+umtqrGlr6vRWS4TEvwNxRf2MGfJoncBOE0eNAClSjymwSGX9ldpiXt gjOopxAGYzxJBVVou0ulxxhvXKUVbMvDgq3hn2x841mwlx6n5Cwf3MVj7hgKLTOwwxD/ VpEqDBE65klBR64/CZ0259Ba/nwjQllJ/fRHnfFdJzd4CKcDkq6SE7elxDtJhK41v1L3 nkeEz9+3x717KtN+Qp7lJ7FqPIdMnhbqZmOpX+ixzeVazflDchadM7VLIou6IwO9EbWP SuS1EkImW697o+29zJ04VKMlro+xcThpGklCrtF9KnTlxxPNCIyhLhytDGip038snJOt zEDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720878329; x=1721483129; 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=gZJir4sNNdcJ/TphbPyVDtPS9PromycX/J6csVA69UE=; b=N+RTuG8dss7OREIzKceoT+Fr6JNPu567EiuUfeZEwIhkM8+oYNyJniFh0LWQ0UusEF B0iNZcmkBRsmF3IJ2i7CE5WuM5KoPwnjABy/IjT/iPPX0fF8g0KPRVZgl8bdLTzJuATa GCBA3WOgPAOV7qsgd6+gEHw5i4QMjWacxFNmEqOVJmD1qKM3QR8AvYN+RbUtZFhZd1MV ZiEustSHA8S0elfOFv2ImsuDRS2l/cgdsl4f4XI3ZlJEf69iPZgUyYshFK848yVX6RJP DI5q3sb3kGtgZjDG04xi5ceSbzpY13LQS9m8PipynRWwyuoS+6KBXp6S5vGBIhG24kJm HuNA== X-Forwarded-Encrypted: i=1; AJvYcCVuJv99gKuchcokr0R/t2GGZa4YDMLOqPWGJIpF1hZrpjD+uCdKpGtPvxIZeyY85luPz21bxBOQaKyho3DgNbYx4IcI X-Gm-Message-State: AOJu0YzmDbS0Yl2GgbazOQCT8BpP9smUfJFt1RT7n11PBB9RxTtXrioR 3l+Xojw5OvIY07pzfl9YZsDCLBMhRg0LmHKkIxMfbhI5drICWhdb X-Google-Smtp-Source: AGHT+IFlQlX4+n4Y7qvsZExBR3dyALzUmgtGzw117KXh1UaLa5G0l/NOuJCHBfpggZSMwvhy+Q62wA== X-Received: by 2002:adf:ae59:0:b0:366:f994:33c with SMTP id ffacd0b85a97d-367ceacb515mr10678497f8f.56.1720878328919; Sat, 13 Jul 2024 06:45:28 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:cb20:918b:a998:e5da]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680dab3bd8sm1440325f8f.13.2024.07.13.06.45.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Jul 2024 06:45:28 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: chriscool@tuxfamily.org, git@vger.kernel.org, jltobler@gmail.com, phillip.wood123@gmail.com Subject: [PATCH v3 7/8] check-whitespace: detect if no base_commit is provided Date: Sat, 13 Jul 2024 15:45:17 +0200 Message-ID: <20240713134518.773053-8-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240713134518.773053-1-karthik.188@gmail.com> References: <20240711083043.1732288-1-karthik.188@gmail.com> <20240713134518.773053-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 exits 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 fallback to 'CI_MERGE_REQUEST_DIFF_BASE_SHA' if "CI_MERGE_REQUEST_TARGET_BRANCH_SHA" isn't available in GitLab CI, similar to the previous commit. 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 | 14 +++++++++++++- ci/check-whitespace.sh | 10 ++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 14f9d3dc8e..0596a01b68 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -118,8 +118,20 @@ check-whitespace: image: ubuntu:latest before_script: - ./ci/install-dependencies.sh + # Since $CI_MERGE_REQUEST_TARGET_BRANCH_SHA is only defined for merged + # pipelines, we fallback to $CI_MERGE_REQUEST_DIFF_BASE_SHA, which should + # be defined in all pipelines. script: - - ./ci/check-whitespace.sh "$CI_MERGE_REQUEST_TARGET_BRANCH_SHA" + - | + if test -n "$CI_MERGE_REQUEST_TARGET_BRANCH_SHA" + then + ./ci/check-whitespace.sh "$CI_MERGE_REQUEST_TARGET_BRANCH_SHA" + elif test -n "$CI_MERGE_REQUEST_DIFF_BASE_SHA" + then + ./ci/check-whitespace.sh "$CI_MERGE_REQUEST_DIFF_BASE_SHA" + else + echo "CI_MERGE_REQUEST_DIFF_BASE_SHA should always exist!"; exit 1 + fi rules: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' diff --git a/ci/check-whitespace.sh b/ci/check-whitespace.sh index db399097a5..c40804394c 100755 --- a/ci/check-whitespace.sh +++ b/ci/check-whitespace.sh @@ -9,7 +9,7 @@ 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 @@ -21,6 +21,12 @@ commitText= commitTextmd= goodParent= +if ! git rev-parse --quiet --verify "${baseCommit}" +then + echo "Invalid '${baseCommit}'" + exit 1 +fi + while read dash sha etc do case "${dash}" in @@ -67,7 +73,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 or more of the commits." echo "Run the following command to resolve whitespace issues:" echo "git rebase --whitespace=fix ${goodParent}" From patchwork Sat Jul 13 13:45:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: karthik nayak X-Patchwork-Id: 13732420 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.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 A125813B580 for ; Sat, 13 Jul 2024 13:45:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720878333; cv=none; b=P/ilPsImsPCVUdGv4gbPpRVOenz0TVc96sI1XVg3FXPgbMS2r7v8+M7x5iz4a+eIpiAIut64nsfNQH6FKX4z07cG4gt5iEgF2VZicjectbmW+xc95o4jbA91UxY3oQAaYpqN4rN5XjznVClUQ+Iyy2raO6ZtZzVN2/PdmmDtDK4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720878333; c=relaxed/simple; bh=fQaACFgFIxG/vOBFIv1xPM7jvvVSGUqWNMyg4xBUvBY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=R0BRfPpYcOFROlAVAJVL/pmsMUPyCQCiahssIHPZIUdm1r2kfBuockN/qKpfMCHmEATID2Hg5vSjIlFg0KiwhSMDqb72X5JgMMXQVnyZru8gmyKYR4ksoVsreDhyZrIqr8vVWthJ7cPUArKe30257iKeEPORxULINDTVqivI0zE= 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=NnjpkZv6; arc=none smtp.client-ip=209.85.221.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="NnjpkZv6" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-367e50f71bbso1934572f8f.2 for ; Sat, 13 Jul 2024 06:45:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720878330; x=1721483130; 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=V1ObvvIMf0jTtjQcMpTJUCl7VMwv/7rhGqluTGyL/Sk=; b=NnjpkZv67ICdYkcdLdJBrJFgidKK0nPMoN8ceEyjOgPo8tOqBovezhhX2zmODs4o0w dRByJfXT5msBp/1txNY6no2cwOWE8XkDs/I6FwMO7P4VWXs1nCkhcxFyVLJ25kh/bOhq hV3Icw3LBVUCaoPj6L/1YbvB69bKGGZIi0WTSBdyhRhd15autZuDg92JZZLkFLPMIZuu a9EfKcX8eK/CSjzebM+/ztN7Pcwy/wml3ykEPsjUxjkYjfSu7bYjQYZKZuSQF9E+J4B8 sj0iuV3OH1ufgmuHDhpa1K8kIrXppMcJzT/Lub83fjm9BIdFa3BKfyBdSxhFRZSPDDeK SJmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720878330; x=1721483130; 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=V1ObvvIMf0jTtjQcMpTJUCl7VMwv/7rhGqluTGyL/Sk=; b=gntxZtsQ4/lpEevybqxHwzLiBvgh0ZE6gWfAv0qTn8dz2LwiEVXiVmFY6/ZNtJvsmb YfB5VxAJpZua812urdeh/GQZ6b1ZOeJWNUuD7jNep6iZcXvFmYAUENT86py3mJ+B0oS6 zewjqHG4yyypEuGWoCxr+yx0eoncu+jCS7gm6qLwtqDob9KX3k70aGxtwuTK/hzURzx0 6Y1MRbczfema7IkTi5xdpe6pu+wdJcNwWKlCKMYCgHxZwiLuipVUkG6FR/EQ2N07YI43 S6U6Utl3zw1f8DTzM9RWxWOA1nbPFc9sfoIz4XiBtnsPlG2Kqo+pRZQdX6aLPxRxXQ4i g6Bg== X-Forwarded-Encrypted: i=1; AJvYcCWe7bF72egV9OOpUYVHrodU12lVswuBzfVd+EeSbdIABCFkrLn1vrRDE/kz4eqJOq8q5VC7u/DcyvDsEHV/1vyHaOps X-Gm-Message-State: AOJu0YyqAdPTgwTMd8Aelbts6V1b+g1Th2uWpxh8xzri5EIpye51uWgE 2nXhru66vH8V0MeLux4rxlxcSs81HUdviN0LDfvokokIqR3F/NWo X-Google-Smtp-Source: AGHT+IEUV0tLC4q+48FPmYdEkWTbkMNYPvbw/4Pk52VCp9oY5ghaMEf/xhPQBf1ZnsOL3qziUEp2/g== X-Received: by 2002:a5d:480c:0:b0:364:6c08:b9b2 with SMTP id ffacd0b85a97d-367cead1d1amr8320462f8f.45.1720878329839; Sat, 13 Jul 2024 06:45:29 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:cb20:918b:a998:e5da]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680dab3bd8sm1440325f8f.13.2024.07.13.06.45.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Jul 2024 06:45:29 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: chriscool@tuxfamily.org, git@vger.kernel.org, jltobler@gmail.com, phillip.wood123@gmail.com Subject: [PATCH v3 8/8] ci/style-check: add `RemoveBracesLLVM` to '.clang-format' Date: Sat, 13 Jul 2024 15:45:18 +0200 Message-ID: <20240713134518.773053-9-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240713134518.773053-1-karthik.188@gmail.com> References: <20240711083043.1732288-1-karthik.188@gmail.com> <20240713134518.773053-1-karthik.188@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 For 'clang-format' setting 'RemoveBracesLLVM' to 'true', adds a check to ensure we avoid curly braces for single-statement bodies in conditional blocks. However, the option does come with two warnings [1]: This option will be renamed and expanded to support other styles. and Setting this option to true could lead to incorrect code formatting due to clang-format’s lack of complete semantic information. As such, extra care should be taken to review code changes made by this option. The latter seems to be of concern. While we want to experiment with the rule, adding it to the in-tree '.clang-format' could affect end-users. Let's only add it to the CI jobs for now. With time, we can evaluate its efficacy and decide if we want to add it to '.clang-format' or retract it entirely. [1]: https://clang.llvm.org/docs/ClangFormatStyleOptions.html#removebracesllvm Signed-off-by: Karthik Nayak --- ci/run-style-check.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ci/run-style-check.sh b/ci/run-style-check.sh index 76dd37d22b..1dce50a0ac 100755 --- a/ci/run-style-check.sh +++ b/ci/run-style-check.sh @@ -5,4 +5,17 @@ baseCommit=$1 +# 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 but keeps braces if one side of +# if/else if/.../else cascade has multi-statement body. +# +# As this rule comes with a warning [1], we want to experiment with it +# before adding it in-tree. since the CI job for the style check is allowed +# to fail, appending the rule here allows us to validate its efficacy. +# While also ensuring that end-users are not affected directly. +# +# [1]: https://clang.llvm.org/docs/ClangFormatStyleOptions.html#removebracesllvm +echo "RemoveBracesLLVM: true" >> .clang-format + git clang-format --style file --diff --extensions c,h "$baseCommit"