]> git.ipfire.org Git - thirdparty/util-linux.git/commit
Drop pointless bitfields
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 20 Nov 2024 13:14:52 +0000 (14:14 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 20 Nov 2024 13:14:52 +0000 (14:14 +0100)
commit63d7937180fcce4ea7fc1d2855872e464f06e779
treec61aab38a0be2378d1541265697533fc709484fe
parenta5dd2fc5ff339079d60b72abb04f329a1e63dbda
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.)
48 files changed:
disk-utils/cfdisk.c
disk-utils/fsck.c
disk-utils/mkfs.minix.c
disk-utils/mkswap.c
include/loopdev.h
include/pty-session.h
lib/pager.c
libfdisk/src/fdiskP.h
libmount/src/lock.c
libsmartcols/src/filter-param.c
libsmartcols/src/smartcolsP.h
login-utils/chfn.c
login-utils/last.c
login-utils/login.c
login-utils/su-common.c
lsfd-cmd/lsfd.h
misc-utils/blkid.c
misc-utils/cal.c
misc-utils/getopt.c
misc-utils/hardlink.c
misc-utils/kill.c
misc-utils/lsblk.h
misc-utils/lslocks.c
misc-utils/mcookie.c
misc-utils/uuidd.c
misc-utils/uuidparse.c
schedutils/taskset.c
schedutils/uclampset.c
sys-utils/dmesg.c
sys-utils/eject.c
sys-utils/hwclock.h
sys-utils/irq-common.h
sys-utils/irqtop.c
sys-utils/lscpu.c
sys-utils/lscpu.h
sys-utils/lsmem.c
sys-utils/mountpoint.c
sys-utils/rfkill.c
sys-utils/rtcwake.c
sys-utils/setpriv.c
sys-utils/swapon.c
term-utils/script.c
term-utils/setterm.c
text-utils/col.c
text-utils/colcrt.c
text-utils/column.c
text-utils/more.c
text-utils/ul.c