[PATCH v2 1/8] CodingGuidelines: instruct to name arrays in singular
- From
Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
- Date
- Feb 25, 2026, 16:32 UTC
- Message-ID
- <20260225183559.79303-2-lucasseikioshiro@gmail.com>
- In-Reply-To
- <20260225183559.79303-1-lucasseikioshiro@gmail.com>
Arrays should be named in the singular form, ensuring that when accessing an element within an array (e.g. dog[0]) it's clear that we're referring to an element instead of a collection.
Add a new rule to CodingGuidelines asking for arrays to be named in singular instead of plural.
Helped-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> --- Documentation/CodingGuidelines | 13 +++++++++++++ 1 file changed, 13 insertions(+)
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines index 51cb70b515..6c595696a5 100644 --- a/Documentation/CodingGuidelines +++ b/Documentation/CodingGuidelines @@ -658,6 +658,19 @@ For C programs: unsigned other_field:1; unsigned field_with_longer_name:1; + - Array names should be named in the singular form if the individual items are + subject of use. E.g.: + + char *dog[] = ...; + walk_dog(dog[0]); + walk_dog(dog[1]); + + Cases where the array is employed as a whole rather than as its unit parts, + the plural forms is preferable. E.g: + + char *dogs[] = ...; + walk_all_dogs(dogs); + For Perl programs: - Most of the C guidelines above apply.
-- 2.50.1 (Apple Git-155)