1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-03-08 20:58:20 +03:00

sysusers: drop counterproductive bitfield annotations

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.)
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2023-01-31 13:47:17 +01:00
parent 907046282c
commit 616c53544f

View 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;