aboutsummaryrefslogtreecommitdiff
path: root/util-linux
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-06-25 10:55:35 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-06-25 10:55:35 +0000
commit80b8b39899a09c7516920cda5fd343b3086d4824 (patch)
treeaa9903fd6b64d19c5f640fa302272d85c92b204e /util-linux
parent1399282b47bb218132a554cbe5b2b0ce4dcc055f (diff)
downloadbusybox-w32-80b8b39899a09c7516920cda5fd343b3086d4824.tar.gz
busybox-w32-80b8b39899a09c7516920cda5fd343b3086d4824.tar.bz2
busybox-w32-80b8b39899a09c7516920cda5fd343b3086d4824.zip
Consolidate ARRAY_SIZE macro; remove one unneeded global var (walter harms <wharms@bfs.de>)
Diffstat (limited to 'util-linux')
-rw-r--r--util-linux/fdisk.c2
-rw-r--r--util-linux/fdisk_osf.c7
-rw-r--r--util-linux/fdisk_sun.c10
-rw-r--r--util-linux/mount.c5
4 files changed, 10 insertions, 14 deletions
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c
index 4ecbadf78..870789112 100644
--- a/util-linux/fdisk.c
+++ b/util-linux/fdisk.c
@@ -20,8 +20,6 @@
20# define USE_FEATURE_FDISK_BLKSIZE(a) 20# define USE_FEATURE_FDISK_BLKSIZE(a)
21#endif 21#endif
22 22
23#define SIZE(a) (sizeof(a)/sizeof((a)[0]))
24
25#define DEFAULT_SECTOR_SIZE 512 23#define DEFAULT_SECTOR_SIZE 512
26#define MAX_SECTOR_SIZE 2048 24#define MAX_SECTOR_SIZE 2048
27#define SECTOR_SIZE 512 /* still used in osf/sgi/sun code */ 25#define SECTOR_SIZE 512 /* still used in osf/sgi/sun code */
diff --git a/util-linux/fdisk_osf.c b/util-linux/fdisk_osf.c
index afb8459a2..9f0dc7fd3 100644
--- a/util-linux/fdisk_osf.c
+++ b/util-linux/fdisk_osf.c
@@ -163,7 +163,7 @@ static const char * const xbsd_dktypenames[] = {
163 "floppy", 163 "floppy",
164 0 164 0
165}; 165};
166#define BSD_DKMAXTYPES (sizeof(xbsd_dktypenames) / sizeof(xbsd_dktypenames[0]) - 1) 166
167 167
168/* 168/*
169 * Filesystem type and version. 169 * Filesystem type and version.
@@ -219,7 +219,6 @@ static const char *const xbsd_fstypes[] = {
219 "\x10" "AdvFS", /* BSD_FS_ADVFS */ 219 "\x10" "AdvFS", /* BSD_FS_ADVFS */
220 NULL 220 NULL
221}; 221};
222#define BSD_FSMAXTYPES (SIZE(xbsd_fstypes)-1)
223 222
224 223
225/* 224/*
@@ -509,7 +508,7 @@ xbsd_print_disklabel(int show_all)
509#else 508#else
510 printf("# %s:\n", partname(disk_device, xbsd_part_index+1, 0)); 509 printf("# %s:\n", partname(disk_device, xbsd_part_index+1, 0));
511#endif 510#endif
512 if ((unsigned) lp->d_type < BSD_DKMAXTYPES) 511 if ((unsigned) lp->d_type < ARRAY_SIZE(xbsd_dktypenames)-1)
513 printf("type: %s\n", xbsd_dktypenames[lp->d_type]); 512 printf("type: %s\n", xbsd_dktypenames[lp->d_type]);
514 else 513 else
515 printf("type: %d\n", lp->d_type); 514 printf("type: %d\n", lp->d_type);
@@ -571,7 +570,7 @@ xbsd_print_disklabel(int show_all)
571 ); 570 );
572 } 571 }
573 572
574 if ((unsigned) pp->p_fstype < BSD_FSMAXTYPES) 573 if ((unsigned) pp->p_fstype < ARRAY_SIZE(xbsd_fstypes)-1)
575 printf("%8.8s", xbsd_fstypes[pp->p_fstype]); 574 printf("%8.8s", xbsd_fstypes[pp->p_fstype]);
576 else 575 else
577 printf("%8x", pp->p_fstype); 576 printf("%8x", pp->p_fstype);
diff --git a/util-linux/fdisk_sun.c b/util-linux/fdisk_sun.c
index 2fa7b2b86..d4614fd4f 100644
--- a/util-linux/fdisk_sun.c
+++ b/util-linux/fdisk_sun.c
@@ -207,7 +207,7 @@ sun_autoconfigure_scsi(void)
207 if (!q) 207 if (!q)
208 break; 208 break;
209 *q = '\0'; 209 *q = '\0';
210 for (i = 0; i < SIZE(sun_drives); i++) { 210 for (i = 0; i < ARRAY_SIZE(sun_drives); i++) {
211 if (*sun_drives[i].vendor && strcasecmp(sun_drives[i].vendor, vendor)) 211 if (*sun_drives[i].vendor && strcasecmp(sun_drives[i].vendor, vendor))
212 continue; 212 continue;
213 if (!strstr(model, sun_drives[i].model)) 213 if (!strstr(model, sun_drives[i].model))
@@ -244,7 +244,7 @@ create_sunlabel(void)
244 puts("Drive type\n" 244 puts("Drive type\n"
245 " ? auto configure\n" 245 " ? auto configure\n"
246 " 0 custom (with hardware detected defaults)"); 246 " 0 custom (with hardware detected defaults)");
247 for (i = 0; i < SIZE(sun_drives); i++) { 247 for (i = 0; i < ARRAY_SIZE(sun_drives); i++) {
248 printf(" %c %s%s%s\n", 248 printf(" %c %s%s%s\n",
249 i + 'a', sun_drives[i].vendor, 249 i + 'a', sun_drives[i].vendor,
250 (*sun_drives[i].vendor) ? " " : "", 250 (*sun_drives[i].vendor) ? " " : "",
@@ -255,11 +255,11 @@ create_sunlabel(void)
255 if (c == '0') { 255 if (c == '0') {
256 break; 256 break;
257 } 257 }
258 if (c >= 'a' && c < 'a' + SIZE(sun_drives)) { 258 if (c >= 'a' && c < 'a' + ARRAY_SIZE(sun_drives)) {
259 p = sun_drives + c - 'a'; 259 p = sun_drives + c - 'a';
260 break; 260 break;
261 } 261 }
262 if (c >= 'A' && c < 'A' + SIZE(sun_drives)) { 262 if (c >= 'A' && c < 'A' + ARRAY_SIZE(sun_drives)) {
263 p = sun_drives + c - 'A'; 263 p = sun_drives + c - 'A';
264 break; 264 break;
265 } 265 }
@@ -446,7 +446,7 @@ verify_sun(void)
446 else 446 else
447 array[i] = -1; 447 array[i] = -1;
448 } 448 }
449 qsort(array,SIZE(array),sizeof(array[0]), 449 qsort(array, ARRAY_SIZE(array), sizeof(array[0]),
450 (int (*)(const void *,const void *)) verify_sun_cmp); 450 (int (*)(const void *,const void *)) verify_sun_cmp);
451 if (array[0] == -1) { 451 if (array[0] == -1) {
452 printf("No partitions defined\n"); 452 printf("No partitions defined\n");
diff --git a/util-linux/mount.c b/util-linux/mount.c
index fe2f1d969..4dd1a85a2 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -120,7 +120,6 @@ struct {
120 {"remount", MS_REMOUNT}, // action flag 120 {"remount", MS_REMOUNT}, // action flag
121}; 121};
122 122
123#define VECTOR_SIZE(v) (sizeof(v) / sizeof((v)[0]))
124 123
125/* Append mount options to string */ 124/* Append mount options to string */
126static void append_mount_options(char **oldopts, const char *newopts) 125static void append_mount_options(char **oldopts, const char *newopts)
@@ -168,7 +167,7 @@ static int parse_mount_options(char *options, char **unrecognized)
168 if (comma) *comma = 0; 167 if (comma) *comma = 0;
169 168
170 // Find this option in mount_options 169 // Find this option in mount_options
171 for (i = 0; i < VECTOR_SIZE(mount_options); i++) { 170 for (i = 0; i < ARRAY_SIZE(mount_options); i++) {
172 if (!strcasecmp(mount_options[i].name, options)) { 171 if (!strcasecmp(mount_options[i].name, options)) {
173 long fl = mount_options[i].flags; 172 long fl = mount_options[i].flags;
174 if (fl < 0) flags &= fl; 173 if (fl < 0) flags &= fl;
@@ -177,7 +176,7 @@ static int parse_mount_options(char *options, char **unrecognized)
177 } 176 }
178 } 177 }
179 // If unrecognized not NULL, append unrecognized mount options */ 178 // If unrecognized not NULL, append unrecognized mount options */
180 if (unrecognized && i == VECTOR_SIZE(mount_options)) { 179 if (unrecognized && i == ARRAY_SIZE(mount_options)) {
181 // Add it to strflags, to pass on to kernel 180 // Add it to strflags, to pass on to kernel
182 i = *unrecognized ? strlen(*unrecognized) : 0; 181 i = *unrecognized ? strlen(*unrecognized) : 0;
183 *unrecognized = xrealloc(*unrecognized, i+strlen(options)+2); 182 *unrecognized = xrealloc(*unrecognized, i+strlen(options)+2);