Module Name:    src
Committed By:   tsutsui
Date:           Sun Mar 13 08:54:45 UTC 2016

Modified Files:
        src/sys/arch/atari/stand/installboot: disklabel.c installboot.h

Log Message:
Misc KNF and ANSIfy.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/atari/stand/installboot/disklabel.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/atari/stand/installboot/installboot.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/atari/stand/installboot/disklabel.c
diff -u src/sys/arch/atari/stand/installboot/disklabel.c:1.6 src/sys/arch/atari/stand/installboot/disklabel.c:1.7
--- src/sys/arch/atari/stand/installboot/disklabel.c:1.6	Sat Oct  1 15:59:00 2011
+++ src/sys/arch/atari/stand/installboot/disklabel.c	Sun Mar 13 08:54:45 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: disklabel.c,v 1.6 2011/10/01 15:59:00 chs Exp $	*/
+/*	$NetBSD: disklabel.c,v 1.7 2016/03/13 08:54:45 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1995 Waldi Ravens
@@ -57,29 +57,29 @@ struct ahdilabel {
 };
 
 u_int	dkcksum(struct disklabel *);
-u_int32_t readdisklabel(char *, struct disklabel *);
+uint32_t readdisklabel(char *, struct disklabel *);
 
 static int  bsd_label(int, off_t, struct disklabel *);
-static int  ahdi_label(int, u_int32_t *, struct disklabel *);
+static int  ahdi_label(int, uint32_t *, struct disklabel *);
 static int  ahdi_getparts(int, daddr_t, daddr_t, struct ahdilabel *);
 
 u_int
 dkcksum (struct disklabel *dl)
 {
-	u_int16_t sum  = 0,
-		  *st  = (u_int16_t *)dl,
-		  *end = (u_int16_t *)&dl->d_partitions[dl->d_npartitions];
+	uint16_t sum  = 0,
+		 *st  = (uint16_t *)dl,
+		 *end = (uint16_t *)&dl->d_partitions[dl->d_npartitions];
 
 	while (st < end)
 		sum ^= *st++;
-	return(sum);
+	return sum;
 }
 
-u_int32_t
-readdisklabel (char *fn, struct disklabel *dl)
+uint32_t
+readdisklabel(char *fn, struct disklabel *dl)
 {
 	int		 fd, e;
-	u_int32_t	 bbsec;
+	uint32_t	 bbsec;
 
 	memset(dl, 0, sizeof *dl);
 
@@ -89,63 +89,62 @@ readdisklabel (char *fn, struct disklabe
 	/* Try NetBSD/Atari format first */
 	if ((e = bsd_label(fd, (off_t)0, dl)) < 0)
 		err(EXIT_FAILURE, "%s", fn);
-	if (!e)
-		return(0);
+	if (e == 0)
+		return 0;
 
 	/* Try unprotected AHDI format last */
 	if ((e = ahdi_label(fd, &bbsec, dl)) < 0)
 		err(EXIT_FAILURE, "%s", fn);
-	if (!e)
-		return(bbsec);
+	if (e == 0)
+		return bbsec;
 
 	warnx("%s: Unknown disk label format.", fn);
-	return(NO_BOOT_BLOCK);
+	return NO_BOOT_BLOCK;
 }
 
 static int
-bsd_label (int fd, off_t offs, struct disklabel *label)
+bsd_label(int fd, off_t offs, struct disklabel *label)
 {
 	struct bootblock bb;
 	struct disklabel *p;
 
 	if (lseek(fd, offs, SEEK_SET) != offs)
-		return(-1);
+		return -1;
 	if (read(fd, &bb, sizeof(bb)) != sizeof(bb))
-		return(-1);
+		return -1;
 
 	p = (struct disklabel *)bb.bb_label;
-	if (  (offs == 0 && bb.bb_magic != NBDAMAGIC)
-	   || (offs != 0 && bb.bb_magic != AHDIMAGIC)
-	   || p->d_npartitions > MAXPARTITIONS
-	   || p->d_magic2 != DISKMAGIC
-	   || p->d_magic  != DISKMAGIC
-	   || dkcksum(p)  != 0
-	   )	{
-		return(1);
+	if ((offs == 0 && bb.bb_magic != NBDAMAGIC) ||
+	    (offs != 0 && bb.bb_magic != AHDIMAGIC) ||
+	    p->d_npartitions > MAXPARTITIONS ||
+	    p->d_magic2 != DISKMAGIC ||
+	    p->d_magic  != DISKMAGIC ||
+	    dkcksum(p)  != 0) {
+		return 1;
 	}
 
 	*label = *p;
-	return(0);
+	return 0;
 }
 
 static int
-ahdi_label (int fd, u_int32_t *bbsec, struct disklabel *label)
+ahdi_label(int fd, uint32_t *bbsec, struct disklabel *label)
 {
 	struct ahdilabel al;
 	u_int		 i, j;
 	int		 e;
 
 	memset(&al, 0, sizeof(al));
-	if ((e = ahdi_getparts(fd, AHDI_BBLOCK, AHDI_BBLOCK, &al)))
-		return(e);
+	if ((e = ahdi_getparts(fd, AHDI_BBLOCK, AHDI_BBLOCK, &al)) != 0)
+		return e;
 
 	/*
 	 * Perform sanity checks.
 	 */
 	if (al.bslst == 0 || al.bslend == 0)
-		return(1);
+		return 1;
 	if (al.nsecs == 0 || al.nparts == 0)
-		return(1);
+		return 1;
 	if (al.nparts > AHDI_MAXPARTS)
 		warnx("Too many AHDI partitions (%u).", al.nparts);
 	for (i = 0; i < al.nparts; ++i) {
@@ -153,19 +152,19 @@ ahdi_label (int fd, u_int32_t *bbsec, st
 		for (j = 0; j < al.nroots; ++j) {
 			daddr_t	aux = al.roots[j];
 			if (aux >= p1->ap_st && aux <= p1->ap_end)
-				return(1);
+				return 1;
 		}
 		for (j = i + 1; j < al.nparts; ++j) {
 			struct ahdi_part *p2 = &al.parts[j];
 			if (p1->ap_st >= p2->ap_st && p1->ap_st <= p2->ap_end)
-				return(1);
+				return 1;
 			if (p2->ap_st >= p1->ap_st && p2->ap_st <= p1->ap_end)
-				return(1);
+				return 1;
 		}
 		if (p1->ap_st >= al.bslst && p1->ap_st <= al.bslend)
-			return(1);
+			return 1;
 		if (al.bslst >= p1->ap_st && al.bslst <= p1->ap_end)
-			return(1);
+			return 1;
 	}
 
 	/*
@@ -179,23 +178,19 @@ ahdi_label (int fd, u_int32_t *bbsec, st
 		if (id == AHDI_PID_NBD || id == AHDI_PID_RAW) {
 			off_t	offs = pd->ap_st * AHDI_BSIZE;
 			if ((e = bsd_label(fd, offs, label)) < 0)
-				return(e);
-			if (!e) {
+				return e;
+			if (e == 0) {
 				*bbsec = pd->ap_st;	/* got it */
-				return(0);
+				return 0;
 			}
 		}
 	}
 	*bbsec = NO_BOOT_BLOCK;	/* AHDI label, no NetBSD boot block */
-	return(0);
+	return 0;
 }
 
 static int
-ahdi_getparts(fd, rsec, esec, alab)
-	int		 fd;
-	daddr_t		 rsec,
-			 esec;
-	struct ahdilabel *alab;
+ahdi_getparts(int fd, daddr_t rsec, daddr_t esec, struct ahdilabel *alab)
 {
 	struct ahdi_part *part, *end;
 	struct ahdi_root root;
@@ -205,35 +200,36 @@ ahdi_getparts(fd, rsec, esec, alab)
 	if (lseek(fd, ro, SEEK_SET) != ro) {
 		off_t	mend = lseek(fd, 0, SEEK_END);
 		if (mend == -1 || mend > ro)
-			return(-1);
-		return(1);
+			return -1;
+		return 1;
 	}
 	if (read(fd, &root, sizeof(root)) != sizeof(root))
-		return(-1);
+		return -1;
 
 	if (rsec == AHDI_BBLOCK)
 		end = &root.ar_parts[AHDI_MAXRPD];
-	else end = &root.ar_parts[AHDI_MAXARPD];
+	else
+		end = &root.ar_parts[AHDI_MAXARPD];
 	for (part = root.ar_parts; part < end; ++part) {
 		u_int	id;
 
 		memcpy(&id, &part->ap_flg, sizeof (id));
-		if (!(id & 0x01000000))
+		if ((id & 0x01000000) == 0)
 			continue;
 		if ((id &= 0x00ffffff) == AHDI_PID_XGM) {
 			int	e;
 			daddr_t	aux = part->ap_st + esec;
 			alab->roots = realloc(alab->roots,
-					(alab->nroots + 1) * sizeof(*alab->roots));
+			    (alab->nroots + 1) * sizeof(*alab->roots));
 			alab->roots[alab->nroots++] = aux;
 			e = ahdi_getparts(fd, aux,
-					   esec == AHDI_BBLOCK ? aux : esec, alab);
-			if (e)
-				return(e);
+			    esec == AHDI_BBLOCK ? aux : esec, alab);
+			if (e != 0)
+				return e;
 		} else {
 			struct ahdi_part *p;
 			alab->parts = realloc(alab->parts,
-					(alab->nparts + 1) * sizeof(*alab->parts));
+			    (alab->nparts + 1) * sizeof(*alab->parts));
 			p = &alab->parts[alab->nparts++];
 			memcpy(&p->ap_flg, &id, sizeof (id));
 			p->ap_st = part->ap_st + rsec;
@@ -243,5 +239,5 @@ ahdi_getparts(fd, rsec, esec, alab)
 	alab->nsecs  = root.ar_hdsize;
 	alab->bslst  = root.ar_bslst;
 	alab->bslend = root.ar_bslst + root.ar_bslsize - 1;
-	return(0);
+	return 0;
 }

Index: src/sys/arch/atari/stand/installboot/installboot.h
diff -u src/sys/arch/atari/stand/installboot/installboot.h:1.10 src/sys/arch/atari/stand/installboot/installboot.h:1.11
--- src/sys/arch/atari/stand/installboot/installboot.h:1.10	Sat Mar 14 14:45:57 2009
+++ src/sys/arch/atari/stand/installboot/installboot.h	Sun Mar 13 08:54:45 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: installboot.h,v 1.10 2009/03/14 14:45:57 dsl Exp $	*/
+/*	$NetBSD: installboot.h,v 1.11 2016/03/13 08:54:45 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1995 Waldi Ravens
@@ -46,4 +46,4 @@
 #define	BOOTVERSION	0x03
 
 u_int	dkcksum(struct disklabel *);
-u_int32_t readdisklabel(char *, struct disklabel *);
+uint32_t readdisklabel(char *, struct disklabel *);

Reply via email to