diff options
| author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2024-11-20 14:14:52 +0100 |
|---|---|---|
| committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2024-11-20 14:14:52 +0100 |
| commit | 63d7937180fcce4ea7fc1d2855872e464f06e779 (patch) | |
| tree | c61aab38a0be2378d1541265697533fc709484fe /misc-utils/kill.c | |
| parent | a5dd2fc5ff339079d60b72abb04f329a1e63dbda (diff) | |
| download | util-linux-63d7937180fcce4ea7fc1d2855872e464f06e779.tar.gz | |
Drop pointless bitfields
Bitfields have their uses, but the uses here didn't make any sense.
Code generated to read or write bitfields is more complicated (and
slower) because, well, the bits need to be manipulated with special
instructions. So bitfields should be used when we have a structure
that is repeated hundreds or thousands of times in memory and those
saving are higher than the cost of having more complicated code. This
can happen for example in the kernel code. But the code here has
structures that are instantiated once or or at most few times.
In addition, a bitfield often does not save any memory because of
alignment requirements. In the majority of cases modified here, the
bitfield was the last field in a structure, so no memory savings were
made.
$ size build*/{mkswap,more,ul,col,rtcwake,lsmem,lscpu,eject,dmesg,uuidd,taskset,login}
text data bss dec hex filename
132014 1988 88 134090 20bca build/mkswap
129342 1852 88 131282 200d2 build2/mkswap
55161 1480 128 56769 ddc1 build/more
54265 1480 128 55873 da41 build2/more
14364 868 112 15344 3bf0 build/ul
14316 868 112 15296 3bc0 build2/ul
28547 1000 112 29659 73db build/col
28435 1000 112 29547 736b build2/col
46914 1960 112 48986 bf5a build/rtcwake
46834 1960 112 48906 bf0a build2/rtcwake
63419 1744 176 65339 ff3b build/lsmem
63403 1744 176 65323 ff2b build2/lsmem
159885 2864 464 163213 27d8d build/lscpu
159757 2864 464 163085 27d0d build2/lscpu
90041 1704 88 91833 166b9 build/eject
89737 1704 88 91529 16589 build2/eject
82150 5152 1032 88334 1590e build/dmesg
81846 5152 1032 88030 157de build2/dmesg
37601 1368 80 39049 9889 build/uuidd
37585 1368 80 39033 9879 build2/uuidd
58906 1336 56 60298 eb8a build/taskset
58890 1336 56 60282 eb7a build2/taskset
84761 2128 152 87041 15401 build/login
84672 2128 152 86952 153a8 build2/login
(To be clear: those small savings are not particularly important. The
motivation for this patch is to eradicate the antipattern of making
things more complicated without any benefit.)
Diffstat (limited to 'misc-utils/kill.c')
| -rw-r--r-- | misc-utils/kill.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/misc-utils/kill.c b/misc-utils/kill.c index a5f78d2af6..a911df6b72 100644 --- a/misc-utils/kill.c +++ b/misc-utils/kill.c @@ -92,16 +92,15 @@ struct kill_control { #ifdef UL_HAVE_PIDFD struct list_head follow_ups; #endif - unsigned int - check_all:1, - do_kill:1, - do_pid:1, - require_handler:1, - use_sigval:1, + bool check_all, + do_kill, + do_pid, + require_handler, + use_sigval, #ifdef UL_HAVE_PIDFD - timeout:1, + timeout, #endif - verbose:1; + verbose; }; static void print_signal_name(int signum, bool newline) |
