From 2ba641e5f3879593e36fa84872289872a4060d03 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 12 Feb 2017 00:19:33 +0000 Subject: [PATCH] misc: add static keyword to where needed [smatch scan] text-utils/rev.c:68:9: warning: symbol 'buf' was not declared. Should it be static? Signed-off-by: Sami Kerola --- disk-utils/cfdisk.c | 6 +- disk-utils/fdformat.c | 2 +- disk-utils/fdisk-menu.c | 16 ++-- disk-utils/fsck.c | 2 +- disk-utils/fsck.cramfs.c | 4 +- disk-utils/partx.c | 4 +- disk-utils/raw.c | 8 +- disk-utils/sfdisk.c | 2 +- lib/colors.c | 2 +- lib/loopdev.c | 2 +- libblkid/src/superblocks/drbdmanage.c | 2 +- libblkid/src/topology/evms.c | 2 +- libfdisk/src/sun.c | 2 +- login-utils/sulogin.c | 10 +-- login-utils/vipw.c | 6 +- misc-utils/blkid.c | 2 +- misc-utils/findmnt.c | 2 +- misc-utils/getopt.c | 4 +- misc-utils/kill.c | 2 +- misc-utils/look.c | 18 ++--- misc-utils/lsblk.c | 6 +- misc-utils/whereis.c | 2 +- schedutils/ionice.c | 2 +- sys-utils/hwclock-cmos.c | 26 +++---- sys-utils/hwclock.c | 2 +- sys-utils/ipcs.c | 2 +- sys-utils/lscpu.c | 12 +-- sys-utils/lsns.c | 4 +- sys-utils/prlimit.c | 2 +- sys-utils/renice.c | 2 +- sys-utils/swapon.c | 2 +- term-utils/script.c | 2 +- text-utils/col.c | 16 ++-- text-utils/column.c | 4 +- text-utils/more.c | 106 +++++++++++++------------- text-utils/pg.c | 64 ++++++++-------- text-utils/rev.c | 2 +- text-utils/ul.c | 45 ++++++----- 38 files changed, 199 insertions(+), 200 deletions(-) diff --git a/disk-utils/cfdisk.c b/disk-utils/cfdisk.c index 4ad52842cc..f06dad1c85 100644 --- a/disk-utils/cfdisk.c +++ b/disk-utils/cfdisk.c @@ -150,8 +150,8 @@ static int ui_resize; /* ncurses LINES and COLS may be actual variables or *macros*, but we need * something portable and writable */ -size_t ui_lines; -size_t ui_cols; +static size_t ui_lines; +static size_t ui_cols; /* menu item */ struct cfdisk_menuitem { @@ -245,7 +245,7 @@ struct cfdisk { /* * let's use include/debug.h stuff for cfdisk too */ -UL_DEBUG_DEFINE_MASK(cfdisk); +static UL_DEBUG_DEFINE_MASK(cfdisk); UL_DEBUG_DEFINE_MASKNAMES(cfdisk) = UL_DEBUG_EMPTY_MASKNAMES; #define CFDISK_DEBUG_INIT (1 << 1) diff --git a/disk-utils/fdformat.c b/disk-utils/fdformat.c index ad6b62b50d..142bca0ecf 100644 --- a/disk-utils/fdformat.c +++ b/disk-utils/fdformat.c @@ -20,7 +20,7 @@ #define SECTOR_SIZE 512 -struct floppy_struct param; +static struct floppy_struct param; static void format_begin(int ctrl) diff --git a/disk-utils/fdisk-menu.c b/disk-utils/fdisk-menu.c index baac9791a0..9ab28c43f9 100644 --- a/disk-utils/fdisk-menu.c +++ b/disk-utils/fdisk-menu.c @@ -89,7 +89,7 @@ DECLARE_MENU_CB(generic_menu_cb); #define MENU_XENT_NEST(k, t, l, p) { .title = t, .key = k, .expert = 1, .label = l, .parent = p } /* Generic menu */ -struct menu menu_generic = { +static const struct menu menu_generic = { .callback = generic_menu_cb, .entries = { MENU_BSEP(N_("Generic")), @@ -127,7 +127,7 @@ struct menu menu_generic = { } }; -struct menu menu_createlabel = { +static const struct menu menu_createlabel = { .callback = createlabel_menu_cb, .exclude = FDISK_DISKLABEL_BSD, .nonested = 1, @@ -145,7 +145,7 @@ struct menu menu_createlabel = { } }; -struct menu menu_geo = { +static const struct menu menu_geo = { .callback = geo_menu_cb, .exclude = FDISK_DISKLABEL_GPT | FDISK_DISKLABEL_BSD, .entries = { @@ -157,7 +157,7 @@ struct menu menu_geo = { } }; -struct menu menu_gpt = { +static const struct menu menu_gpt = { .callback = gpt_menu_cb, .label = FDISK_DISKLABEL_GPT, .entries = { @@ -178,7 +178,7 @@ struct menu menu_gpt = { } }; -struct menu menu_sun = { +static const struct menu menu_sun = { .callback = sun_menu_cb, .label = FDISK_DISKLABEL_SUN, .entries = { @@ -195,7 +195,7 @@ struct menu menu_sun = { } }; -struct menu menu_sgi = { +static const struct menu menu_sgi = { .callback = sgi_menu_cb, .label = FDISK_DISKLABEL_SGI, .entries = { @@ -208,7 +208,7 @@ struct menu menu_sgi = { } }; -struct menu menu_dos = { +static const struct menu menu_dos = { .callback = dos_menu_cb, .label = FDISK_DISKLABEL_DOS, .entries = { @@ -226,7 +226,7 @@ struct menu menu_dos = { } }; -struct menu menu_bsd = { +static const struct menu menu_bsd = { .callback = bsd_menu_cb, .label = FDISK_DISKLABEL_BSD, .entries = { diff --git a/disk-utils/fsck.c b/disk-utils/fsck.c index 93296c97d6..cb1b21278c 100644 --- a/disk-utils/fsck.c +++ b/disk-utils/fsck.c @@ -931,7 +931,7 @@ err: /* * Deal with the fsck -t argument. */ -struct fs_type_compile { +static struct fs_type_compile { char **list; int *type; int negate; diff --git a/disk-utils/fsck.cramfs.c b/disk-utils/fsck.cramfs.c index 81e17be27b..63033d626d 100644 --- a/disk-utils/fsck.cramfs.c +++ b/disk-utils/fsck.cramfs.c @@ -69,11 +69,11 @@ static int fd; /* ROM image file descriptor */ static char *filename; /* ROM image filename */ -struct cramfs_super super; /* just find the cramfs superblock once */ +static struct cramfs_super super; /* just find the cramfs superblock once */ static int cramfs_is_big_endian = 0; /* source is big endian */ static int opt_verbose = 0; /* 1 = verbose (-v), 2+ = very verbose (-vv) */ static int opt_extract = 0; /* extract cramfs (-x) */ -char *extract_dir = ""; /* optional extraction directory (-x) */ +static char *extract_dir = ""; /* optional extraction directory (-x) */ #define PAD_SIZE 512 diff --git a/disk-utils/partx.c b/disk-utils/partx.c index d1964b458f..a0e337b78b 100644 --- a/disk-utils/partx.c +++ b/disk-utils/partx.c @@ -82,7 +82,7 @@ struct colinfo { }; /* columns descriptions */ -struct colinfo infos[] = { +static struct colinfo infos[] = { [COL_PARTNO] = { "NR", 0.25, SCOLS_FL_RIGHT, N_("partition number") }, [COL_START] = { "START", 0.30, SCOLS_FL_RIGHT, N_("start of the partition in sectors") }, [COL_END] = { "END", 0.30, SCOLS_FL_RIGHT, N_("end of the partition in sectors") }, @@ -99,7 +99,7 @@ struct colinfo infos[] = { /* array with IDs of enabled columns */ static int columns[NCOLS]; -size_t ncolumns; +static size_t ncolumns; static int verbose; static int partx_flags; diff --git a/disk-utils/raw.c b/disk-utils/raw.c index d5c2a681f1..395e367033 100644 --- a/disk-utils/raw.c +++ b/disk-utils/raw.c @@ -32,11 +32,11 @@ #define RAW_NR_MINORS 8192 -int do_query; -int do_query_all; +static int do_query; +static int do_query_all; -int master_fd; -int raw_minor; +static int master_fd; +static int raw_minor; void open_raw_ctl(void); static int query(int minor_raw, const char *raw_name, int quiet); diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c index b304acb534..f4f9b6b1ad 100644 --- a/disk-utils/sfdisk.c +++ b/disk-utils/sfdisk.c @@ -55,7 +55,7 @@ /* * sfdisk debug stuff (see fdisk.h and include/debug.h) */ -UL_DEBUG_DEFINE_MASK(sfdisk); +static UL_DEBUG_DEFINE_MASK(sfdisk); UL_DEBUG_DEFINE_MASKNAMES(sfdisk) = UL_DEBUG_EMPTY_MASKNAMES; #define SFDISKPROG_DEBUG_INIT (1 << 1) diff --git a/lib/colors.c b/lib/colors.c index 99e2228ed2..4b280fe270 100644 --- a/lib/colors.c +++ b/lib/colors.c @@ -34,7 +34,7 @@ /* * terminal-colors.d debug stuff */ -UL_DEBUG_DEFINE_MASK(termcolors); +static UL_DEBUG_DEFINE_MASK(termcolors); UL_DEBUG_DEFINE_MASKNAMES(termcolors) = UL_DEBUG_EMPTY_MASKNAMES; #define TERMCOLORS_DEBUG_INIT (1 << 1) diff --git a/lib/loopdev.c b/lib/loopdev.c index a57e7a73b4..fd4f16692d 100644 --- a/lib/loopdev.c +++ b/lib/loopdev.c @@ -46,7 +46,7 @@ /* * Debug stuff (based on include/debug.h) */ -UL_DEBUG_DEFINE_MASK(loopdev); +static UL_DEBUG_DEFINE_MASK(loopdev); UL_DEBUG_DEFINE_MASKNAMES(loopdev) = UL_DEBUG_EMPTY_MASKNAMES; #define LOOPDEV_DEBUG_INIT (1 << 1) diff --git a/libblkid/src/superblocks/drbdmanage.c b/libblkid/src/superblocks/drbdmanage.c index e84efa3438..48bf1dabf0 100644 --- a/libblkid/src/superblocks/drbdmanage.c +++ b/libblkid/src/superblocks/drbdmanage.c @@ -35,7 +35,7 @@ struct drbdmanage_pers { } __attribute__ ((packed)); -const char persistence_magic[4] = "\x1a\xdb\x98\xa2"; +static const char persistence_magic[4] = "\x1a\xdb\x98\xa2"; static int probe_drbdmanage(blkid_probe pr, diff --git a/libblkid/src/topology/evms.c b/libblkid/src/topology/evms.c index eed41d8b4f..a4656d5b88 100644 --- a/libblkid/src/topology/evms.c +++ b/libblkid/src/topology/evms.c @@ -30,7 +30,7 @@ #define _IOT_evms_stripe_info _IOT (_IOTS(uint32_t), 2, 0, 0, 0, 0) #define EVMS_GET_STRIPE_INFO _IOR(EVMS_MAJOR, 0xF0, struct evms_stripe_info) -struct evms_stripe_info { +static struct evms_stripe_info { uint32_t size; /* stripe unit 512-byte blocks */ uint32_t width; /* the number of stripe members or RAID data disks */ } evms_stripe_info; diff --git a/libfdisk/src/sun.c b/libfdisk/src/sun.c index ac46d2ae57..5414a927c6 100644 --- a/libfdisk/src/sun.c +++ b/libfdisk/src/sun.c @@ -1121,7 +1121,7 @@ static const struct fdisk_field sun_fields[] = { FDISK_FIELD_ATTR, N_("Flags"), 0, FDISK_FIELDFL_NUMBER } }; -const struct fdisk_label_operations sun_operations = +static const struct fdisk_label_operations sun_operations = { .probe = sun_probe_label, .write = sun_write_disklabel, diff --git a/login-utils/sulogin.c b/login-utils/sulogin.c index b1e8c90f4c..9f539d791d 100644 --- a/login-utils/sulogin.c +++ b/login-utils/sulogin.c @@ -71,11 +71,11 @@ static unsigned int timeout; static int profile; static volatile uint32_t openfd; /* Remember higher file descriptors */ -struct sigaction saved_sigint; -struct sigaction saved_sigtstp; -struct sigaction saved_sigquit; -struct sigaction saved_sighup; -struct sigaction saved_sigchld; +static struct sigaction saved_sigint; +static struct sigaction saved_sigtstp; +static struct sigaction saved_sigquit; +static struct sigaction saved_sighup; +static struct sigaction saved_sigchld; static volatile sig_atomic_t alarm_rised; static volatile sig_atomic_t sigchild; diff --git a/login-utils/vipw.c b/login-utils/vipw.c index d12ea73164..4d85924346 100644 --- a/login-utils/vipw.c +++ b/login-utils/vipw.c @@ -81,9 +81,9 @@ enum { VIPW, VIGR }; -int program; -char orig_file[FILENAMELEN]; /* original file /etc/passwd or /etc/group */ -char *tmp_file; /* tmp file */ +static int program; +static char orig_file[FILENAMELEN]; /* original file /etc/passwd or /etc/group */ +static char *tmp_file; /* tmp file */ void pw_error (char *, int, int); diff --git a/misc-utils/blkid.c b/misc-utils/blkid.c index ca07e9ee7f..9278553c70 100644 --- a/misc-utils/blkid.c +++ b/misc-utils/blkid.c @@ -46,7 +46,7 @@ #include "ttyutils.h" #include "xalloc.h" -int raw_chars; +static int raw_chars; static void print_version(FILE *out) { diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c index b15a52b9d8..d83dca92c3 100644 --- a/misc-utils/findmnt.c +++ b/misc-utils/findmnt.c @@ -154,7 +154,7 @@ struct libmnt_cache *cache; #ifdef HAVE_LIBUDEV -struct udev *udev; +static struct udev *udev; #endif static int match_func(struct libmnt_fs *fs, void *data __attribute__ ((__unused__))); diff --git a/misc-utils/getopt.c b/misc-utils/getopt.c index 94cfec5ad5..af4cf386a8 100644 --- a/misc-utils/getopt.c +++ b/misc-utils/getopt.c @@ -97,8 +97,8 @@ struct getopt_control { enum { REALLOC_INCREMENT = 8 }; /* Allow changing which getopt is in use with function pointer. */ -int (*getopt_long_fp) (int argc, char *const *argv, const char *optstr, - const struct option * longopts, int *longindex); +static int (*getopt_long_fp) (int argc, char *const *argv, const char *optstr, + const struct option * longopts, int *longindex); /* * This function 'normalizes' a single argument: it puts single quotes diff --git a/misc-utils/kill.c b/misc-utils/kill.c index e52a03d4ba..9046d76d1e 100644 --- a/misc-utils/kill.c +++ b/misc-utils/kill.c @@ -82,7 +82,7 @@ struct kill_control { verbose:1; }; -struct signv { +static const struct signv { const char *name; int val; } sys_signame[] = { diff --git a/misc-utils/look.c b/misc-utils/look.c index ae0d576ddc..3f785a727f 100644 --- a/misc-utils/look.c +++ b/misc-utils/look.c @@ -66,12 +66,12 @@ #define GREATER 1 #define LESS (-1) -int dflag, fflag; +static int dflag, fflag; /* uglified the source a bit with globals, so that we only need to allocate comparbuf once */ -int stringlen; -char *string; -char *comparbuf; +static int stringlen; +static char *string; +static char *comparbuf; static char *binary_search (char *, char *); static int compare (char *, char *); @@ -164,7 +164,7 @@ main(int argc, char *argv[]) return look(front, back); } -int +static int look(char *front, char *back) { int ch; @@ -232,7 +232,7 @@ look(char *front, char *back) #define SKIP_PAST_NEWLINE(p, back) \ while (p < back && *p++ != '\n') -char * +static char * binary_search(char *front, char *back) { char *p; @@ -266,7 +266,7 @@ binary_search(char *front, char *back) * o front points at the first character in a line. * o front is before or at the first line to be printed. */ -char * +static char * linear_search(char *front, char *back) { while (front < back) { @@ -286,7 +286,7 @@ linear_search(char *front, char *back) /* * Print as many lines as match string, starting at front. */ -void +static void print_from(char *front, char *back) { int eol; @@ -321,7 +321,7 @@ print_from(char *front, char *back) * We use strcasecmp etc, since it knows how to ignore case also * in other locales. */ -int +static int compare(char *s2, char *s2end) { int i; char *p; diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index 5f8a02e8c1..a5efb42766 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -63,7 +63,7 @@ #include "debug.h" -UL_DEBUG_DEFINE_MASK(lsblk); +static UL_DEBUG_DEFINE_MASK(lsblk); UL_DEBUG_DEFINE_MASKNAMES(lsblk) = UL_DEBUG_EMPTY_MASKNAMES; #define LSBLK_DEBUG_INIT (1 << 1) @@ -216,7 +216,7 @@ struct lsblk { unsigned int sort_hidden:1; /* sort column not between output columns */ }; -struct lsblk *lsblk; /* global handler */ +static struct lsblk *lsblk; /* global handler */ /* columns[] array specifies all currently wanted output column. The columns * are defined by infos[] array and you can specify (on command line) each @@ -247,7 +247,7 @@ static struct libmnt_table *mtab, *swaps; static struct libmnt_cache *mntcache; #ifdef HAVE_LIBUDEV -struct udev *udev; +static struct udev *udev; #endif struct blkdev_cxt { diff --git a/misc-utils/whereis.c b/misc-utils/whereis.c index 697d66626d..b5b35f5f5c 100644 --- a/misc-utils/whereis.c +++ b/misc-utils/whereis.c @@ -57,7 +57,7 @@ #include "debug.h" -UL_DEBUG_DEFINE_MASK(whereis); +static UL_DEBUG_DEFINE_MASK(whereis); UL_DEBUG_DEFINE_MASKNAMES(whereis) = UL_DEBUG_EMPTY_MASKNAMES; #define WHEREIS_DEBUG_INIT (1 << 1) diff --git a/schedutils/ionice.c b/schedutils/ionice.c index 38a6846f9b..1cbde8faaf 100644 --- a/schedutils/ionice.c +++ b/schedutils/ionice.c @@ -51,7 +51,7 @@ enum { #define IOPRIO_PRIO_DATA(mask) ((mask) & IOPRIO_PRIO_MASK) #define IOPRIO_PRIO_VALUE(class, data) (((class) << IOPRIO_CLASS_SHIFT) | data) -const char *to_prio[] = { +static const char *to_prio[] = { [IOPRIO_CLASS_NONE] = "none", [IOPRIO_CLASS_RT] = "realtime", [IOPRIO_CLASS_BE] = "best-effort", diff --git a/sys-utils/hwclock-cmos.c b/sys-utils/hwclock-cmos.c index 013fe094df..4915471bd3 100644 --- a/sys-utils/hwclock-cmos.c +++ b/sys-utils/hwclock-cmos.c @@ -66,12 +66,12 @@ # undef __i386__ # undef __x86_64__ # warning "disable cmos access - no sys/io.h or asm/io.h" -void outb(int a __attribute__((__unused__)), - int b __attribute__((__unused__))) +static void outb(int a __attribute__((__unused__)), + int b __attribute__((__unused__))) { } -int inb(int c __attribute__((__unused__))) +static int inb(int c __attribute__((__unused__))) { return 0; } @@ -117,7 +117,7 @@ static int inb(int c __attribute__((__unused__))) * like SRM.) It is reported that ALPHA_PRE_V1_2_SRM_CONSOLE uses 1958. */ #define TM_EPOCH 1900 -int cmos_epoch = 1900; +static int cmos_epoch = 1900; /* * Martin Ostermann writes: @@ -133,18 +133,18 @@ int cmos_epoch = 1900; * Jensen when USE_DEV_PORT was defined, but not with the normal inb/outb * functions. */ -int use_dev_port = 0; /* 1 for Jensen */ -int dev_port_fd; -unsigned short clock_ctl_addr = 0x70; /* 0x170 for Jensen */ -unsigned short clock_data_addr = 0x71; /* 0x171 for Jensen */ +static int use_dev_port = 0; /* 1 for Jensen */ +static int dev_port_fd; +static unsigned short clock_ctl_addr = 0x70; /* 0x170 for Jensen */ +static unsigned short clock_data_addr = 0x71; /* 0x171 for Jensen */ -int century_byte = 0; /* 0: don't access a century byte - * 50 (0x32): usual PC value - * 55 (0x37): PS/2 - */ +static int century_byte = 0; /* 0: don't access a century byte + * 50 (0x32): usual PC value + * 55 (0x37): PS/2 + */ #ifdef __alpha__ -int funkyTOY = 0; /* 1 for PC164/LX164/SX164 type alpha */ +static int funkyTOY = 0; /* 1 for PC164/LX164/SX164 type alpha */ #endif #ifdef __alpha diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c index 9fae9df235..21d1304e11 100644 --- a/sys-utils/hwclock.c +++ b/sys-utils/hwclock.c @@ -90,7 +90,7 @@ static int hwaudit_fd = -1; #endif /* The struct that holds our hardware access routines */ -struct clock_ops *ur; +static struct clock_ops *ur; /* Maximal clock adjustment in seconds per day. (adjtime() glibc call has 2145 seconds limit on i386, so it is good enough for us as well, diff --git a/sys-utils/ipcs.c b/sys-utils/ipcs.c index 6fab5b8108..4f3d23d907 100644 --- a/sys-utils/ipcs.c +++ b/sys-utils/ipcs.c @@ -596,7 +596,7 @@ static void print_shm(int shmid, int unit) ipc_shm_free_info(shmdata); } -void print_msg(int msgid, int unit) +static void print_msg(int msgid, int unit) { struct msg_data *msgdata; diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index 92ffba44ae..683fd66f70 100644 --- a/sys-utils/lscpu.c +++ b/sys-utils/lscpu.c @@ -104,14 +104,14 @@ enum { VIRT_FULL, VIRT_CONT }; -const char *virt_types[] = { +static const char *virt_types[] = { [VIRT_NONE] = N_("none"), [VIRT_PARA] = N_("para"), [VIRT_FULL] = N_("full"), [VIRT_CONT] = N_("container"), }; -const char *hv_vendors[] = { +static const char *hv_vendors[] = { [HYPER_NONE] = NULL, [HYPER_XEN] = "Xen", [HYPER_KVM] = "KVM", @@ -130,7 +130,7 @@ const char *hv_vendors[] = { [HYPER_WSL] = "Windows Subsystem for Linux" }; -const int hv_vendor_pci[] = { +static const int hv_vendor_pci[] = { [HYPER_NONE] = 0x0000, [HYPER_XEN] = 0x5853, [HYPER_KVM] = 0x0000, @@ -139,7 +139,7 @@ const int hv_vendor_pci[] = { [HYPER_VBOX] = 0x80ee, }; -const int hv_graphics_pci[] = { +static const int hv_graphics_pci[] = { [HYPER_NONE] = 0x0000, [HYPER_XEN] = 0x0001, [HYPER_KVM] = 0x0000, @@ -169,7 +169,7 @@ enum { DISP_VERTICAL = 1 }; -const char *disp_modes[] = { +static const char *disp_modes[] = { [DISP_HORIZONTAL] = N_("horizontal"), [DISP_VERTICAL] = N_("vertical") }; @@ -188,7 +188,7 @@ struct polarization_modes { char *readable; }; -struct polarization_modes polar_modes[] = { +static struct polarization_modes polar_modes[] = { [POLAR_UNKNOWN] = {"U", "-"}, [POLAR_VLOW] = {"VL", "vert-low"}, [POLAR_VMEDIUM] = {"VM", "vert-medium"}, diff --git a/sys-utils/lsns.c b/sys-utils/lsns.c index 0c4ff449d5..ecb0d89694 100644 --- a/sys-utils/lsns.c +++ b/sys-utils/lsns.c @@ -44,7 +44,7 @@ #include "debug.h" -UL_DEBUG_DEFINE_MASK(lsns); +static UL_DEBUG_DEFINE_MASK(lsns); UL_DEBUG_DEFINE_MASKNAMES(lsns) = UL_DEBUG_EMPTY_MASKNAMES; #define LSNS_DEBUG_INIT (1 << 1) @@ -55,7 +55,7 @@ UL_DEBUG_DEFINE_MASKNAMES(lsns) = UL_DEBUG_EMPTY_MASKNAMES; #define DBG(m, x) __UL_DBG(lsns, LSNS_DEBUG_, m, x) #define ON_DBG(m, x) __UL_DBG_CALL(lsns, LSNS_DEBUG_, m, x) -struct idcache *uid_cache = NULL; +static struct idcache *uid_cache = NULL; /* column IDs */ enum { diff --git a/sys-utils/prlimit.c b/sys-utils/prlimit.c index b4ad739ed0..c96d38589e 100644 --- a/sys-utils/prlimit.c +++ b/sys-utils/prlimit.c @@ -119,7 +119,7 @@ struct colinfo { }; /* columns descriptions */ -struct colinfo infos[] = { +static struct colinfo infos[] = { [COL_RES] = { "RESOURCE", 0.25, SCOLS_FL_TRUNC, N_("resource name") }, [COL_HELP] = { "DESCRIPTION", 0.1, SCOLS_FL_TRUNC, N_("resource description")}, [COL_SOFT] = { "SOFT", 0.1, SCOLS_FL_RIGHT, N_("soft limit")}, diff --git a/sys-utils/renice.c b/sys-utils/renice.c index 656a111dad..bc6e3c849b 100644 --- a/sys-utils/renice.c +++ b/sys-utils/renice.c @@ -48,7 +48,7 @@ #include "c.h" #include "closestream.h" -const char *idtype[] = { +static const char *idtype[] = { [PRIO_PROCESS] = N_("process ID"), [PRIO_PGRP] = N_("process group ID"), [PRIO_USER] = N_("user ID"), diff --git a/sys-utils/swapon.c b/sys-utils/swapon.c index d0ad6bb6f4..f6005e67d4 100644 --- a/sys-utils/swapon.c +++ b/sys-utils/swapon.c @@ -89,7 +89,7 @@ enum { COL_UUID, COL_LABEL }; -struct colinfo infos[] = { +static struct colinfo infos[] = { [COL_PATH] = { "NAME", 0.20, 0, N_("device file or partition path") }, [COL_TYPE] = { "TYPE", 0.20, SCOLS_FL_TRUNC, N_("type of the device")}, [COL_SIZE] = { "SIZE", 0.20, SCOLS_FL_RIGHT, N_("size of the swap area")}, diff --git a/term-utils/script.c b/term-utils/script.c index 6e12ecaa98..d1ef07203f 100644 --- a/term-utils/script.c +++ b/term-utils/script.c @@ -73,7 +73,7 @@ #include "debug.h" -UL_DEBUG_DEFINE_MASK(script); +static UL_DEBUG_DEFINE_MASK(script); UL_DEBUG_DEFINE_MASKNAMES(script) = UL_DEBUG_EMPTY_MASKNAMES; #define SCRIPT_DEBUG_INIT (1 << 1) diff --git a/text-utils/col.c b/text-utils/col.c index b35306e48f..b236b891f7 100644 --- a/text-utils/col.c +++ b/text-utils/col.c @@ -111,14 +111,14 @@ void flush_lines(int); void flush_blanks(void); LINE *alloc_line(void); -CSET last_set; /* char_set of last char printed */ -LINE *lines; -int compress_spaces; /* if doing space -> tab conversion */ -int fine; /* if `fine' resolution (half lines) */ -unsigned max_bufd_lines; /* max # lines to keep in memory */ -int nblank_lines; /* # blanks after last flushed line */ -int no_backspaces; /* if not to output any backspaces */ -int pass_unknown_seqs; /* whether to pass unknown control sequences */ +static CSET last_set; /* char_set of last char printed */ +static LINE *lines; +static int compress_spaces; /* if doing space -> tab conversion */ +static int fine; /* if `fine' resolution (half lines) */ +static unsigned max_bufd_lines; /* max # lines to keep in memory */ +static int nblank_lines; /* # blanks after last flushed line */ +static int no_backspaces; /* if not to output any backspaces */ +static int pass_unknown_seqs; /* whether to pass unknown control sequences */ #define PUTC(ch) \ if (putwchar(ch) == WEOF) \ diff --git a/text-utils/column.c b/text-utils/column.c index deeea855e7..3d50f2e27f 100644 --- a/text-utils/column.c +++ b/text-utils/column.c @@ -308,8 +308,8 @@ static void print(wchar_t **list, int entries) } } -wchar_t *local_wcstok(wchar_t * p, const wchar_t * separator, int greedy, - wchar_t ** wcstok_state) +static wchar_t *local_wcstok(wchar_t *p, const wchar_t *separator, int greedy, + wchar_t **wcstok_state) { wchar_t *result; if (greedy) diff --git a/text-utils/more.c b/text-utils/more.c index ea881e8ed0..d4aba11e46 100644 --- a/text-utils/more.c +++ b/text-utils/more.c @@ -136,56 +136,56 @@ void prepare_line_buffer(void); #define COMMAND_BUF 200 #define REGERR_BUF NUM_COLUMNS -struct termios otty, savetty0; -long file_pos, file_size; -int fnum, no_intty, no_tty, slow_tty; -int dum_opt, dlines; -void onquit(int), onsusp(int), chgwinsz(int), end_it(int); -int nscroll = SCROLL_LEN; /* Number of lines scrolled by 'd' */ -int fold_opt = 1; /* Fold long lines */ -int stop_opt = 1; /* Stop after form feeds */ -int ssp_opt = 0; /* Suppress white space */ -int ul_opt = 1; /* Underline as best we can */ -int promptlen; -int Currline; /* Line we are currently at */ -int startup = 1; -int firstf = 1; -int notell = 1; -int docrterase = 0; -int docrtkill = 0; -int bad_so; /* True if overwriting does not turn - off standout */ -int inwait, Pause, errors; -int within; /* true if we are within a file, - false if we are between files */ -int hard, dumb, noscroll, hardtabs, clreol, eatnl; -int catch_susp; /* We should catch the SIGTSTP signal */ -char **fnames; /* The list of file names */ -int nfiles; /* Number of files left to process */ -char *shell; /* The name of the shell to use */ -int shellp; /* A previous shell command exists */ -sigjmp_buf restore; -char *Line; /* Line buffer */ -size_t LineLen; /* size of Line buffer */ -int Lpp = LINES_PER_PAGE; /* lines per page */ -char *Clear; /* clear screen */ -char *eraseln; /* erase line */ -char *Senter, *Sexit; /* enter and exit standout mode */ -char *ULenter, *ULexit; /* enter and exit underline mode */ -char *chUL; /* underline character */ -char *chBS; /* backspace character */ -char *Home; /* go to home */ -char *cursorm; /* cursor movement */ -char cursorhome[40]; /* contains cursor movement to home */ -char *EodClr; /* clear rest of screen */ -int Mcol = NUM_COLUMNS; /* number of columns */ -int Wrap = 1; /* set if automargins */ -int soglitch; /* terminal has standout mode glitch */ -int ulglitch; /* terminal has underline mode glitch */ -int pstate = 0; /* current UL state */ +static struct termios otty, savetty0; +static long file_pos, file_size; +static int fnum, no_intty, no_tty, slow_tty; +static int dum_opt, dlines; +static void onquit(int), onsusp(int), chgwinsz(int), end_it(int); +static int nscroll = SCROLL_LEN; /* Number of lines scrolled by 'd' */ +static int fold_opt = 1; /* Fold long lines */ +static int stop_opt = 1; /* Stop after form feeds */ +static int ssp_opt = 0; /* Suppress white space */ +static int ul_opt = 1; /* Underline as best we can */ +static int promptlen; +static int Currline; /* Line we are currently at */ +static int startup = 1; +static int firstf = 1; +static int notell = 1; +static int docrterase = 0; +static int docrtkill = 0; +static int bad_so; /* True if overwriting does not turn + off standout */ +static int inwait, Pause, errors; +static int within; /* true if we are within a file, + false if we are between files */ +static int hard, dumb, noscroll, hardtabs, clreol, eatnl; +static int catch_susp; /* We should catch the SIGTSTP signal */ +static char **fnames; /* The list of file names */ +static int nfiles; /* Number of files left to process */ +static char *shell; /* The name of the shell to use */ +static int shellp; /* A previous shell command exists */ +static sigjmp_buf restore; +static char *Line; /* Line buffer */ +static size_t LineLen; /* size of Line buffer */ +static int Lpp = LINES_PER_PAGE; /* lines per page */ +static char *Clear; /* clear screen */ +static char *eraseln; /* erase line */ +static char *Senter, *Sexit; /* enter and exit standout mode */ +static char *ULenter, *ULexit; /* enter and exit underline mode */ +static char *chUL; /* underline character */ +static char *chBS; /* backspace character */ +static char *Home; /* go to home */ +static char *cursorm; /* cursor movement */ +static char cursorhome[40]; /* contains cursor movement to home */ +static char *EodClr; /* clear rest of screen */ +static int Mcol = NUM_COLUMNS; /* number of columns */ +static int Wrap = 1; /* set if automargins */ +static int soglitch; /* terminal has standout mode glitch */ +static int ulglitch; /* terminal has underline mode glitch */ +static int pstate = 0; /* current UL state */ static int magic(FILE *, char *); -char *previousre; /* previous search() buf[] item */ -struct { +static char *previousre; /* previous search() buf[] item */ +static struct { long chrctr, line; } context, screen_start; extern char PC; /* pad character */ @@ -631,7 +631,7 @@ void screen(register FILE *f, register int num_lines) } /* Come here if a quit signal is received */ -void onquit(int dummy __attribute__((__unused__))) +static void onquit(int dummy __attribute__((__unused__))) { signal(SIGQUIT, SIG_IGN); if (!inwait) { @@ -650,7 +650,7 @@ void onquit(int dummy __attribute__((__unused__))) /* Come here if a signal for a window size change is received */ #ifdef SIGWINCH -void chgwinsz(int dummy __attribute__((__unused__))) +static void chgwinsz(int dummy __attribute__((__unused__))) { struct winsize win; @@ -671,7 +671,7 @@ void chgwinsz(int dummy __attribute__((__unused__))) #endif /* SIGWINCH */ /* Clean up terminal state and exit. Also come here if interrupt signal received */ -void __attribute__((__noreturn__)) end_it(int dummy __attribute__((__unused__))) +static void __attribute__((__noreturn__)) end_it(int dummy __attribute__((__unused__))) { /* May be executed as a signal handler as well as by main process. * @@ -1096,7 +1096,7 @@ void home(void) static int lastcmd, lastarg, lastp; static int lastcolon; -char shell_line[SHELL_LINE]; +static char shell_line[SHELL_LINE]; /* Read a command and do it. A command consists of an optional integer * argument followed by the command character. Return the number of diff --git a/text-utils/pg.c b/text-utils/pg.c index ed62adcfde..b05ec3d70e 100644 --- a/text-utils/pg.c +++ b/text-utils/pg.c @@ -96,7 +96,7 @@ enum { }; /* Current command */ -struct { +static struct { char cmdline[CMDBUF]; size_t cmdlen; int count; @@ -106,42 +106,42 @@ struct { } cmd; /* Position of file arguments on argv[] to main() */ -struct { +static struct { int first; int current; int last; } files; -void (*oldint) (int); /* old SIGINT handler */ -void (*oldquit) (int); /* old SIGQUIT handler */ -void (*oldterm) (int); /* old SIGTERM handler */ -char *tty; /* result of ttyname(1) */ -unsigned ontty; /* whether running on tty device */ -unsigned exitstatus; /* exit status */ -int pagelen = 23; /* lines on a single screen page */ -int ttycols = 79; /* screen columns (starting at 0) */ -struct termios otio; /* old termios settings */ -int tinfostat = -1; /* terminfo routines initialized */ -int searchdisplay = TOP; /* matching line position */ -regex_t re; /* regular expression to search for */ -int remembered; /* have a remembered search string */ -int cflag; /* clear screen before each page */ -int eflag; /* suppress (EOF) */ -int fflag; /* do not split lines */ -int nflag; /* no newline for commands required */ -int rflag; /* "restricted" pg */ -int sflag; /* use standout mode */ -const char *pstring = ":"; /* prompt string */ -char *searchfor; /* search pattern from argv[] */ -int havepagelen; /* page length is manually defined */ -long startline; /* start line from argv[] */ -int nextfile = 1; /* files to advance */ -jmp_buf jmpenv; /* jump from signal handlers */ -int canjump; /* jmpenv is valid */ -wchar_t wbuf[READBUF]; /* used in several widechar routines */ - -char *copyright; -const char *helpscreen = N_("\ +static void (*oldint) (int); /* old SIGINT handler */ +static void (*oldquit) (int); /* old SIGQUIT handler */ +static void (*oldterm) (int); /* old SIGTERM handler */ +static char *tty; /* result of ttyname(1) */ +static unsigned ontty; /* whether running on tty device */ +static unsigned exitstatus; /* exit status */ +static int pagelen = 23; /* lines on a single screen page */ +static int ttycols = 79; /* screen columns (starting at 0) */ +static struct termios otio; /* old termios settings */ +static int tinfostat = -1; /* terminfo routines initialized */ +static int searchdisplay = TOP; /* matching line position */ +static regex_t re; /* regular expression to search for */ +static int remembered; /* have a remembered search string */ +static int cflag; /* clear screen before each page */ +static int eflag; /* suppress (EOF) */ +static int fflag; /* do not split lines */ +static int nflag; /* no newline for commands required */ +static int rflag; /* "restricted" pg */ +static int sflag; /* use standout mode */ +static const char *pstring = ":"; /* prompt string */ +static char *searchfor; /* search pattern from argv[] */ +static int havepagelen; /* page length is manually defined */ +static long startline; /* start line from argv[] */ +static int nextfile = 1; /* files to advance */ +static jmp_buf jmpenv; /* jump from signal handlers */ +static int canjump; /* jmpenv is valid */ +static wchar_t wbuf[READBUF]; /* used in several widechar routines */ + +static char *copyright; +static const char *helpscreen = N_("\ -------------------------------------------------------\n\ h this screen\n\ q or Q quit program\n\ diff --git a/text-utils/rev.c b/text-utils/rev.c index b4ae892f16..feed2b167c 100644 --- a/text-utils/rev.c +++ b/text-utils/rev.c @@ -64,7 +64,7 @@ #include "c.h" #include "closestream.h" -wchar_t *buf; +static wchar_t *buf; static void sig_handler(int signo __attribute__ ((__unused__))) { diff --git a/text-utils/ul.c b/text-utils/ul.c index de6da81780..178d5cb7fb 100644 --- a/text-utils/ul.c +++ b/text-utils/ul.c @@ -70,7 +70,6 @@ static int put1wc(int c) #define putwp(s) putp(s) #endif -static void usage(FILE *out); static int handle_escape(FILE * f); static void filter(FILE *f); static void flushln(void); @@ -101,33 +100,33 @@ static void print_out(char *line); #define UNDERL 010 /* Ul */ #define BOLD 020 /* Bold */ -int must_use_uc, must_overstrike; -char *CURS_UP, - *CURS_RIGHT, - *CURS_LEFT, - *ENTER_STANDOUT, - *EXIT_STANDOUT, - *ENTER_UNDERLINE, - *EXIT_UNDERLINE, - *ENTER_DIM, - *ENTER_BOLD, - *ENTER_REVERSE, - *UNDER_CHAR, - *EXIT_ATTRIBUTES; - -struct CHAR { +static int must_use_uc, must_overstrike; +static char *CURS_UP, + *CURS_RIGHT, + *CURS_LEFT, + *ENTER_STANDOUT, + *EXIT_STANDOUT, + *ENTER_UNDERLINE, + *EXIT_UNDERLINE, + *ENTER_DIM, + *ENTER_BOLD, + *ENTER_REVERSE, + *UNDER_CHAR, + *EXIT_ATTRIBUTES; + +struct CHAR { char c_mode; wchar_t c_char; int c_width; }; -struct CHAR *obuf; -int obuflen; -int col, maxcol; -int mode; -int halfpos; -int upln; -int iflag; +static struct CHAR *obuf; +static int obuflen; +static int col, maxcol; +static int mode; +static int halfpos; +static int upln; +static int iflag; static void __attribute__((__noreturn__)) usage(FILE *out) -- 2.39.5