]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
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)
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

index 948957c5e2c3f87a85324c27502b0b24ce5852c6..4018f4d3d3f1346921400b7ade315b7fe158c823 100644 (file)
@@ -247,10 +247,10 @@ struct cfdisk {
        struct libmnt_table *fstab;
        struct libmnt_cache *mntcache;
 #endif
-       unsigned int    wrong_order :1,         /* PT not in right order */
-                       zero_start :1,          /* ignore existing partition table */
-                       device_is_used : 1,     /* don't use re-read ioctl */
-                       show_extra :1;          /* show extra partinfo */
+       bool    wrong_order,    /* PT not in right order */
+               zero_start,     /* ignore existing partition table */
+               device_is_used, /* don't use re-read ioctl */
+               show_extra;     /* show extra partinfo */
 };
 
 
index 5c09058721c9a6dbb27a81a9edf1f126974125db..beccb17508f3eb3e3fe3c0c71b7a8dd88b7aa436 100644 (file)
@@ -99,9 +99,9 @@ struct fsck_fs_data
 {
        const char      *device;
        dev_t           disk;
-       unsigned int    stacked:1,
-                       done:1,
-                       eval_device:1;
+       bool            stacked,
+                       done,
+                       eval_device;
 };
 
 /*
index f6f2f489611fefb84efe6d84d69771045eea80d8..328dc8887d165397d9e6a571b66e3d2e03b9d960 100644 (file)
@@ -58,6 +58,7 @@
  *
  */
 
+#include <stdbool.h>
 #include <stdio.h>
 #include <time.h>
 #include <unistd.h>
@@ -117,8 +118,7 @@ struct fs_control {
        size_t fs_dirsize;              /* maximum size of directory */
        unsigned long fs_inodes;        /* number of inodes */
        int fs_magic;                   /* file system magic number */
-       unsigned int
-        check_blocks:1;                /* check for bad blocks */
+       bool check_blocks;              /* check for bad blocks */
 };
 
 static char root_block[MINIX_BLOCK_SIZE];
index ca1f07b86d54f0f42b60073794c6407fdf638d08..b1f3a328569d119f25b7bf137190120785a93830 100644 (file)
@@ -15,6 +15,7 @@
  * Copyright (C) 2007-2014 Karel Zak <kzak@redhat.com>
  */
 
+#include <stdbool.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <string.h>
@@ -94,11 +95,11 @@ struct mkswap_control {
 
        enum ENDIANNESS         endianness;
 
-       unsigned int            check:1,        /* --check */
-                               verbose:1,      /* --verbose */
-                               quiet:1,        /* --quiet */
-                               force:1,        /* --force */
-                               file:1;         /* --file */
+       bool                    check,          /* --check */
+                               verbose,        /* --verbose */
+                               quiet,          /* --quiet */
+                               force,          /* --force */
+                               file;           /* --file */
 };
 
 static uint32_t cpu32_to_endianness(uint32_t v, enum ENDIANNESS e)
index d10bf7f376505eb96088ccb4ca75726fd9c28147..e5ec1c98a467a63c3a869b0c02f7618dc6433a68 100644 (file)
@@ -5,6 +5,7 @@
 #ifndef UTIL_LINUX_LOOPDEV_H
 #define UTIL_LINUX_LOOPDEV_H
 
+#include <stdbool.h>
 #include "sysfs.h"
 
 /*
@@ -95,8 +96,8 @@ struct loopdev_iter {
        int             ct_perm;        /* count permission problems */
        int             ct_succ;        /* count number of detected devices */
 
-       unsigned int    done:1;         /* scanning done */
-       unsigned int    default_check:1;/* check first LOOPDEV_NLOOPS */
+       bool            done;           /* scanning done */
+       bool            default_check;  /* check first LOOPDEV_NLOOPS */
        int             flags;          /* LOOPITER_FL_* flags */
 };
 
@@ -117,11 +118,11 @@ struct loopdev_cxt {
        uint64_t        blocksize;      /* used by loopcxt_setup_device() */
 
        int             flags;          /* LOOPDEV_FL_* flags */
-       unsigned int    has_info:1;     /* .info contains data */
-       unsigned int    extra_check:1;  /* unusual stuff for iterator */
-       unsigned int    info_failed:1;  /* LOOP_GET_STATUS ioctl failed */
-       unsigned int    control_ok:1;   /* /dev/loop-control success */
-       unsigned int    is_lost:1;      /* device in /sys, but missing in /dev */
+       bool            has_info;       /* .info contains data */
+       bool            extra_check;    /* unusual stuff for iterator */
+       bool            info_failed;    /* LOOP_GET_STATUS ioctl failed */
+       bool            control_ok;     /* /dev/loop-control success */
+       bool            is_lost;        /* device in /sys, but missing in /dev */
 
        struct path_cxt         *sysfs; /* pointer to /sys/dev/block/<maj:min>/ */
        struct loop_config      config; /* for GET/SET ioctl */
index 734a7f6893a144efab4c0be7a9d4c1a422b30912..af54197b329bf39e89d383eb4299ea749a614719 100644 (file)
@@ -10,6 +10,7 @@
 #include <pty.h>
 #include <termios.h>
 #include <signal.h>
+#include <stdbool.h>
 #include <sys/time.h>
 #include <sys/stat.h>
 
@@ -86,11 +87,11 @@ struct ul_pty {
                struct ul_pty_child_buffer *next;
                char buf[BUFSIZ];
                size_t size, cursor;
-               unsigned int final_input:1;     /* drain child before writing */
+               bool final_input;       /* drain child before writing */
        } *child_buffer_head, *child_buffer_tail, *free_buffers;
 
-       unsigned int isterm:1,          /* is stdin terminal? */
-                    slave_echo:1;      /* keep ECHO on pty slave */
+       bool isterm,            /* is stdin terminal? */
+               slave_echo;     /* keep ECHO on pty slave */
 };
 
 void ul_pty_init_debug(int mask);
index 15a5e2736f20bcf62f862f7c4732313ec7fd2ba2..20002acda074d01cb8d963ed514d2359f16d6ebf 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <unistd.h>
+#include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
 #include <err.h>
@@ -44,7 +45,7 @@ struct child_process {
        struct sigaction orig_sigquit;
        struct sigaction orig_sigpipe;
 
-       unsigned no_stdin:1;
+       bool no_stdin;
        void (*preexec_cb)(void);
 };
 static struct child_process pager_process;
index c972726563db9e223e5baa6c38589fae93eccffa..1f44996afa8fbba65e8ff12729c1f20e4681f1d6 100644 (file)
@@ -11,6 +11,7 @@
 #define _LIBFDISK_PRIVATE_H
 
 #include <errno.h>
+#include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/stat.h>
@@ -300,8 +301,8 @@ struct fdisk_label {
        struct fdisk_geometry   geom_min;       /* minimal geometry */
        struct fdisk_geometry   geom_max;       /* maximal geometry */
 
-       unsigned int            changed:1,      /* label has been modified */
-                               disabled:1;     /* this driver is disabled at all */
+       bool                    changed,        /* label has been modified */
+                               disabled;       /* this driver is disabled at all */
 
        const struct fdisk_field *fields;       /* all possible fields */
        size_t                  nfields;
@@ -351,9 +352,9 @@ struct fdisk_ask {
                        uint64_t        base;           /* for relative results */
                        uint64_t        unit;           /* unit for offsets */
                        const char      *range;         /* by library generated list */
-                       unsigned int    relative :1,
-                                       inchars  :1,
-                                       wrap_negative   :1;
+                       bool            relative,
+                                       inchars,
+                                       wrap_negative;
                } num;
                /* FDISK_ASKTYPE_{WARN,WARNX,..} */
                struct ask_print {
index b336a3b5da37d6ec80643e186ac0b71e3d3d98ec..28ff8b788b6c3b2417da1e07dcafae2a00f8b206 100644 (file)
@@ -40,8 +40,8 @@ struct libmnt_lock {
        char    *lockfile;      /* path to lock file (e.g. /etc/mtab~) */
        int     lockfile_fd;    /* lock file descriptor */
 
-       unsigned int    locked :1,      /* do we own the lock? */
-                       sigblock :1;    /* block signals when locked */
+       bool    locked,         /* do we own the lock? */
+               sigblock;       /* block signals when locked */
 
        sigset_t oldsigmask;
 };
index 636d4e5ee90ca21b7466f48e5348665c53b3b46e..4a67cbfaff0fce08be10b9d3c9fb55e662f8d735 100644 (file)
@@ -24,8 +24,8 @@ struct filter_param {
        char *holder_name;
        regex_t *re;
 
-       unsigned int fetched :1,        /* holder requested */
-                    empty : 1;
+       bool fetched,   /* holder requested */
+            empty;
 };
 
 static int cast_param(int type, struct filter_param *n);
index 23fc824c2ab66bdbb53ca6d9984d29034e85f01f..444661ee6a113873a972ce4062c8ed3f69208b5a 100644 (file)
@@ -265,22 +265,22 @@ struct libscols_table {
        struct libscols_column *cur_column;     /* currently used column */
 
        /* flags */
-       unsigned int    ascii           :1,     /* don't use unicode */
-                       colors_wanted   :1,     /* enable colors */
-                       is_term         :1,     /* isatty() */
-                       padding_debug   :1,     /* output visible padding chars */
-                       is_dummy_print  :1,     /* printing used for width calculation only */
-                       is_shellvar     :1,     /* shell compatible column names */
-                       maxout          :1,     /* maximize output */
-                       minout          :1,     /* minimize output (mutually exclusive to maxout) */
-                       header_repeat   :1,     /* print header after libscols_table->termheight */
-                       header_printed  :1,     /* header already printed */
-                       priv_symbols    :1,     /* default private symbols */
-                       walk_last_done  :1,     /* last tree root walked */
-                       no_headings     :1,     /* don't print header */
-                       no_encode       :1,     /* don't care about control and non-printable chars */
-                       no_linesep      :1,     /* don't print line separator */
-                       no_wrap         :1;     /* never wrap lines */
+       bool            ascii         , /* don't use unicode */
+                       colors_wanted , /* enable colors */
+                       is_term       , /* isatty() */
+                       padding_debug , /* output visible padding chars */
+                       is_dummy_print, /* printing used for width calculation only */
+                       is_shellvar   , /* shell compatible column names */
+                       maxout        , /* maximize output */
+                       minout        , /* minimize output (mutually exclusive to maxout) */
+                       header_repeat , /* print header after libscols_table->termheight */
+                       header_printed, /* header already printed */
+                       priv_symbols  , /* default private symbols */
+                       walk_last_done, /* last tree root walked */
+                       no_headings   , /* don't print header */
+                       no_encode     , /* don't care about control and non-printable chars */
+                       no_linesep    , /* don't print line separator */
+                       no_wrap       ; /* never wrap lines */
 };
 
 #define IS_ITER_FORWARD(_i)    ((_i)->direction == SCOLS_ITER_FORWARD)
index 752d59821f2a577c855f86b00cea64fcf6d6d108..b82492e9b7e5790abd7d32dd70b04e87d6002b62 100644 (file)
@@ -72,13 +72,12 @@ struct chfn_control {
         *          NULL in fields that haven't been changed.
         *  In the end, "newf" is folded into "oldf".  */
        struct finfo oldf, newf;
-       unsigned int
-               allow_fullname:1,       /* The login.defs restriction */
-               allow_room:1,              /* see: man login.defs(5) */
-               allow_work:1,              /* and look for CHFN_RESTRICT */
-               allow_home:1,              /* keyword for these four. */
-               changed:1,              /* is change requested */
-               interactive:1;          /* whether to prompt for fields or not */
+       bool    allow_fullname, /* The login.defs restriction */
+               allow_room,     /* see: man login.defs(5) */
+               allow_work,     /* and look for CHFN_RESTRICT */
+               allow_home,     /* keyword for these four. */
+               changed,        /* is change requested */
+               interactive;    /* whether to prompt for fields or not */
 };
 
 /* we do not accept gecos field sizes longer than MAX_FIELD_SIZE */
index 0f92fef353ec58bde1536516ae9220641be6030f..bdd3750631863f6b9ff489bc9840603cd701e622 100644 (file)
 #define UCHUNKSIZE     16384   /* How much we read at once. */
 
 struct last_control {
-       unsigned int lastb :1,    /* Is this command 'lastb' */
-                    extended :1, /* Lots of info */
-                    showhost :1, /* Show hostname */
-                    altlist :1,  /* Hostname at the end */
-                    usedns :1,   /* Use DNS to lookup the hostname */
-                    useip :1;    /* Print IP address in number format */
+       bool lastb,     /* Is this command 'lastb' */
+            extended,  /* Lots of info */
+            showhost,  /* Show hostname */
+            altlist,   /* Hostname at the end */
+            usedns,    /* Use DNS to lookup the hostname */
+            useip;     /* Print IP address in number format */
 
        unsigned int name_len;  /* Number of login name characters to print */
        unsigned int domain_len; /* Number of domain name characters to print */
index a312927720c104feef402e455ada9cf9758686e9..1d7dd3a679107d3fd8fdddf2af96af170c4da2d7 100644 (file)
@@ -132,11 +132,11 @@ struct login_context {
 
        pid_t           pid;
 
-       unsigned int    quiet:1,        /* hush file exists */
-                       remote:1,       /* login -h */
-                       nohost:1,       /* login -H */
-                       noauth:1,       /* login -f */
-                       keep_env:1;     /* login -p */
+       bool            quiet,          /* hush file exists */
+                       remote,         /* login -h */
+                       nohost,         /* login -H */
+                       noauth,         /* login -f */
+                       keep_env;       /* login -p */
 };
 
 static pid_t child_pid = 0;
index feb4645fa1b6837fd4a3d9561a90d895bb4dd15f..8a77cf2a806158373e875993f1b48073c666e9e7 100644 (file)
@@ -150,18 +150,18 @@ struct su_context {
 #ifdef USE_PTY
        struct ul_pty   *pty;                   /* pseudo terminal handler (for --pty) */
 #endif
-       unsigned int runuser :1,                /* flase=su, true=runuser */
-                    runuser_uopt :1,           /* runuser -u specified */
-                    isterm :1,                 /* is stdin terminal? */
-                    fast_startup :1,           /* pass the `-f' option to the subshell. */
-                    simulate_login :1,         /* simulate a login instead of just starting a shell. */
-                    change_environment :1,     /* change some environment vars to indicate the user su'd to.*/
-                    same_session :1,           /* don't call setsid() with a command. */
-                    suppress_pam_info:1,       /* don't print PAM info messages (Last login, etc.). */
-                    pam_has_session :1,        /* PAM session opened */
-                    pam_has_cred :1,           /* PAM cred established */
-                    force_pty :1,              /* create pseudo-terminal */
-                    restricted :1;             /* false for root user */
+       bool            runuser,                /* flase=su, true=runuser */
+                       runuser_uopt,           /* runuser -u specified */
+                       isterm,                 /* is stdin terminal? */
+                       fast_startup,           /* pass the `-f' option to the subshell. */
+                       simulate_login,         /* simulate a login instead of just starting a shell. */
+                       change_environment,     /* change some environment vars to indicate the user su'd to.*/
+                       same_session,           /* don't call setsid() with a command. */
+                       suppress_pam_info,      /* don't print PAM info messages (Last login, etc.). */
+                       pam_has_session,        /* PAM session opened */
+                       pam_has_cred,           /* PAM cred established */
+                       force_pty,              /* create pseudo-terminal */
+                       restricted;             /* false for root user */
 };
 
 
index a34a756c7225d8bd6e9b5aac53ecdb6f7ace8634..e25aec4d6cb2607bf90492ac779b74f876e16b4c 100644 (file)
@@ -207,10 +207,10 @@ struct file {
        unsigned int sys_flags;
        unsigned int mnt_id;
 
-       uint8_t locked_read:1,
-               locked_write:1,
-               multiplexed:1,
-               is_error:1;
+       bool    locked_read,
+               locked_write,
+               multiplexed,
+               is_error;
 };
 
 #define is_opened_file(_f) ((_f)->association >= 0)
index aaffe19168edcafe7cf0f061611171983b8e93ba..d5fe4f1fa0002a49232199b1cf5e7bcdb1b95a81 100644 (file)
@@ -9,6 +9,7 @@
  * %End-Header%
  */
 
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -56,15 +57,14 @@ struct blkid_control {
        uintmax_t size;
        char *show[128];
        struct ul_jsonwrt *json_fmt;
-       unsigned int
-               eval:1,
-               gc:1,
-               lookup:1,
-               lowprobe:1,
-               lowprobe_superblocks:1,
-               lowprobe_topology:1,
-               no_part_details:1,
-               raw_chars:1;
+       bool    eval,
+               gc,
+               lookup,
+               lowprobe,
+               lowprobe_superblocks,
+               lowprobe_topology,
+               no_part_details,
+               raw_chars;
 };
 
 static void __attribute__((__noreturn__)) usage(void)
index 1af95124c49af62231415aed06653c00f599a7b2..0acf042ff63ab68a9dd9257dd60bb587576fa281 100644 (file)
@@ -214,22 +214,22 @@ struct cal_control {
        const char *abbr_month[MONTHS_IN_YEAR]; /* abbreviated month names */
        const char *weekdays[DAYS_IN_WEEK];     /* day names */
 
-       int reform_year;                /* Gregorian reform year */
-       int colormode;                  /* day and week number highlight */
-       int num_months;                 /* number of requested months */
-       int span_months;                /* span the date */
-       int months_in_row;              /* number of months horizontally in print out */
-       int weekstart;                  /* day the week starts, often Sun or Mon */
-       int weektype;                   /* WEEK_TYPE_{NONE,ISO,US} */
-       size_t day_width;               /* day width in characters in printout */
-       size_t week_width;              /* 7 * day_width + possible week num */
-       size_t month_width;             /* width of a month (vertical mode) */
-       int gutter_width;               /* spaces in between horizontal month outputs */
-       struct cal_request req;         /* the times user is interested */
-       unsigned int    julian:1,       /* julian output */
-                       header_year:1,  /* print year number */
-                       header_hint:1,  /* does month name + year need two lines to fit */
-                       vertical:1;     /* display the output in vertical */
+       int reform_year;        /* Gregorian reform year */
+       int colormode;          /* day and week number highlight */
+       int num_months;         /* number of requested months */
+       int span_months;        /* span the date */
+       int months_in_row;      /* number of months horizontally in print out */
+       int weekstart;          /* day the week starts, often Sun or Mon */
+       int weektype;           /* WEEK_TYPE_{NONE,ISO,US} */
+       size_t day_width;       /* day width in characters in printout */
+       size_t week_width;      /* 7 * day_width + possible week num */
+       size_t month_width;     /* width of a month (vertical mode) */
+       int gutter_width;       /* spaces in between horizontal month outputs */
+       struct cal_request req; /* the times user is interested */
+       bool    julian,         /* julian output */
+               header_year,    /* print year number */
+               header_hint,    /* does month name + year need two lines to fit */
+               vertical;       /* display the output in vertical */
 };
 
 struct cal_month {
index c57dd87377abeafefe24a6f7dc7f906e808cbca1..ae35baaf8d1543d62dc9e193624eb3c958c21723 100644 (file)
@@ -57,6 +57,7 @@
 #define CLOSE_EXIT_CODE                XALLOC_EXIT_CODE
 #define TEST_EXIT_CODE         4
 
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -88,11 +89,10 @@ struct getopt_control {
        struct option *long_options;    /* long options */
        int long_options_length;        /* length of options array */
        int long_options_nr;            /* number of used elements in array */
-       unsigned int
-               compatible:1,           /* compatibility mode for 'difficult' programs */
-               quiet_errors:1,         /* print errors */
-               quiet_output:1,         /* print output */
-               quote:1;                /* quote output */
+       bool    compatible,             /* compatibility mode for 'difficult' programs */
+               quiet_errors,           /* print errors */
+               quiet_output,           /* print output */
+               quote;                  /* quote output */
 };
 
 enum { REALLOC_INCREMENT = 8 };
index d17bcd4f0e79f6abd3047d98299e72ccb52df365..6ac4a3306db63bf69e6c431f2c48af537680481b 100644 (file)
@@ -184,20 +184,20 @@ static struct options {
 
        const char *method;
        signed int verbosity;
-       unsigned int respect_mode:1;
-       unsigned int respect_owner:1;
-       unsigned int respect_name:1;
-       unsigned int respect_dir:1;
-       unsigned int respect_time:1;
-       unsigned int respect_xattrs:1;
-       unsigned int maximise:1;
-       unsigned int minimise:1;
-       unsigned int keep_oldest:1;
-       unsigned int prio_trees:1;
-       unsigned int dry_run:1;
-       unsigned int list_duplicates:1;
+       bool respect_mode;
+       bool respect_owner;
+       bool respect_name;
+       bool respect_dir;
+       bool respect_time;
+       bool respect_xattrs;
+       bool maximise;
+       bool minimise;
+       bool keep_oldest;
+       bool prio_trees;
+       bool dry_run;
+       bool list_duplicates;
+       bool within_mount;
        char line_delim;
-       unsigned int within_mount:1;
        uintmax_t min_size;
        uintmax_t max_size;
        size_t io_size;
index a5f78d2af603fa28a51a208f521215f64bf48cb1..a911df6b723448ee2899c8a3741196810dbec21c 100644 (file)
@@ -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)
index 044fcab72e6db92ae79bb335f7558baad639356c..b2b9b40dcd01d4abaf4485ca469b07cfb16bb5b4 100644 (file)
@@ -6,6 +6,7 @@
 #ifndef UTIL_LINUX_LSBLK_H
 #define UTIL_LINUX_LSBLK_H
 
+#include <stdbool.h>
 #include <stdint.h>
 #include <inttypes.h>
 #include <sys/stat.h>
@@ -63,20 +64,20 @@ struct lsblk {
 
        int properties_by[__LSBLK_NMETHODS];
 
-       unsigned int all_devices:1;     /* print all devices, including empty */
-       unsigned int bytes:1;           /* print SIZE in bytes */
-       unsigned int inverse:1;         /* print inverse dependencies */
-       unsigned int merge:1;           /* merge sub-trees */
-       unsigned int nodeps:1;          /* don't print slaves/holders */
-       unsigned int scsi:1;            /* print only device with HCTL (SCSI) */
-       unsigned int nvme:1;            /* print NVMe device only */
-       unsigned int virtio:1;          /* print virtio device only */
-       unsigned int paths:1;           /* print devnames with "/dev" prefix */
-       unsigned int sort_hidden:1;     /* sort column not between output columns */
-       unsigned int rawdata : 1;       /* has rawdata in cell userdata */
-       unsigned int dedup_hidden :1;   /* deduplication column not between output columns */
-       unsigned int force_tree_order:1;/* sort lines by parent->tree relation */
-       unsigned int noempty:1;         /* hide empty devices */
+       bool all_devices;       /* print all devices, including empty */
+       bool bytes;             /* print SIZE in bytes */
+       bool inverse;           /* print inverse dependencies */
+       bool merge;             /* merge sub-trees */
+       bool nodeps;            /* don't print slaves/holders */
+       bool scsi;              /* print only device with HCTL (SCSI) */
+       bool nvme;              /* print NVMe device only */
+       bool virtio;            /* print virtio device only */
+       bool paths;             /* print devnames with "/dev" prefix */
+       bool sort_hidden;       /* sort column not between output columns */
+       bool rawdata;           /* has rawdata in cell userdata */
+       bool dedup_hidden;      /* deduplication column not between output columns */
+       bool force_tree_order;  /* sort lines by parent->tree relation */
+       bool noempty;           /* hide empty devices */
 };
 
 extern struct lsblk *lsblk;     /* global handler */
index d0d05088c6bcd6413615664f7b957720fdcd024c..bbf5d38e4e5a1c8a850f38f9c4d3d68f468b674b 100644 (file)
@@ -116,8 +116,8 @@ struct lock {
        off_t end;
        ino_t inode;
        dev_t dev;
-       unsigned int mandatory :1,
-                    blocked   :1;
+       bool  mandatory,
+             blocked;
        uint64_t size;
        int fd;
        int id;
index 99df4f4a6d973d8dad5b102553fe3da3088b8693..c837fb39ce9e828b6d1dc0f83d6c237cba801b32 100644 (file)
@@ -33,6 +33,7 @@
 
 #include <fcntl.h>
 #include <getopt.h>
+#include <stdbool.h>
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -50,7 +51,7 @@ struct mcookie_control {
        size_t  nfiles;
        uint64_t maxsz;
 
-       unsigned int verbose:1;
+       bool    verbose;
 };
 
 /* The basic function to hash a file */
index f3f2f42e240e9c7f6942cb4783915dc2ca1901e5..79992e309d694db766fd690131b5df8f45d491b6 100644 (file)
@@ -85,9 +85,9 @@ struct uuidd_options_t {
        const char       *socket_path;
        uuidd_prot_num_t num;
        uuidd_prot_op_t  do_type;
-       unsigned int     do_kill:1,
-                        no_pid:1,
-                        s_flag:1;
+       bool             do_kill,
+                        no_pid,
+                        s_flag;
 };
 
 static void __attribute__((__noreturn__)) usage(void)
index 1336038118a6bab4cbaea7b38ef89539d1f1f62d..7ad1e2e03283fa594daaeb72accaa2da304c1026 100644 (file)
@@ -83,10 +83,9 @@ static int columns[ARRAY_SIZE(infos) * 2];
 static size_t ncolumns;
 
 struct control {
-       unsigned int
-               json:1,
-               no_headings:1,
-               raw:1;
+       bool    json,
+               no_headings,
+               raw;
 };
 
 static void __attribute__((__noreturn__)) usage(void)
index 98c8da17ef49a492f424d8df60d3293772958723..8408f86dabcb4a49ff21dc6164b07a42ee147d25 100644 (file)
@@ -18,6 +18,7 @@
  * Copyright (C) 2010 Karel Zak <kzak@redhat.com>
  */
 
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -45,8 +46,8 @@ struct taskset {
        size_t          setsize;
        char            *buf;           /* buffer for conversion from mask to string */
        size_t          buflen;
-       unsigned int    use_list:1,     /* use list rather than masks */
-                       get_only:1;     /* print the mask, but not modify */
+       bool            use_list,       /* use list rather than masks */
+                       get_only;       /* print the mask, but not modify */
 };
 
 static void __attribute__((__noreturn__)) usage(void)
index 5968de93dbe81af9f65fcf5022740e6e54601e58..4b37557a12b4b2cd34559bc546aa2b10722807eb 100644 (file)
@@ -21,6 +21,7 @@
 #include <errno.h>
 #include <getopt.h>
 #include <sched.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -38,12 +39,12 @@ struct uclampset {
        unsigned int util_max;
 
        pid_t pid;
-       unsigned int    all_tasks:1,            /* all threads of the PID */
-                       system:1,
-                       util_min_set:1,         /* indicates -m option was passed */
-                       util_max_set:1,         /* indicates -M option was passed */
-                       reset_on_fork:1,
-                       verbose:1;
+       bool    all_tasks,              /* all threads of the PID */
+               system,
+               util_min_set,           /* indicates -m option was passed */
+               util_max_set,           /* indicates -M option was passed */
+               reset_on_fork,
+               verbose;
        char *cmd;
 };
 
index e73cddf5e064b3a73bd2fd19e6c4e7ddbf8763c8..a8369799f388314de99c0c333a8100b6d7fc490e 100644 (file)
@@ -233,20 +233,20 @@ struct dmesg_control {
 
        struct ul_jsonwrt jfmt;         /* -J formatting */
 
-       unsigned int    follow:1,       /* wait for new messages */
-                       end:1,          /* seek to the of buffer */
-                       raw:1,          /* raw mode */
-                       noesc:1,        /* no escape */
-                       fltr_lev:1,     /* filter out by levels[] */
-                       fltr_fac:1,     /* filter out by facilities[] */
-                       decode:1,       /* use "facility: level: " prefix */
-                       pager:1,        /* pipe output into a pager */
-                       color:1,        /* colorize messages */
-                       json:1,         /* JSON output */
-                       force_prefix:1; /* force timestamp and decode prefix
+       bool            follow,         /* wait for new messages */
+                       end,            /* seek to the of buffer */
+                       raw,            /* raw mode */
+                       noesc,          /* no escape */
+                       fltr_lev,       /* filter out by levels[] */
+                       fltr_fac,       /* filter out by facilities[] */
+                       decode,         /* use "facility: level: " prefix */
+                       pager,          /* pipe output into a pager */
+                       color,          /* colorize messages */
+                       json,           /* JSON output */
+                       force_prefix;   /* force timestamp and decode prefix
                                           on each line */
        int             indent;         /* due to timestamps if newline */
-       size_t          caller_id_size;   /* PRINTK_CALLERID max field size */
+       size_t          caller_id_size; /* PRINTK_CALLERID max field size */
 };
 
 struct dmesg_record {
index 12b1156008ee4f77e3ff0e206409adfd6da40c42..310d6c3dfad09b466ed6b85acf52904609ef0f46 100644 (file)
@@ -75,27 +75,27 @@ struct eject_control {
        struct libmnt_table *mtab;
        char *device;                   /* device or mount point to be ejected */
        int fd;                         /* file descriptor for device */
-       unsigned int                    /* command flags and arguments */
-               a_option:1,
-               c_option:1,
-               d_option:1,
-               F_option:1,
-               f_option:1,
-               i_option:1,
-               M_option:1,
-               m_option:1,
-               n_option:1,
-               p_option:1,
-               q_option:1,
-               r_option:1,
-               s_option:1,
-               T_option:1,
-               t_option:1,
-               v_option:1,
-               X_option:1,
-               x_option:1,
-               a_arg:1,
-               i_arg:1;
+       bool                            /* command flags and arguments */
+               a_option,
+               c_option,
+               d_option,
+               F_option,
+               f_option,
+               i_option,
+               M_option,
+               m_option,
+               n_option,
+               p_option,
+               q_option,
+               r_option,
+               s_option,
+               T_option,
+               t_option,
+               v_option,
+               X_option,
+               x_option,
+               a_arg,
+               i_arg;
 
        unsigned int force_exclusive;   /* use O_EXCL */
 
index 21b7efa3d2852d95b32cef97d77a307c69a2d0a6..2522d6c7dfc66f9a1bd1eab2ad8db2fb159341ce 100644 (file)
@@ -9,6 +9,7 @@
 #ifndef HWCLOCK_CLOCK_H
 #define HWCLOCK_CLOCK_H
 
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -41,30 +42,29 @@ struct hwclock_control {
 #endif
        char *param_get_option;
        char *param_set_option;
-       unsigned int
-               hwaudit_on:1,
-               adjust:1,
-               show:1,
-               hctosys:1,
-               utc:1,
-               systohc:1,
+       bool    hwaudit_on,
+               adjust,
+               show,
+               hctosys,
+               utc,
+               systohc,
 #if defined(__linux__) && defined(__alpha__)
-               getepoch:1,
-               setepoch:1,
+               getepoch,
+               setepoch,
 #endif
-               noadjfile:1,
-               local_opt:1,
-               directisa:1,
-               testing:1,
-               systz:1,
-               predict:1,
-               get:1,
-               set:1,
-               update:1,
-               universal:1,    /* will store hw_clock_is_utc() return value */
-               vl_read:1,
-               vl_clear:1,
-               verbose:1;
+               noadjfile,
+               local_opt,
+               directisa,
+               testing,
+               systz,
+               predict,
+               get,
+               set,
+               update,
+               universal,      /* will store hw_clock_is_utc() return value */
+               vl_read,
+               vl_clear,
+               verbose;
 };
 
 struct clock_ops {
index a23a51a96061d482754c3070d6f890342b090c29..02b72d75230a289f6af64e88d7a3770955e749de 100644 (file)
@@ -12,6 +12,8 @@
 #ifndef UTIL_LINUX_H_IRQ_COMMON
 #define UTIL_LINUX_H_IRQ_COMMON
 
+#include <stdbool.h>
+
 #include "c.h"
 #include "nls.h"
 #include "cpuset.h"
@@ -58,10 +60,9 @@ struct irq_output {
 
        irq_cmp_t *sort_cmp_func;
 
-       unsigned int
-               json:1,         /* JSON output */
-               pairs:1,        /* export, NAME="value" aoutput */
-               no_headings:1;  /* don't print header */
+       bool    json,           /* JSON output */
+               pairs,          /* export, NAME="value" aoutput */
+               no_headings;    /* don't print header */
 };
 
 int irq_column_name_to_id(char const *const name, size_t const namesz);
index 0a732a1c3f704c5dd81eb9964cc8e1c6820b486f..8fbedb16ab3206a0672f92f85a3ace5fedae1341 100644 (file)
@@ -71,10 +71,10 @@ enum irqtop_cpustat_mode {
 
 /* top control struct */
 struct irqtop_ctl {
-       WINDOW          *win;
-       int             cols;
-       int             rows;
-       char            *hostname;
+       WINDOW  *win;
+       int     cols;
+       int     rows;
+       char    *hostname;
 
        struct itimerspec timer;
        struct irq_stat *prev_stat;
@@ -83,8 +83,8 @@ struct irqtop_ctl {
        cpu_set_t *cpuset;
 
        enum irqtop_cpustat_mode cpustat_mode;
-       unsigned int request_exit:1;
-       unsigned int softirq:1;
+       bool    request_exit,
+               softirq;
 };
 
 /* user's input parser */
index 455bbf4e9116b452912d94e8c0f011a5f0436b18..17eaea9f42070a1f2c19dd2cc74bf5b17a3a743b 100644 (file)
@@ -127,7 +127,7 @@ struct lscpu_coldesc {
        const char *help;
 
        int flags;
-       unsigned int  is_abbr:1;        /* name is abbreviation */
+       bool is_abbr;   /* name is abbreviation */
        int json_type;
 };
 
index a79206e9336b1341cec81c785809ac9a13d26211..4d394a81d6e87fc760e9c2b80adc4df679660d16 100644 (file)
@@ -12,6 +12,8 @@
 #ifndef LSCPU_H
 #define LSCPU_H
 
+#include <stdbool.h>
+
 #include "c.h"
 #include "nls.h"
 #include "cpuset.h"
@@ -160,8 +162,8 @@ struct lscpu_cpu {
 struct lscpu_arch {
        char    *name;          /* uname() .machine */
 
-       unsigned int    bit32:1,
-                       bit64:1;
+       bool    bit32,
+               bit64;
 };
 
 struct lscpu_vulnerability {
index 9ea80cb857d01ceaf4bba0745239100ce4d292ec..c9851e98c4f23f56837bac14b1f357c5d4ea2457 100644 (file)
@@ -18,6 +18,7 @@
 #include <closestream.h>
 #include <xalloc.h>
 #include <getopt.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <dirent.h>
@@ -53,7 +54,7 @@ struct memory_block {
        int             node;
        int             nr_zones;
        int             zones[MAX_NR_ZONES];
-       unsigned int    removable:1;
+       bool            removable;
 };
 
 struct lsmem {
index 8f0b0d5f45ceaa233bb384338f0d2380a0bb5119..6294a4c07a8971934008e6ee7d44e59d96f22f55 100644 (file)
@@ -14,6 +14,7 @@
  * This is libmount based reimplementation of the mountpoint(1)
  * from sysvinit project.
  */
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
@@ -37,11 +38,10 @@ struct mountpoint_control {
        char *path;
        dev_t dev;
        struct stat st;
-       unsigned int
-               dev_devno:1,
-               fs_devno:1,
-               nofollow:1,
-               quiet:1;
+       bool    dev_devno,
+               fs_devno,
+               nofollow,
+               quiet;
 };
 
 static int dir_to_device(struct mountpoint_control *ctl)
index fcb249208d14c6b0df0d297edc905742c0f6e084..860e86425f575a527102b346de29928adb12accf 100644 (file)
@@ -142,10 +142,9 @@ static size_t ncolumns;
 
 struct control {
        struct libscols_table *tb;
-       unsigned int
-               json:1,
-               no_headings:1,
-               raw:1;
+       bool    json,
+               no_headings,
+               raw;
 };
 
 static int column_name_to_id(const char *name, size_t namesz)
index aeabead70b03d61c7d1184efc3c81ff84aa6dee0..d384feb64516d8dab37b23e1968d273bf9d7e363 100644 (file)
@@ -96,8 +96,8 @@ struct rtcwake_control {
        enum clock_modes clock_mode;    /* hwclock timezone */
        time_t sys_time;                /* system time */
        time_t rtc_time;                /* hardware time */
-       unsigned int verbose:1,         /* verbose messaging */
-                    dryrun:1;          /* do not set alarm, suspend system, etc */
+       bool    verbose,                /* verbose messaging */
+               dryrun;                 /* do not set alarm, suspend system, etc */
 };
 
 static void __attribute__((__noreturn__)) usage(void)
index 5899552d6da4391e58acf19889c5f1559fda7b2a..19b8c80aa797cb3edacbf90b638e0e14c02409f6 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/securebits.h>
 #include <pwd.h>
 #include <stdarg.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/prctl.h>
@@ -75,20 +76,19 @@ enum cap_type {
  */
 
 struct privctx {
-       unsigned int
-               nnp:1,                  /* no_new_privs */
-               have_ruid:1,            /* real uid */
-               have_euid:1,            /* effective uid */
-               have_rgid:1,            /* real gid */
-               have_egid:1,            /* effective gid */
-               have_passwd:1,          /* passwd entry */
-               have_groups:1,          /* add groups */
-               keep_groups:1,          /* keep groups */
-               clear_groups:1,         /* remove groups */
-               init_groups:1,          /* initialize groups */
-               reset_env:1,            /* reset environment */
-               have_securebits:1,      /* remove groups */
-               have_ptracer:1;         /* modify ptracer */
+       bool    nnp,                    /* no_new_privs */
+               have_ruid,              /* real uid */
+               have_euid,              /* effective uid */
+               have_rgid,              /* real gid */
+               have_egid,              /* effective gid */
+               have_passwd,            /* passwd entry */
+               have_groups,            /* add groups */
+               keep_groups,            /* keep groups */
+               clear_groups,           /* remove groups */
+               init_groups,            /* initialize groups */
+               reset_env,              /* reset environment */
+               have_securebits,        /* remove groups */
+               have_ptracer;           /* modify ptracer */
 
        /* uids and gids */
        uid_t ruid, euid;
index ce499c10d73fac260338df75b9c33466ddfafa06..419155d67394bff887689801c4263f1d1d0043bf 100644 (file)
@@ -12,6 +12,7 @@
  * the code. Karel Zak rewrote the code under GPL-2.0-or-later.
  */
 #include <assert.h>
+#include <stdbool.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <getopt.h>
@@ -138,14 +139,13 @@ struct swapon_ctl {
 
        struct swap_prop props;         /* global settings for all devices */
 
-       unsigned int
-               all:1,                  /* turn on all swap devices */
-               bytes:1,                /* display --show in bytes */
-               fix_page_size:1,        /* reinitialize page size */
-               no_heading:1,           /* toggle --show headers */
-               raw:1,                  /* toggle --show alignment */
-               show:1,                 /* display --show information */
-               verbose:1;              /* be chatty */
+       bool    all,                    /* turn on all swap devices */
+               bytes,                  /* display --show in bytes */
+               fix_page_size,          /* reinitialize page size */
+               no_heading,             /* toggle --show headers */
+               raw,                    /* toggle --show alignment */
+               show,                   /* display --show information */
+               verbose;                /* be chatty */
 };
 
 static int column_name_to_id(const char *name, size_t namesz)
index 3457ac8174741960cb17fe1d18e01c2e60f49e7c..59b640256481d706440e82cfd9277bea1e8f5ebc 100644 (file)
@@ -140,13 +140,12 @@ struct script_control {
        pid_t child;            /* child pid */
        int childstatus;        /* child process exit value */
 
-       unsigned int
-        append:1,              /* append output */
-        rc_wanted:1,           /* return child exit value */
-        flush:1,               /* flush after each write */
-        quiet:1,               /* suppress most output */
-        force:1,               /* write output to links */
-        isterm:1;              /* is child process running as terminal */
+       bool    append,         /* append output */
+               rc_wanted,      /* return child exit value */
+               flush,          /* flush after each write */
+               quiet,          /* suppress most output */
+               force,          /* write output to links */
+               isterm;         /* is child process running as terminal */
 };
 
 static ssize_t log_info(struct script_control *ctl, const char *name, const char *msgfmt, ...)
index a41a5c98ed99c35f6615754428964b02f3ab2c02..d9f9b450205ce5ae06c5d29846e1fc9917c88838 100644 (file)
@@ -50,6 +50,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <getopt.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -173,22 +174,22 @@ struct setterm_control {
        int opt_rt_len;         /* regular tab length */
        int opt_tb_array[TABS_MAX + 1]; /* array for tab list */
        /* colors */
-       unsigned int opt_fo_color:4, opt_ba_color:4, opt_ul_color:4, opt_hb_color:4;
+       uint8_t opt_fo_color, opt_ba_color, opt_ul_color, opt_hb_color;
        /* boolean options */
-       unsigned int opt_cu_on:1, opt_li_on:1, opt_bo_on:1, opt_hb_on:1,
-           opt_bl_on:1, opt_re_on:1, opt_un_on:1, opt_rep_on:1,
-           opt_appck_on:1, opt_invsc_on:1, opt_msg_on:1, opt_cl_all:1,
-           vcterm:1;
+       bool opt_cu_on, opt_li_on, opt_bo_on, opt_hb_on,
+           opt_bl_on, opt_re_on, opt_un_on, opt_rep_on,
+           opt_appck_on, opt_invsc_on, opt_msg_on, opt_cl_all,
+           vcterm;
        /* Option flags.  Set when an option is invoked. */
-       uint64_t opt_term:1, opt_reset:1, opt_resize:1, opt_initialize:1, opt_cursor:1,
-           opt_linewrap:1, opt_default:1, opt_foreground:1,
-           opt_background:1, opt_bold:1, opt_blink:1, opt_reverse:1,
-           opt_underline:1, opt_store:1, opt_clear:1, opt_blank:1,
-           opt_snap:1, opt_snapfile:1, opt_append:1, opt_ulcolor:1,
-           opt_hbcolor:1, opt_halfbright:1, opt_repeat:1, opt_tabs:1,
-           opt_clrtabs:1, opt_regtabs:1, opt_appcursorkeys:1,
-           opt_inversescreen:1, opt_msg:1, opt_msglevel:1, opt_powersave:1,
-           opt_powerdown:1, opt_blength:1, opt_bfreq:1;
+       bool opt_term, opt_reset, opt_resize, opt_initialize, opt_cursor,
+           opt_linewrap, opt_default, opt_foreground,
+           opt_background, opt_bold, opt_blink, opt_reverse,
+           opt_underline, opt_store, opt_clear, opt_blank,
+           opt_snap, opt_snapfile, opt_append, opt_ulcolor,
+           opt_hbcolor, opt_halfbright, opt_repeat, opt_tabs,
+           opt_clrtabs, opt_regtabs, opt_appcursorkeys,
+           opt_inversescreen, opt_msg, opt_msglevel, opt_powersave,
+           opt_powerdown, opt_blength, opt_bfreq;
 };
 
 static int parse_color(const char *arg)
index f9bc3be40c4f1baa10fcaf4ae2782369e3996213..37654eae5214ba04ca1a8947d3a8e18d5fa6d030 100644 (file)
@@ -56,6 +56,7 @@
 #include <ctype.h>
 #include <errno.h>
 #include <getopt.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -105,7 +106,7 @@ struct col_char {
        wchar_t         c_char;         /* character in question */
        int             c_width;        /* character width */
 
-       uint8_t         c_set:1;        /* character set (currently only 2) */
+       uint8_t         c_set;          /* character set (currently only 2) */
 };
 
 struct col_line {
@@ -116,7 +117,7 @@ struct col_line {
        size_t          l_line_len;     /* strlen(l_line) */
        size_t          l_max_col;      /* max column in the line */
 
-       uint8_t         l_needs_sort:1; /* set if chars went in out of order */
+       bool            l_needs_sort;   /* set if chars went in out of order */
 };
 
 #ifdef COL_DEALLOCATE_ON_EXIT
@@ -139,12 +140,11 @@ struct col_ctl {
        struct col_alloc *alloc_root;   /* first of line allocations */
        struct col_alloc *alloc_head;   /* latest line allocation */
 #endif
-       unsigned int
-               last_set:1,             /* char_set of last char printed */
-               compress_spaces:1,      /* if doing space -> tab conversion */
-               fine:1,                 /* if `fine' resolution (half lines) */
-               no_backspaces:1,        /* if not to output any backspaces */
-               pass_unknown_seqs:1;    /* whether to pass unknown control sequences */
+       bool    last_set,               /* char_set of last char printed */
+               compress_spaces,        /* if doing space -> tab conversion */
+               fine,                   /* if `fine' resolution (half lines) */
+               no_backspaces,          /* if not to output any backspaces */
+               pass_unknown_seqs;      /* whether to pass unknown control sequences */
 };
 
 struct col_lines {
@@ -158,9 +158,8 @@ struct col_lines {
        size_t nflushd_lines;
        size_t this_line;
 
-       unsigned int
-               cur_set:1,
-               warned:1;
+       bool    cur_set,
+               warned;
 };
 
 static void __attribute__((__noreturn__)) usage(void)
index 4a1214cc8068e0841e9c2ed83184c6da1cb2e392..2e5c4e56e742c23fbe95e118738b46df015487ad 100644 (file)
@@ -41,6 +41,7 @@
  *     modified to work correctly in multi-byte locales
  */
 
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <getopt.h>
 enum { OUTPUT_COLS = 132 };
 
 struct colcrt_control {
-       FILE            *f;
-       wchar_t         line[OUTPUT_COLS + 1];
-       wchar_t         line_under[OUTPUT_COLS + 1];
-       unsigned int    print_nl:1,
-                       need_line_under:1,
-                       no_underlining:1,
-                       half_lines:1;
+       FILE    *f;
+       wchar_t line[OUTPUT_COLS + 1];
+       wchar_t line_under[OUTPUT_COLS + 1];
+       bool    print_nl,
+               need_line_under,
+               no_underlining,
+               half_lines;
 };
 
 static void __attribute__((__noreturn__)) usage(void)
index f5ae83d727e6e5bc7897fd8ad0db21f5e126c9c3..a0a94867f119bc8ba5d697325fbe7a97b0e12a4d 100644 (file)
 #include <sys/ioctl.h>
 
 #include <ctype.h>
+#include <errno.h>
+#include <stdbool.h>
 #include <stdio.h>
-#include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
-#include <errno.h>
+#include <unistd.h>
 #include <getopt.h>
 
 #include "nls.h"
@@ -96,14 +97,14 @@ struct column_control {
        size_t  maxncols;       /* maximal number of input columns */
        size_t  mincolsep;      /* minimal spaces between columns */
 
-       unsigned int greedy :1,
-                    json :1,
-                    header_repeat :1,
-                    hide_unnamed :1,
-                    maxout : 1,
-                    keep_empty_lines :1,       /* --keep-empty-lines */
-                    tab_noheadings :1,
-                    use_spaces :1;
+       bool    greedy,
+               json,
+               header_repeat,
+               hide_unnamed,
+               maxout : 1,
+               keep_empty_lines,       /* --keep-empty-lines */
+               tab_noheadings,
+               use_spaces;
 };
 
 typedef enum {
index 99e7cf5d02ffec869f306b7f184108c14af31572..e39fe724c98a0defbe01e13d14a4cf1c325605a4 100644 (file)
@@ -201,38 +201,38 @@ struct more_control {
        magic_t magic;                  /* libmagic database entries */
 #endif
        unsigned int
-               ignore_stdin:1,         /* POLLHUP; peer closed pipe */
-               bad_stdout:1,           /* true if overwriting does not turn off standout */
-               catch_suspend:1,        /* we should catch the SIGTSTP signal */
-               clear_line_ends:1,      /* do not scroll, paint each screen from the top */
-               clear_first:1,          /* is first character in file \f */
-               dumb_tty:1,             /* is terminal type known */
-               eat_newline:1,          /* is newline ignored after 80 cols */
-               erase_input_ok:1,       /* is erase input supported */
-               erase_previous_ok:1,    /* is erase previous supported */
-               exit_on_eof:1,          /* exit on EOF */
-               first_file:1,           /* is the input file the first in list */
-               fold_long_lines:1,      /* fold long lines */
-               hard_tabs:1,            /* print spaces instead of '\t' */
-               hard_tty:1,             /* is this hard copy terminal (a printer or such) */
-               leading_colon:1,        /* key command has leading ':' character */
-               is_eof:1,               /* EOF detected */
-               is_paused:1,            /* is output paused */
-               no_quit_dialog:1,       /* suppress quit dialog */
-               no_scroll:1,            /* do not scroll, clear the screen and then display text */
-               no_tty_in:1,            /* is input in interactive mode */
-               no_tty_out:1,           /* is output in interactive mode */
-               no_tty_err:1,           /* is stderr terminal */
-               print_banner:1,         /* print file name banner */
-               reading_num:1,          /* are we reading leading_number */
-               report_errors:1,        /* is an error reported */
-               search_at_start:1,      /* search pattern defined at start up */
-               search_called:1,        /* previous more command was a search */
-               squeeze_spaces:1,       /* suppress white space */
-               stdout_glitch:1,        /* terminal has standout mode glitch */
-               stop_after_formfeed:1,  /* stop after form feeds */
-               suppress_bell:1,        /* suppress bell */
-               wrap_margin:1;          /* set if automargins */
+               ignore_stdin,           /* POLLHUP; peer closed pipe */
+               bad_stdout,             /* true if overwriting does not turn off standout */
+               catch_suspend,          /* we should catch the SIGTSTP signal */
+               clear_line_ends,        /* do not scroll, paint each screen from the top */
+               clear_first,            /* is first character in file \f */
+               dumb_tty,               /* is terminal type known */
+               eat_newline,            /* is newline ignored after 80 cols */
+               erase_input_ok,         /* is erase input supported */
+               erase_previous_ok,      /* is erase previous supported */
+               exit_on_eof,            /* exit on EOF */
+               first_file,             /* is the input file the first in list */
+               fold_long_lines,        /* fold long lines */
+               hard_tabs,              /* print spaces instead of '\t' */
+               hard_tty,               /* is this hard copy terminal (a printer or such) */
+               leading_colon,          /* key command has leading ':' character */
+               is_eof,                 /* EOF detected */
+               is_paused,              /* is output paused */
+               no_quit_dialog,         /* suppress quit dialog */
+               no_scroll,              /* do not scroll, clear the screen and then display text */
+               no_tty_in,              /* is input in interactive mode */
+               no_tty_out,             /* is output in interactive mode */
+               no_tty_err,             /* is stderr terminal */
+               print_banner,           /* print file name banner */
+               reading_num,            /* are we reading leading_number */
+               report_errors,          /* is an error reported */
+               search_at_start,        /* search pattern defined at start up */
+               search_called,          /* previous more command was a search */
+               squeeze_spaces,         /* suppress white space */
+               stdout_glitch,          /* terminal has standout mode glitch */
+               stop_after_formfeed,    /* stop after form feeds */
+               suppress_bell,          /* suppress bell */
+               wrap_margin;            /* set if automargins */
 };
 
 static void __attribute__((__noreturn__)) usage(void)
index 62bfcd7bf9c8f04dbec4935081bfd6e2fa6163ee..8fa6428cd6f9d62f7cc57295861865359b0c9f92 100644 (file)
@@ -40,6 +40,7 @@
  *     modified to work correctly in multi-byte locales
  */
 
+#include <stdbool.h>
 #include <stdio.h>
 #include <unistd.h>            /* for getopt(), isatty() */
 #include <string.h>            /* for memset(), strcpy() */
@@ -110,10 +111,9 @@ struct ul_ctl {
        int current_mode;
        size_t buflen;
        struct ul_char *buf;
-       unsigned int
-               indicated_opt:1,
-               must_use_uc:1,
-               must_overstrike:1;
+       bool    indicated_opt,
+               must_use_uc,
+               must_overstrike;
 };
 
 static void __attribute__((__noreturn__)) usage(void)