git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/6] CodingGuidelines: document our style for flags

From
Patrick Steinhardt <ps@pks.im>
Date
Mar 31, 2026, 23:57 UTC
Message-ID
<20260401-pks-odb-cleanups-v1-1-89adba9ada68@pks.im>
In-Reply-To
<20260401-pks-odb-cleanups-v1-0-89adba9ada68@pks.im>
We have recently iterated a bit on our style for flags. Document this.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 Documentation/CodingGuidelines | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index b8670751f5..4992e52093 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -668,6 +668,18 @@ For C programs:
    unsigned other_field:1;
    unsigned field_with_longer_name:1;
 
+ - When a function `F` accepts flags, those flags should be defined as `enum
+   F_flags`. Individual flag definitions should start with `F` and be in
+   all-uppercase letters. Flag values should be represented via bit shifts.
+   E.g.
+
+        enum frobnicate_flags {
+                FROBNICATE_FOO = (1 << 0),
+                FROBNICATE_BAR = (1 << 1),
+        };
+
+        int frobnicate(enum frobnicate_flags flags);
+
  - Array names should be named in the singular form if the individual items are
    subject of use. E.g.:
 
-- 
2.53.0.1185.g05d4b7b318.dirty
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 2 of 7 in “odb: small set of cleanups”
  1. 0/6 odb: small set of cleanupsPatrick Steinhardt, Mar 31, 2026
  2. 1/6 CodingGuidelines: document our style for flagsPatrick Steinhardt, Mar 31, 2026
  3. 2/6 treewide: use enum for `odb_for_each_object()` flagsPatrick Steinhardt, Mar 31, 2026
  4. 3/6 odb: rename `odb_write_object()` flagsPatrick Steinhardt, Mar 31, 2026
  5. 4/6 odb: use enum for `odb_write_object` flagsPatrick Steinhardt, Mar 31, 2026
  6. 5/6 odb: rename `odb_has_object()` flagsPatrick Steinhardt, Mar 31, 2026
  7. 6/6 odb: drop unneeded headers and forward declsPatrick Steinhardt, Mar 31, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.