]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sysusers: drop counterproductive bitfield annotations
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 31 Jan 2023 12:47:17 +0000 (13:47 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 31 Jan 2023 12:47:17 +0000 (13:47 +0100)
The usual story:
$ diff -u <(pahole build/systemd-sysusers.0) <(pahole build/systemd-sysusers)
  /* size: 80, cachelines: 2, members: 15 */
- /* sum members: 68, holes: 1, sum holes: 4 */
- /* sum bitfield members: 5 bits (0 bytes) */
- /* padding: 7 */
- /* bit_padding: 3 bits */
+ /* sum members: 73, holes: 1, sum holes: 4 */
+ /* padding: 3 */
  /* last cacheline: 16 bytes */

Effectively, because of padding, we were not saving anything. We're not putting
struct Item in arrays, but when allocating on the heap, we're going to round up to
normal alignment too.

The code becomes shorter (and quicker):
$ size build/systemd-sysusers{,.0}
   text    data     bss     dec     hex filename
  79967    2040     264   82271   1415f build/systemd-sysusers.0
  79726    2040     264   82030   1406e build/systemd-sysusers

(In case you're wondering, I wrote this long commit message for a very simple
change on purpose: I want to deflate the bitfield cargo cult a bit.)

src/sysusers/sysusers.c

index 6e197b964dbbf9fb3327032360e3aafb503c6aee..4a695fcfabd328fa76a8247aa35ecc50d08bd2d3 100644 (file)
@@ -76,17 +76,17 @@ typedef struct Item {
         gid_t gid;
         uid_t uid;
 
-        bool gid_set:1;
+        bool gid_set;
 
         /* When set the group with the specified GID must exist
          * and the check if a UID clashes with the GID is skipped.
          */
-        bool id_set_strict:1;
+        bool id_set_strict;
 
-        bool uid_set:1;
+        bool uid_set;
 
-        bool todo_user:1;
-        bool todo_group:1;
+        bool todo_user;
+        bool todo_group;
 } Item;
 
 static char *arg_root = NULL;