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.)
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 */
};
{
const char *device;
dev_t disk;
- unsigned int stacked:1,
- done:1,
- eval_device:1;
+ bool stacked,
+ done,
+ eval_device;
};
/*
*
*/
+#include <stdbool.h>
#include <stdio.h>
#include <time.h>
#include <unistd.h>
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];
* Copyright (C) 2007-2014 Karel Zak <kzak@redhat.com>
*/
+#include <stdbool.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
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)
#ifndef UTIL_LINUX_LOOPDEV_H
#define UTIL_LINUX_LOOPDEV_H
+#include <stdbool.h>
#include "sysfs.h"
/*
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 */
};
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 */
#include <pty.h>
#include <termios.h>
#include <signal.h>
+#include <stdbool.h>
#include <sys/time.h>
#include <sys/stat.h>
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);
*/
#include <unistd.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <err.h>
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;
#define _LIBFDISK_PRIVATE_H
#include <errno.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
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;
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 {
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;
};
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);
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)
* 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 */
#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 */
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;
#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 */
};
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)
* %End-Header%
*/
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
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)
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 {
#define CLOSE_EXIT_CODE XALLOC_EXIT_CODE
#define TEST_EXIT_CODE 4
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
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 };
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;
#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)
#ifndef UTIL_LINUX_LSBLK_H
#define UTIL_LINUX_LSBLK_H
+#include <stdbool.h>
#include <stdint.h>
#include <inttypes.h>
#include <sys/stat.h>
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 */
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;
#include <fcntl.h>
#include <getopt.h>
+#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
size_t nfiles;
uint64_t maxsz;
- unsigned int verbose:1;
+ bool verbose;
};
/* The basic function to hash a file */
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)
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)
* Copyright (C) 2010 Karel Zak <kzak@redhat.com>
*/
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
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)
#include <errno.h>
#include <getopt.h>
#include <sched.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
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;
};
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 {
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 */
#ifndef HWCLOCK_CLOCK_H
#define HWCLOCK_CLOCK_H
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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 {
#ifndef UTIL_LINUX_H_IRQ_COMMON
#define UTIL_LINUX_H_IRQ_COMMON
+#include <stdbool.h>
+
#include "c.h"
#include "nls.h"
#include "cpuset.h"
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);
/* 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;
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 */
const char *help;
int flags;
- unsigned int is_abbr:1; /* name is abbreviation */
+ bool is_abbr; /* name is abbreviation */
int json_type;
};
#ifndef LSCPU_H
#define LSCPU_H
+#include <stdbool.h>
+
#include "c.h"
#include "nls.h"
#include "cpuset.h"
struct lscpu_arch {
char *name; /* uname() .machine */
- unsigned int bit32:1,
- bit64:1;
+ bool bit32,
+ bit64;
};
struct lscpu_vulnerability {
#include <closestream.h>
#include <xalloc.h>
#include <getopt.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
int node;
int nr_zones;
int zones[MAX_NR_ZONES];
- unsigned int removable:1;
+ bool removable;
};
struct lsmem {
* This is libmount based reimplementation of the mountpoint(1)
* from sysvinit project.
*/
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
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)
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)
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)
#include <linux/securebits.h>
#include <pwd.h>
#include <stdarg.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/prctl.h>
*/
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;
* 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>
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)
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, ...)
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
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)
#include <ctype.h>
#include <errno.h>
#include <getopt.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
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 {
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
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 {
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)
* 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)
#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"
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 {
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)
* 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() */
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)