summaryrefslogtreecommitdiff
path: root/util-linux
diff options
context:
space:
mode:
authorMark Whitley2001-01-23 22:30:04 +0000
committerMark Whitley2001-01-23 22:30:04 +0000
commit59ab025363d884deb2013dcaae6c968585a6ec72 (patch)
tree852d97bdc34c44dbcf29cc8b5cd9257a8c90f7b3 /util-linux
parent2b8d07c590249991fae975652aae86f5fca91f81 (diff)
downloadbusybox-59ab025363d884deb2013dcaae6c968585a6ec72.zip
busybox-59ab025363d884deb2013dcaae6c968585a6ec72.tar.gz
#define -> static const int. Also got rid of some big static buffers.
Diffstat (limited to 'util-linux')
-rw-r--r--util-linux/fbset.c94
-rw-r--r--util-linux/fsck_minix.c38
-rw-r--r--util-linux/getopt.c6
-rw-r--r--util-linux/mkswap.c2
-rw-r--r--util-linux/mount.c30
-rw-r--r--util-linux/nfsmount.c61
-rw-r--r--util-linux/rdate.c2
-rw-r--r--util-linux/swaponoff.c4
-rw-r--r--util-linux/umount.c8
9 files changed, 121 insertions, 124 deletions
diff --git a/util-linux/fbset.c b/util-linux/fbset.c
index 40a907b..845be84 100644
--- a/util-linux/fbset.c
+++ b/util-linux/fbset.c
@@ -36,53 +36,55 @@
#define DEFAULTFBDEV "/dev/fb0"
#define DEFAULTFBMODE "/etc/fb.modes"
-#define OPT_CHANGE 1
-#define OPT_INFO (1 << 1)
-#define OPT_READMODE (1 << 2)
-
-#define CMD_HELP 0
-#define CMD_FB 1
-#define CMD_DB 2
-#define CMD_GEOMETRY 3
-#define CMD_TIMING 4
-#define CMD_ACCEL 5
-#define CMD_HSYNC 6
-#define CMD_VSYNC 7
-#define CMD_LACED 8
-#define CMD_DOUBLE 9
-/* #define CMD_XCOMPAT 10 */
-#define CMD_ALL 11
-#define CMD_INFO 12
-#define CMD_CHANGE 13
+static const int OPT_CHANGE = (1 << 0);
+static const int OPT_INFO = (1 << 1);
+static const int OPT_READMODE = (1 << 2);
+
+enum {
+ CMD_HELP = 0,
+ CMD_FB = 1,
+ CMD_DB = 2,
+ CMD_GEOMETRY = 3,
+ CMD_TIMING = 4,
+ CMD_ACCEL = 5,
+ CMD_HSYNC = 6,
+ CMD_VSYNC = 7,
+ CMD_LACED = 8,
+ CMD_DOUBLE = 9,
+/* CMD_XCOMPAT = 10, */
+ CMD_ALL = 11,
+ CMD_INFO = 12,
+ CMD_CHANGE = 13,
#ifdef BB_FEATURE_FBSET_FANCY
-#define CMD_XRES 100
-#define CMD_YRES 101
-#define CMD_VXRES 102
-#define CMD_VYRES 103
-#define CMD_DEPTH 104
-#define CMD_MATCH 105
-#define CMD_PIXCLOCK 106
-#define CMD_LEFT 107
-#define CMD_RIGHT 108
-#define CMD_UPPER 109
-#define CMD_LOWER 110
-#define CMD_HSLEN 111
-#define CMD_VSLEN 112
-#define CMD_CSYNC 113
-#define CMD_GSYNC 114
-#define CMD_EXTSYNC 115
-#define CMD_BCAST 116
-#define CMD_RGBA 117
-#define CMD_STEP 118
-#define CMD_MOVE 119
+ CMD_XRES = 100,
+ CMD_YRES = 101,
+ CMD_VXRES = 102,
+ CMD_VYRES = 103,
+ CMD_DEPTH = 104,
+ CMD_MATCH = 105,
+ CMD_PIXCLOCK = 106,
+ CMD_LEFT = 107,
+ CMD_RIGHT = 108,
+ CMD_UPPER = 109,
+ CMD_LOWER = 110,
+ CMD_HSLEN = 111,
+ CMD_VSLEN = 112,
+ CMD_CSYNC = 113,
+ CMD_GSYNC = 114,
+ CMD_EXTSYNC = 115,
+ CMD_BCAST = 116,
+ CMD_RGBA = 117,
+ CMD_STEP = 118,
+ CMD_MOVE = 119,
#endif
+};
static unsigned int g_options = 0;
/* Stuff stolen from the kernel's fb.h */
-#define FBIOGET_VSCREENINFO 0x4600
-#define FBIOPUT_VSCREENINFO 0x4601
+static const int FBIOGET_VSCREENINFO = 0x4600;
+static const int FBIOPUT_VSCREENINFO = 0x4601;
#define __u32 unsigned int
struct fb_bitfield {
__u32 offset; /* beginning of bitfield */
@@ -180,12 +182,12 @@ struct cmdoptions_t {
#ifdef BB_FEATURE_FBSET_READMODE
/* taken from linux/fb.h */
-#define FB_VMODE_INTERLACED 1 /* interlaced */
-#define FB_VMODE_DOUBLE 2 /* double scan */
-#define FB_SYNC_HOR_HIGH_ACT 1 /* horizontal sync high active */
-#define FB_SYNC_VERT_HIGH_ACT 2 /* vertical sync high active */
-#define FB_SYNC_EXT 4 /* external sync */
-#define FB_SYNC_COMP_HIGH_ACT 8 /* composite sync high active */
+static const int FB_VMODE_INTERLACED = 1; /* interlaced */
+static const int FB_VMODE_DOUBLE = 2; /* double scan */
+static const int FB_SYNC_HOR_HIGH_ACT = 1; /* horizontal sync high active */
+static const int FB_SYNC_VERT_HIGH_ACT = 2; /* vertical sync high active */
+static const int FB_SYNC_EXT = 4; /* external sync */
+static const int FB_SYNC_COMP_HIGH_ACT = 8; /* composite sync high active */
#endif
static int readmode(struct fb_var_screeninfo *base, const char *fn,
const char *mode)
diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c
index b35e6bb..18841ec 100644
--- a/util-linux/fsck_minix.c
+++ b/util-linux/fsck_minix.c
@@ -104,24 +104,24 @@ typedef unsigned short u16;
typedef unsigned int u32;
-#define MINIX_ROOT_INO 1
-#define MINIX_LINK_MAX 250
-#define MINIX2_LINK_MAX 65530
-
-#define MINIX_I_MAP_SLOTS 8
-#define MINIX_Z_MAP_SLOTS 64
-#define MINIX_SUPER_MAGIC 0x137F /* original minix fs */
-#define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */
-#define MINIX2_SUPER_MAGIC 0x2468 /* minix V2 fs */
-#define MINIX2_SUPER_MAGIC2 0x2478 /* minix V2 fs, 30 char names */
-#define MINIX_VALID_FS 0x0001 /* Clean fs. */
-#define MINIX_ERROR_FS 0x0002 /* fs has errors. */
+static const int MINIX_ROOT_INO = 1;
+static const int MINIX_LINK_MAX = 250;
+static const int MINIX2_LINK_MAX = 65530;
+
+static const int MINIX_I_MAP_SLOTS = 8;
+static const int MINIX_Z_MAP_SLOTS = 64;
+static const int MINIX_SUPER_MAGIC = 0x137F; /* original minix fs */
+static const int MINIX_SUPER_MAGIC2 = 0x138F; /* minix fs, 30 char names */
+static const int MINIX2_SUPER_MAGIC = 0x2468; /* minix V2 fs */
+static const int MINIX2_SUPER_MAGIC2 = 0x2478; /* minix V2 fs, 30 char names */
+static const int MINIX_VALID_FS = 0x0001; /* Clean fs. */
+static const int MINIX_ERROR_FS = 0x0002; /* fs has errors. */
#define MINIX_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix_inode)))
#define MINIX2_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix2_inode)))
-#define MINIX_V1 0x0001 /* original minix fs */
-#define MINIX_V2 0x0002 /* minix V2 fs */
+static const int MINIX_V1 = 0x0001; /* original minix fs */
+static const int MINIX_V2 = 0x0002; /* minix V2 fs */
#define INODE_VERSION(inode) inode->i_sb->u.minix_sb.s_version
@@ -185,12 +185,6 @@ struct minix_dir_entry {
#define MINIX_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix_inode)))
-#define MINIX_VALID_FS 0x0001 /* Clean fs. */
-#define MINIX_ERROR_FS 0x0002 /* fs has errors. */
-
-#define MINIX_SUPER_MAGIC 0x137F /* original minix fs */
-#define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */
-
#ifndef BLKGETSIZE
#define BLKGETSIZE _IO(0x12,96) /* return device size */
#endif
@@ -199,7 +193,7 @@ struct minix_dir_entry {
#define volatile
#endif
-#define ROOT_INO 1
+static const int ROOT_INO = 1;
#define UPPER(size,n) ((size+((n)-1))/(n))
#define INODE_SIZE (sizeof(struct minix_inode))
@@ -231,7 +225,7 @@ static struct termios termios;
static int termios_set = 0;
/* File-name data */
-#define MAX_DEPTH 32
+static const int MAX_DEPTH = 32;
static int name_depth = 0;
// static char name_list[MAX_DEPTH][BUFSIZ + 1];
static char **name_list = NULL;
diff --git a/util-linux/getopt.c b/util-linux/getopt.c
index 0ebf9df..ff55a3e 100644
--- a/util-linux/getopt.c
+++ b/util-linux/getopt.c
@@ -53,9 +53,9 @@
/* NON_OPT is the code that is returned when a non-option is found in '+'
mode */
-#define NON_OPT 1
+static const int NON_OPT = 1;
/* LONG_OPT is the code that is returned when a long option is found. */
-#define LONG_OPT 2
+static const int LONG_OPT = 2;
/* The shells recognized. */
typedef enum {BASH,TCSH} shell_t;
@@ -199,7 +199,7 @@ int generate_output(char * argv[],int argc,const char *optstr,
static struct option *long_options=NULL;
static int long_options_length=0; /* Length of array */
static int long_options_nr=0; /* Nr of used elements in array */
-#define LONG_OPTIONS_INCR 10
+static const int LONG_OPTIONS_INCR = 10;
#define init_longopt() add_longopt(NULL,0)
/* Register a long option. The contents of name is copied. */
diff --git a/util-linux/mkswap.c b/util-linux/mkswap.c
index e7fab4e..5b908da 100644
--- a/util-linux/mkswap.c
+++ b/util-linux/mkswap.c
@@ -48,7 +48,7 @@
#ifndef _IO
/* pre-1.3.45 */
-#define BLKGETSIZE 0x1260
+static const int BLKGETSIZE = 0x1260;
#else
/* same on i386, m68k, arm; different on alpha, mips, sparc, ppc */
#define BLKGETSIZE _IO(0x12,96)
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 88e45fc..f78786e 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -55,21 +55,21 @@
#include <linux/devmtab.h> /* For Erik's nifty devmtab device driver */
#endif
-
-#define MS_MGC_VAL 0xc0ed0000 /* Magic number indicatng "new" flags */
-#define MS_RDONLY 1 /* Mount read-only */
-#define MS_NOSUID 2 /* Ignore suid and sgid bits */
-#define MS_NODEV 4 /* Disallow access to device special files */
-#define MS_NOEXEC 8 /* Disallow program execution */
-#define MS_SYNCHRONOUS 16 /* Writes are synced at once */
-#define MS_REMOUNT 32 /* Alter flags of a mounted FS */
-#define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
-#define S_QUOTA 128 /* Quota initialized for file/directory/symlink */
-#define S_APPEND 256 /* Append-only file */
-#define S_IMMUTABLE 512 /* Immutable file */
-#define MS_NOATIME 1024 /* Do not update access times. */
-#define MS_NODIRATIME 2048 /* Do not update directory access times */
-
+enum {
+ MS_MGC_VAL = 0xc0ed0000, /* Magic number indicatng "new" flags */
+ MS_RDONLY = 1, /* Mount read-only */
+ MS_NOSUID = 2, /* Ignore suid and sgid bits */
+ MS_NODEV = 4, /* Disallow access to device special files */
+ MS_NOEXEC = 8, /* Disallow program execution */
+ MS_SYNCHRONOUS = 16, /* Writes are synced at once */
+ MS_REMOUNT = 32, /* Alter flags of a mounted FS */
+ MS_MANDLOCK = 64, /* Allow mandatory locks on an FS */
+ S_QUOTA = 128, /* Quota initialized for file/directory/symlink */
+ S_APPEND = 256, /* Append-only file */
+ S_IMMUTABLE = 512, /* Immutable file */
+ MS_NOATIME = 1024, /* Do not update access times. */
+ MS_NODIRATIME = 2048, /* Do not update directory access times */
+};
#if defined BB_FEATURE_MOUNT_LOOP
diff --git a/util-linux/nfsmount.c b/util-linux/nfsmount.c
index b5c3821..d661a99 100644
--- a/util-linux/nfsmount.c
+++ b/util-linux/nfsmount.c
@@ -54,10 +54,10 @@
#include <linux/nfs.h> /* For the kernels nfs stuff */
#ifndef NFS_FHSIZE
-#define NFS_FHSIZE 32
+static const int NFS_FHSIZE = 32;
#endif
#ifndef NFS_PORT
-#define NFS_PORT 2049
+static const int NFS_PORT = 2049;
#endif
/* Disable the nls stuff */
@@ -68,19 +68,19 @@
# define _(Text) (Text)
# define N_(Text) (Text)
-#define MS_MGC_VAL 0xc0ed0000 /* Magic number indicatng "new" flags */
-#define MS_RDONLY 1 /* Mount read-only */
-#define MS_NOSUID 2 /* Ignore suid and sgid bits */
-#define MS_NODEV 4 /* Disallow access to device special files */
-#define MS_NOEXEC 8 /* Disallow program execution */
-#define MS_SYNCHRONOUS 16 /* Writes are synced at once */
-#define MS_REMOUNT 32 /* Alter flags of a mounted FS */
-#define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
-#define S_QUOTA 128 /* Quota initialized for file/directory/symlink */
-#define S_APPEND 256 /* Append-only file */
-#define S_IMMUTABLE 512 /* Immutable file */
-#define MS_NOATIME 1024 /* Do not update access times. */
-#define MS_NODIRATIME 2048 /* Do not update directory access times */
+static const int MS_MGC_VAL = 0xc0ed0000; /* Magic number indicatng "new" flags */
+static const int MS_RDONLY = 1; /* Mount read-only */
+static const int MS_NOSUID = 2; /* Ignore suid and sgid bits */
+static const int MS_NODEV = 4; /* Disallow access to device special files */
+static const int MS_NOEXEC = 8; /* Disallow program execution */
+static const int MS_SYNCHRONOUS = 16; /* Writes are synced at once */
+static const int MS_REMOUNT = 32; /* Alter flags of a mounted FS */
+static const int MS_MANDLOCK = 64; /* Allow mandatory locks on an FS */
+static const int S_QUOTA = 128; /* Quota initialized for file/directory/symlink */
+static const int S_APPEND = 256; /* Append-only file */
+static const int S_IMMUTABLE = 512; /* Immutable file */
+static const int MS_NOATIME = 1024; /* Do not update access times. */
+static const int MS_NODIRATIME = 2048; /* Do not update directory access times */
/*
@@ -93,7 +93,7 @@
* so it is easiest to ignore the kernel altogether (at compile time).
*/
-#define NFS_MOUNT_VERSION 4
+static const int NFS_MOUNT_VERSION = 4;
struct nfs2_fh {
char data[32];
@@ -125,16 +125,16 @@ struct nfs_mount_data {
/* bits in the flags field */
-#define NFS_MOUNT_SOFT 0x0001 /* 1 */
-#define NFS_MOUNT_INTR 0x0002 /* 1 */
-#define NFS_MOUNT_SECURE 0x0004 /* 1 */
-#define NFS_MOUNT_POSIX 0x0008 /* 1 */
-#define NFS_MOUNT_NOCTO 0x0010 /* 1 */
-#define NFS_MOUNT_NOAC 0x0020 /* 1 */
-#define NFS_MOUNT_TCP 0x0040 /* 2 */
-#define NFS_MOUNT_VER3 0x0080 /* 3 */
-#define NFS_MOUNT_KERBEROS 0x0100 /* 3 */
-#define NFS_MOUNT_NONLM 0x0200 /* 3 */
+static const int NFS_MOUNT_SOFT = 0x0001; /* 1 */
+static const int NFS_MOUNT_INTR = 0x0002; /* 1 */
+static const int NFS_MOUNT_SECURE = 0x0004; /* 1 */
+static const int NFS_MOUNT_POSIX = 0x0008; /* 1 */
+static const int NFS_MOUNT_NOCTO = 0x0010; /* 1 */
+static const int NFS_MOUNT_NOAC = 0x0020; /* 1 */
+static const int NFS_MOUNT_TCP = 0x0040; /* 2 */
+static const int NFS_MOUNT_VER3 = 0x0080; /* 3 */
+static const int NFS_MOUNT_KERBEROS = 0x0100; /* 3 */
+static const int NFS_MOUNT_NONLM = 0x0200; /* 3 */
#define UTIL_LINUX_VERSION "2.10m"
@@ -160,14 +160,14 @@ static char *nfs_strerror(int stat);
#define MAKE_VERSION(p,q,r) (65536*(p) + 256*(q) + (r))
#define MAX_NFSPROT ((nfs_mount_version >= 4) ? 3 : 2)
-#define EX_FAIL 32 /* mount failure */
-#define EX_BG 256 /* retry in background (internal only) */
+static const int EX_FAIL = 32; /* mount failure */
+static const int EX_BG = 256; /* retry in background (internal only) */
/*
* nfs_mount_version according to the sources seen at compile time.
*/
-int nfs_mount_version = NFS_MOUNT_VERSION;
+static int nfs_mount_version;
/*
* Unfortunately, the kernel prints annoying console messages
@@ -187,8 +187,9 @@ find_kernel_nfs_mount_version(void) {
if (kernel_version)
return;
- kernel_version = get_kernel_revision();
+ nfs_mount_version = NFS_MOUNT_VERSION; /* default */
+ kernel_version = get_kernel_revision();
if (kernel_version) {
if (kernel_version < MAKE_VERSION(2,1,32))
nfs_mount_version = 1;
diff --git a/util-linux/rdate.c b/util-linux/rdate.c
index bb53927..954982a 100644
--- a/util-linux/rdate.c
+++ b/util-linux/rdate.c
@@ -33,7 +33,7 @@
#include <getopt.h>
-#define RFC_868_BIAS 2208988800UL
+static const int RFC_868_BIAS = 2208988800UL;
int setdate= 0;
int printdate= 0;
diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c
index 85f3389..eda1510 100644
--- a/util-linux/swaponoff.c
+++ b/util-linux/swaponoff.c
@@ -35,8 +35,8 @@ _syscall1(int, swapoff, const char *, path);
static int whichApp;
-#define SWAPON_APP 1
-#define SWAPOFF_APP 2
+static const int SWAPON_APP = 1;
+static const int SWAPOFF_APP = 2;
static void swap_enable_disable(char *device)
diff --git a/util-linux/umount.c b/util-linux/umount.c
index 40d25f9..2e2d95d 100644
--- a/util-linux/umount.c
+++ b/util-linux/umount.c
@@ -28,10 +28,10 @@
#include <errno.h>
-#define MNT_FORCE 1
-#define MS_MGC_VAL 0xc0ed0000 /* Magic number indicatng "new" flags */
-#define MS_REMOUNT 32 /* Alter flags of a mounted FS. */
-#define MS_RDONLY 1 /* Mount read-only. */
+static const int MNT_FORCE = 1;
+static const int MS_MGC_VAL = 0xc0ed0000; /* Magic number indicatng "new" flags */
+static const int MS_REMOUNT = 32; /* Alter flags of a mounted FS. */
+static const int MS_RDONLY = 1; /* Mount read-only. */
extern int mount (__const char *__special_file, __const char *__dir,
__const char *__fstype, unsigned long int __rwflag,