convert to ANSI KNF

This commit is contained in:
lukem 2000-12-19 15:44:27 +00:00
parent df19f979d4
commit b813a81a7c
1 changed files with 77 additions and 106 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: fdisk.c,v 1.42 2000/07/06 17:22:43 thorpej Exp $ */ /* $NetBSD: fdisk.c,v 1.43 2000/12/19 15:44:27 lukem Exp $ */
/* /*
* Mach Operating System * Mach Operating System
@ -29,7 +29,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint #ifndef lint
__RCSID("$NetBSD: fdisk.c,v 1.42 2000/07/06 17:22:43 thorpej Exp $"); __RCSID("$NetBSD: fdisk.c,v 1.43 2000/12/19 15:44:27 lukem Exp $");
#endif /* not lint */ #endif /* not lint */
#include <sys/types.h> #include <sys/types.h>
@ -138,7 +138,7 @@ unsigned char bootcode[8192]; /* maximum size of bootcode */
unsigned char tempcode[8192]; unsigned char tempcode[8192];
int bootsize; /* actual size of bootcode */ int bootsize; /* actual size of bootcode */
static char reserved[] = "reserved"; static char reserved[] = "reserved";
struct part_type { struct part_type {
@ -259,49 +259,47 @@ struct part_type {
{0xFF, "Xenix Bad Block Table"}, {0xFF, "Xenix Bad Block Table"},
}; };
void usage __P((void)); void usage(void);
void print_s0 __P((int)); void print_s0(int);
void print_part __P((int)); void print_part(int);
int read_boot __P((char *, char *, size_t)); int read_boot(const char *, void *, size_t);
void init_sector0 __P((int, int)); void init_sector0(int, int);
void intuit_translated_geometry __P((void)); void intuit_translated_geometry(void);
void get_geometry __P((void)); void get_geometry(void);
void get_diskname __P((char *, char *, size_t)); void get_diskname(char *, char *, size_t);
int try_heads __P((quad_t, quad_t, quad_t, quad_t, quad_t, quad_t, quad_t, int try_heads(quad_t, quad_t, quad_t, quad_t, quad_t, quad_t, quad_t,
quad_t)); quad_t);
int try_sectors __P((quad_t, quad_t, quad_t, quad_t, quad_t)); int try_sectors(quad_t, quad_t, quad_t, quad_t, quad_t);
void change_part __P((int, int, int, int)); void change_part(int, int, int, int);
void print_params __P((void)); void print_params(void);
void change_active __P((int)); void change_active(int);
void get_params_to_use __P((void)); void get_params_to_use(void);
void dos __P((int, unsigned char *, unsigned char *, unsigned char *)); void dos(int, unsigned char *, unsigned char *, unsigned char *);
int open_disk __P((int)); int open_disk(int);
int read_disk __P((int, void *)); int read_disk(int, void *);
int write_disk __P((int, void *)); int write_disk(int, void *);
int get_params __P((void)); int get_params(void);
int read_s0 __P((void)); int read_s0(void);
int write_s0 __P((void)); int write_s0(void);
int yesno __P((char *)); int yesno(const char *);
void decimal __P((char *, int *)); void decimal(const char *, int *);
int type_match __P((const void *, const void *)); int type_match(const void *, const void *);
char *get_type __P((int)); const char *get_type(int);
int get_mapping __P((int, int *, int *, int *, long *)); int get_mapping(int, int *, int *, int *, unsigned long *);
#ifdef __i386__ #ifdef __i386__
void configure_bootsel __P((void)); void configure_bootsel(void);
#endif #endif
static inline unsigned short getshort __P((void *)); static unsigned short getshort(void *);
static inline void putshort __P((void *p, unsigned short)); static void putshort(void *p, unsigned short);
static inline unsigned long getlong __P((void *)); static unsigned long getlong(void *);
static inline void putlong __P((void *, unsigned long)); static void putlong(void *, unsigned long);
int main __P((int, char **)); int main(int, char *[]);
int int
main(argc, argv) main(int argc, char *argv[])
int argc;
char *argv[];
{ {
int ch; int ch;
int part; int part;
@ -448,8 +446,9 @@ main(argc, argv)
} }
void void
usage() usage(void)
{ {
(void)fprintf(stderr, "usage: fdisk [-aiufBS] [-0|-1|-2|-3] " (void)fprintf(stderr, "usage: fdisk [-aiufBS] [-0|-1|-2|-3] "
"[-b cylinders/heads/sectors]\n" "[-b cylinders/heads/sectors]\n"
" [-s id/start/size] [-c bootcode] " " [-s id/start/size] [-c bootcode] "
@ -458,8 +457,7 @@ usage()
} }
void void
print_s0(which) print_s0(int which)
int which;
{ {
int part; int part;
@ -476,19 +474,16 @@ print_s0(which)
print_part(which); print_part(which);
} }
static inline unsigned short static unsigned short
getshort(p) getshort(void *p)
void *p;
{ {
unsigned char *cp = p; unsigned char *cp = p;
return cp[0] | (cp[1] << 8); return cp[0] | (cp[1] << 8);
} }
static inline void static void
putshort(p, l) putshort(void *p, unsigned short l)
void *p;
unsigned short l;
{ {
unsigned char *cp = p; unsigned char *cp = p;
@ -496,19 +491,16 @@ putshort(p, l)
*cp++ = l >> 8; *cp++ = l >> 8;
} }
static inline unsigned long static unsigned long
getlong(p) getlong(void *p)
void *p;
{ {
unsigned char *cp = p; unsigned char *cp = p;
return cp[0] | (cp[1] << 8) | (cp[2] << 16) | (cp[3] << 24); return cp[0] | (cp[1] << 8) | (cp[2] << 16) | (cp[3] << 24);
} }
static inline void static void
putlong(p, l) putlong(void *p, unsigned long l)
void *p;
unsigned long l;
{ {
unsigned char *cp = p; unsigned char *cp = p;
@ -519,8 +511,7 @@ putlong(p, l)
} }
void void
print_part(part) print_part(int part)
int part;
{ {
struct mbr_partition *partp; struct mbr_partition *partp;
int empty; int empty;
@ -567,10 +558,7 @@ print_part(part)
} }
int int
read_boot(name, buf, len) read_boot(const char *name, void *buf, size_t len)
char *name;
char *buf;
size_t len;
{ {
int bfd, ret; int bfd, ret;
struct stat st; struct stat st;
@ -599,8 +587,7 @@ read_boot(name, buf, len)
} }
void void
init_sector0(start, dopart) init_sector0(int start, int dopart)
int start, dopart;
{ {
int i; int i;
@ -622,10 +609,7 @@ init_sector0(start, dopart)
#ifdef __i386__ #ifdef __i386__
void void
get_diskname(fullname, diskname, size) get_diskname(char *fullname, char *diskname, size_t size)
char *fullname;
char *diskname;
size_t size;
{ {
char *p; char *p;
char *p2; char *p2;
@ -671,7 +655,7 @@ get_diskname(fullname, diskname, size)
} }
void void
get_geometry() get_geometry(void)
{ {
int mib[2], i; int mib[2], i;
size_t len; size_t len;
@ -714,7 +698,7 @@ get_geometry()
} }
void void
configure_bootsel() configure_bootsel(void)
{ {
struct mbr_bootsel *mbs = struct mbr_bootsel *mbs =
(struct mbr_bootsel *)&mboot.bootinst[MBR_BOOTSELOFF]; (struct mbr_bootsel *)&mboot.bootinst[MBR_BOOTSELOFF];
@ -909,7 +893,7 @@ done:
* the BIOS geometry (which in turn requires modifications to the i386 * the BIOS geometry (which in turn requires modifications to the i386
* boot loader to pass in the BIOS geometry for each disk). */ * boot loader to pass in the BIOS geometry for each disk). */
void void
intuit_translated_geometry() intuit_translated_geometry(void)
{ {
int cylinders = -1, heads = -1, sectors = -1, i, j; int cylinders = -1, heads = -1, sectors = -1, i, j;
@ -982,9 +966,8 @@ intuit_translated_geometry()
* absolute sectors for a given entry, or return -1 if it isn't present. * absolute sectors for a given entry, or return -1 if it isn't present.
* Note: for simplicity, the returned sector is 0-based. */ * Note: for simplicity, the returned sector is 0-based. */
int int
get_mapping(i, cylinder, head, sector, absolute) get_mapping(int i, int *cylinder, int *head, int *sector,
int i, *cylinder, *head, *sector; unsigned long *absolute)
long *absolute;
{ {
struct mbr_partition *part = &mboot.parts[i / 2]; struct mbr_partition *part = &mboot.parts[i / 2];
@ -1006,8 +989,7 @@ get_mapping(i, cylinder, head, sector, absolute)
} }
void void
change_part(part, csysid, cstart, csize) change_part(int part, int csysid, int cstart, int csize)
int part, csysid, cstart, csize;
{ {
struct mbr_partition *partp; struct mbr_partition *partp;
@ -1103,7 +1085,7 @@ change_part(part, csysid, cstart, csize)
} }
void void
print_params() print_params(void)
{ {
if (sh_flag) { if (sh_flag) {
@ -1124,8 +1106,7 @@ print_params()
} }
void void
change_active(which) change_active(int which)
int which;
{ {
struct mbr_partition *partp; struct mbr_partition *partp;
int part; int part;
@ -1159,8 +1140,9 @@ change_active(which)
} }
void void
get_params_to_use() get_params_to_use(void)
{ {
if (b_flag) { if (b_flag) {
dos_cylinders = b_cyl; dos_cylinders = b_cyl;
dos_heads = b_head; dos_heads = b_head;
@ -1185,9 +1167,8 @@ get_params_to_use()
* Change real numbers into strange dos numbers * * Change real numbers into strange dos numbers *
\***********************************************/ \***********************************************/
void void
dos(sector, cylinderp, headp, sectorp) dos(int sector, unsigned char *cylinderp, unsigned char *headp,
int sector; unsigned char *sectorp)
unsigned char *cylinderp, *headp, *sectorp;
{ {
int cylinder, head; int cylinder, head;
int biosmaxsec; int biosmaxsec;
@ -1210,9 +1191,9 @@ dos(sector, cylinderp, headp, sectorp)
#if 0 #if 0
void void
checkcyl(cyl) checkcyl(int cyl)
int cyl;
{ {
if (cyl >= MAXCYL) if (cyl >= MAXCYL)
warnx("partition start beyond BIOS limit"); warnx("partition start beyond BIOS limit");
} }
@ -1221,8 +1202,7 @@ checkcyl(cyl)
int fd; int fd;
int int
open_disk(u_flag) open_disk(int u_flag)
int u_flag;
{ {
static char namebuf[MAXPATHLEN + 1]; static char namebuf[MAXPATHLEN + 1];
struct stat st; struct stat st;
@ -1252,9 +1232,7 @@ open_disk(u_flag)
} }
int int
read_disk(sector, buf) read_disk(int sector, void *buf)
int sector;
void *buf;
{ {
if (lseek(fd, (off_t)(sector * 512), 0) == -1) if (lseek(fd, (off_t)(sector * 512), 0) == -1)
@ -1263,9 +1241,7 @@ read_disk(sector, buf)
} }
int int
write_disk(sector, buf) write_disk(int sector, void *buf)
int sector;
void *buf;
{ {
if (lseek(fd, (off_t)(sector * 512), 0) == -1) if (lseek(fd, (off_t)(sector * 512), 0) == -1)
@ -1274,7 +1250,7 @@ write_disk(sector, buf)
} }
int int
get_params() get_params(void)
{ {
if (ioctl(fd, DIOCGDEFLABEL, &disklabel) == -1) { if (ioctl(fd, DIOCGDEFLABEL, &disklabel) == -1) {
@ -1295,7 +1271,7 @@ get_params()
} }
int int
read_s0() read_s0(void)
{ {
if (read_disk(0, mboot.bootinst) == -1) { if (read_disk(0, mboot.bootinst) == -1) {
@ -1310,7 +1286,7 @@ read_s0()
} }
int int
write_s0() write_s0(void)
{ {
int flag, i; int flag, i;
@ -1339,8 +1315,7 @@ write_s0()
} }
int int
yesno(str) yesno(const char *str)
char *str;
{ {
int ch, first; int ch, first;
@ -1353,9 +1328,7 @@ yesno(str)
} }
void void
decimal(str, num) decimal(const char *str, int *num)
char *str;
int *num;
{ {
int acc = 0; int acc = 0;
char *cp; char *cp;
@ -1386,8 +1359,7 @@ decimal(str, num)
} }
int int
type_match(key, item) type_match(const void *key, const void *item)
const void *key, *item;
{ {
const int *typep = key; const int *typep = key;
const struct part_type *ptr = item; const struct part_type *ptr = item;
@ -1399,9 +1371,8 @@ type_match(key, item)
return (0); return (0);
} }
char * const char *
get_type(type) get_type(int type)
int type;
{ {
struct part_type *ptr; struct part_type *ptr;