Misc KNF and cosmetics.

This commit is contained in:
tsutsui 2010-03-31 14:12:55 +00:00
parent 1b840b2df1
commit 8f232399f0
3 changed files with 183 additions and 184 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: disksubr.c,v 1.41 2009/10/20 19:10:10 snj Exp $ */
/* $NetBSD: disksubr.c,v 1.42 2010/03/31 14:12:55 tsutsui Exp $ */
/*
* Copyright (c) 1995 Leo Weppelman.
@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.41 2009/10/20 19:10:10 snj Exp $");
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.42 2010/03/31 14:12:55 tsutsui Exp $");
#ifndef DISKLABEL_NBDA
#define DISKLABEL_NBDA /* required */
@ -69,13 +69,15 @@ static u_int ahdi_getparts(dev_t, void (*)(struct buf *), u_int,
* Returns NULL on success and an error string on failure.
*/
const char *
readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, struct cpu_disklabel *clp)
readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp,
struct cpu_disklabel *clp)
{
int e;
if (clp != NULL)
memset(clp, 0, sizeof *clp);
else printf("Warning: clp == NULL\n");
else
printf("Warning: clp == NULL\n");
/*
* Give some guaranteed validity to the disk label.
@ -85,7 +87,7 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, stru
if (lp->d_secperunit == 0)
lp->d_secperunit = 0x1fffffff;
if (lp->d_secpercyl == 0)
return("Zero secpercyl");
return "Zero secpercyl";
/*
* Some parts of the kernel (see scsipi/cd.c for an example)
@ -117,7 +119,7 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, stru
e = ahdi_label(dev, strat, lp, clp);
#endif
if (e < 0)
return("I/O error");
return "I/O error";
/* Unknown format or uninitialized volume? */
if (e > 0)
@ -129,27 +131,29 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, stru
lp->d_checksum = 0;
lp->d_checksum = dkcksum(lp);
return(NULL);
return NULL;
}
/*
* Check new disk label for sensibility before setting it.
*/
int
setdisklabel(struct disklabel *olp, struct disklabel *nlp, u_long openmask, struct cpu_disklabel *clp)
setdisklabel(struct disklabel *olp, struct disklabel *nlp, u_long openmask,
struct cpu_disklabel *clp)
{
/* special case to allow disklabel to be invalidated */
if (nlp->d_magic == 0xffffffff) {
*olp = *nlp;
return(0);
return 0;
}
/* sanity clause */
if (nlp->d_secpercyl == 0 || nlp->d_npartitions > MAXPARTITIONS
|| nlp->d_secsize == 0 || (nlp->d_secsize % DEV_BSIZE) != 0
|| nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC
|| dkcksum(nlp) != 0)
return(EINVAL);
if (nlp->d_secpercyl == 0 || nlp->d_npartitions > MAXPARTITIONS ||
nlp->d_secsize == 0 || (nlp->d_secsize % DEV_BSIZE) != 0 ||
nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
dkcksum(nlp) != 0)
return EINVAL;
#ifdef DISKLABEL_AHDI
if (clp && clp->cd_bblock)
@ -160,11 +164,11 @@ setdisklabel(struct disklabel *olp, struct disklabel *nlp, u_long openmask, stru
int i = ffs(openmask) - 1;
openmask &= ~(1 << i);
if (i >= nlp->d_npartitions)
return(EBUSY);
return EBUSY;
op = &olp->d_partitions[i];
np = &nlp->d_partitions[i];
if (np->p_offset != op->p_offset || np->p_size < op->p_size)
return(EBUSY);
return EBUSY;
/*
* Copy internally-set partition information
* if new label doesn't include it. XXX
@ -179,14 +183,15 @@ setdisklabel(struct disklabel *olp, struct disklabel *nlp, u_long openmask, stru
nlp->d_checksum = 0;
nlp->d_checksum = dkcksum(nlp);
*olp = *nlp;
return(0);
return 0;
}
/*
* Write disk label back to device after modification.
*/
int
writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, struct cpu_disklabel *clp)
writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp,
struct cpu_disklabel *clp)
{
struct buf *bp;
u_int blk;
@ -194,7 +199,7 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, str
blk = clp->cd_bblock;
if (blk == NO_BOOT_BLOCK)
return(ENXIO);
return ENXIO;
bp = geteblk(BBMINSIZE);
bp->b_dev = MAKEDISKDEV(major(dev), DISKUNIT(dev), RAW_PART);
@ -204,7 +209,7 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, str
bp->b_cylinder = blk / lp->d_secpercyl;
(*strat)(bp);
rv = biowait(bp);
if (!rv) {
if (rv == 0) {
struct bootblock *bb = (struct bootblock *)bp->b_data;
/*
* Allthough the disk pack label may appear anywhere
@ -228,7 +233,7 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, str
rv = biowait(bp);
}
brelse(bp, 0);
return(rv);
return rv;
}
/*
@ -240,12 +245,8 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, str
* +1 if no valid label was found.
*/
static int
bsd_label(dev, strat, label, blkno, offsetp)
dev_t dev;
void (*strat)(struct buf *);
struct disklabel *label;
u_int blkno,
*offsetp;
bsd_label(dev_t dev, void (*strat)(struct buf *), struct disklabel *label,
u_int blkno, u_int *offsetp)
{
struct buf *bp;
int rv;
@ -261,29 +262,28 @@ bsd_label(dev, strat, label, blkno, offsetp)
rv = -1;
if (!biowait(bp)) {
struct bootblock *bb;
u_int32_t *p, *end;
uint32_t *p, *end;
rv = 1;
bb = (struct bootblock *)bp->b_data;
end = (u_int32_t *)((char *)&bb[1] - sizeof(struct disklabel));
for (p = (u_int32_t *)bb; p < end; ++p) {
end = (uint32_t *)((char *)&bb[1] - sizeof(struct disklabel));
for (p = (uint32_t *)bb; p < end; ++p) {
struct disklabel *dl = (struct disklabel *)&p[1];
/*
* Compatibility kludge: the boot block magic number is
* new in 1.1A, in previous versions the disklabel was
* stored at the end of the boot block (offset 7168).
*/
if ( ( (p[0] == NBDAMAGIC && blkno == 0)
|| (p[0] == AHDIMAGIC && blkno != 0)
if (((p[0] == NBDAMAGIC && blkno == 0) ||
(p[0] == AHDIMAGIC && blkno != 0)
#ifdef COMPAT_11
|| (char *)dl - (char *)bb == 7168
#endif
)
&& dl->d_npartitions <= MAXPARTITIONS
&& dl->d_magic2 == DISKMAGIC
&& dl->d_magic == DISKMAGIC
&& dkcksum(dl) == 0
) {
) &&
dl->d_npartitions <= MAXPARTITIONS &&
dl->d_magic2 == DISKMAGIC &&
dl->d_magic == DISKMAGIC &&
dkcksum(dl) == 0) {
if (offsetp != NULL)
*offsetp = (char *)dl - (char *)bb;
*label = *dl;
@ -293,7 +293,7 @@ bsd_label(dev, strat, label, blkno, offsetp)
}
}
brelse(bp, 0);
return(rv);
return rv;
}
#ifdef DISKLABEL_AHDI
@ -313,16 +313,16 @@ ck_label(struct disklabel *dl, struct cpu_disklabel *cdl)
struct partition *p = &dl->d_partitions[i];
if (i == RAW_PART || p->p_size == 0)
continue;
if ( (p->p_offset >= cdl->cd_bslst
&& p->p_offset <= cdl->cd_bslend)
|| (cdl->cd_bslst >= p->p_offset
&& cdl->cd_bslst < p->p_offset + p->p_size)) {
if ((p->p_offset >= cdl->cd_bslst &&
p->p_offset <= cdl->cd_bslend) ||
(cdl->cd_bslst >= p->p_offset &&
cdl->cd_bslst < p->p_offset + p->p_size)) {
uprintf("Warning: NetBSD partition %c includes"
" AHDI bad sector list\n", 'a'+i);
}
for (rp = &cdl->cd_roots[0]; *rp; ++rp) {
if (*rp >= p->p_offset
&& *rp < p->p_offset + p->p_size) {
if (*rp >= p->p_offset &&
*rp < p->p_offset + p->p_size) {
uprintf("Warning: NetBSD partition %c"
" includes AHDI auxiliary root\n", 'a' + i);
}
@ -340,7 +340,8 @@ ck_label(struct disklabel *dl, struct cpu_disklabel *cdl)
* +1 if no valid AHDI label was found.
*/
int
ahdi_label(dev_t dev, void (*strat)(struct buf *), struct disklabel *dl, struct cpu_disklabel *cdl)
ahdi_label(dev_t dev, void (*strat)(struct buf *), struct disklabel *dl,
struct cpu_disklabel *cdl)
{
struct ahdi_ptbl apt;
u_int i;
@ -350,7 +351,7 @@ ahdi_label(dev_t dev, void (*strat)(struct buf *), struct disklabel *dl, struct
* The AHDI format requires a specific block size.
*/
if (dl->d_secsize != AHDI_BSIZE)
return(1);
return 1;
/*
* Fetch the AHDI partition descriptors.
@ -361,8 +362,9 @@ ahdi_label(dev_t dev, void (*strat)(struct buf *), struct disklabel *dl, struct
AHDI_BBLOCK, AHDI_BBLOCK, &apt);
if (i) {
if (i < dl->d_secperunit)
return(-1); /* disk read error */
else return(1); /* reading past end of medium */
return -1; /* disk read error */
else
return 1; /* reading past end of medium */
}
/*
@ -379,28 +381,28 @@ ahdi_label(dev_t dev, void (*strat)(struct buf *), struct disklabel *dl, struct
"- assuming non exists\n");
}
if (apt.at_hdsize == 0 || apt.at_nparts == 0) /* unlikely */
return(1);
return 1;
if (apt.at_nparts > AHDI_MAXPARTS) /* XXX kludge */
return(-1);
return -1;
for (i = 0; i < apt.at_nparts; ++i) {
struct ahdi_part *p1 = &apt.at_parts[i];
for (j = 0; j < apt.at_nroots; ++j) {
u_int aux = apt.at_roots[j];
if (aux >= p1->ap_st && aux <= p1->ap_end)
return(1);
return 1;
}
for (j = i + 1; j < apt.at_nparts; ++j) {
struct ahdi_part *p2 = &apt.at_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 >= apt.at_bslst && p1->ap_st <= apt.at_bslend)
return(1);
return 1;
if (apt.at_bslst >= p1->ap_st && apt.at_bslst <= p1->ap_end)
return(1);
return 1;
}
/*
@ -409,17 +411,17 @@ ahdi_label(dev_t dev, void (*strat)(struct buf *), struct disklabel *dl, struct
apt.at_bblock = NO_BOOT_BLOCK;
for (i = 0; i < apt.at_nparts; ++i) {
struct ahdi_part *pd = &apt.at_parts[i];
u_int id = *((u_int32_t *)&pd->ap_flg);
u_int id = *((uint32_t *)&pd->ap_flg);
if (id == AHDI_PID_NBD || id == AHDI_PID_RAW) {
u_int blkno = pd->ap_st;
j = bsd_label(dev, strat, dl, blkno, &apt.at_label);
if (j < 0) {
return(j); /* I/O error */
return j; /* I/O error */
}
if (!j) {
if (j == 0) {
apt.at_bblock = blkno; /* got it */
ck_label(dl, cdl);
return(0);
return 0;
}
/*
* Not yet, but if this is the first NBD partition
@ -428,8 +430,8 @@ ahdi_label(dev_t dev, void (*strat)(struct buf *), struct disklabel *dl, struct
* in case there is no valid disk label on any of the
* other AHDI partitions.
*/
if (id == AHDI_PID_NBD
&& apt.at_bblock == NO_BOOT_BLOCK)
if (id == AHDI_PID_NBD &&
apt.at_bblock == NO_BOOT_BLOCK)
apt.at_bblock = blkno;
}
}
@ -441,7 +443,7 @@ ahdi_label(dev_t dev, void (*strat)(struct buf *), struct disklabel *dl, struct
* writedisklabel() calls will fail.
*/
ahdi_to_bsd(dl, &apt);
return(0);
return 0;
}
/*
@ -468,7 +470,7 @@ ahdi_to_bsd(struct disklabel *dl, struct ahdi_ptbl *apt)
struct ahdi_part *pd = &apt->at_parts[i];
int fst, pno = -1;
switch (*((u_int32_t *)&pd->ap_flg)) {
switch (*((uint32_t *)&pd->ap_flg)) {
case AHDI_PID_NBD:
/*
* If this partition has been marked as the
@ -526,12 +528,8 @@ ahdi_to_bsd(struct disklabel *dl, struct ahdi_ptbl *apt)
* number of the offending block is returned.
*/
static u_int
ahdi_getparts(dev, strat, secpercyl, rsec, esec, apt)
dev_t dev;
void (*strat)(struct buf *);
u_int secpercyl,
rsec, esec;
struct ahdi_ptbl *apt;
ahdi_getparts(dev_t dev, void (*strat)(struct buf *), u_int secpercyl,
u_int rsec, u_int esec, struct ahdi_ptbl *apt)
{
struct ahdi_part *part, *end;
struct ahdi_root *root;
@ -553,9 +551,10 @@ ahdi_getparts(dev, strat, secpercyl, rsec, esec, apt)
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 = *((u_int32_t *)&part->ap_flg);
u_int id = *((uint32_t *)&part->ap_flg);
if (!(id & 0x01000000))
continue;
if ((id &= 0x00ffffff) == AHDI_PID_XGM) {
@ -565,13 +564,13 @@ ahdi_getparts(dev, strat, secpercyl, rsec, esec, apt)
apt->at_nroots += 1;
rv = ahdi_getparts(dev, strat, secpercyl, offs,
(esec == AHDI_BBLOCK) ? offs : esec, apt);
if (rv)
if (rv != 0)
goto done;
continue;
}
else if (apt->at_nparts < AHDI_MAXPARTS) {
struct ahdi_part *p = &apt->at_parts[apt->at_nparts];
*((u_int32_t *)&p->ap_flg) = id;
*((uint32_t *)&p->ap_flg) = id;
p->ap_st = part->ap_st + rsec;
p->ap_end = p->ap_st + part->ap_size - 1;
}
@ -583,6 +582,6 @@ ahdi_getparts(dev, strat, secpercyl, rsec, esec, apt)
rv = 0;
done:
brelse(bp, 0);
return(rv);
return rv;
}
#endif /* DISKLABEL_AHDI */

View File

@ -1,4 +1,4 @@
/* $NetBSD: intr.c,v 1.20 2010/02/09 23:05:16 wiz Exp $ */
/* $NetBSD: intr.c,v 1.21 2010/03/31 14:12:55 tsutsui Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.20 2010/02/09 23:05:16 wiz Exp $");
__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.21 2010/03/31 14:12:55 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -135,14 +135,14 @@ intr_establish(int vector, int type, int pri, hw_ifun_t ih_fun, void *ih_arg)
switch (type & (AUTO_VEC|USER_VEC)) {
case AUTO_VEC:
if (vector < AVEC_MIN || vector > AVEC_MAX)
return (NULL);
return NULL;
vec_list = &autovec_list[vector-1];
hard_vec = &autovects[vector-1];
ih->ih_intrcnt = &intrcnt_auto[vector-1];
break;
case USER_VEC:
if (vector < UVEC_MIN || vector > UVEC_MAX)
return (NULL);
return NULL;
vec_list = &uservec_list[vector];
hard_vec = &uservects[vector];
ih->ih_intrcnt = &intrcnt_user[vector];
@ -150,7 +150,7 @@ intr_establish(int vector, int type, int pri, hw_ifun_t ih_fun, void *ih_arg)
default:
printf("intr_establish: bogus vector type\n");
free(ih, M_DEVBUF);
return(NULL);
return NULL;
}
/*
@ -187,7 +187,7 @@ intr_establish(int vector, int type, int pri, hw_ifun_t ih_fun, void *ih_arg)
if (cur_vec->ih_type & FAST_VEC) {
free(ih, M_DEVBUF);
printf("intr_establish: vector cannot be shared\n");
return (NULL);
return NULL;
}
/*
@ -202,7 +202,7 @@ intr_establish(int vector, int type, int pri, hw_ifun_t ih_fun, void *ih_arg)
LIST_INSERT_BEFORE(cur_vec, ih, ih_link);
splx(s);
return (ih);
return ih;
}
}
@ -286,7 +286,8 @@ intr_dispatch(struct clockframe frame)
vec_list = &autovec_list[vector - AVEC_LOC];
else if (vector <= (UVEC_LOC+UVEC_MAX) && vector >= UVEC_LOC)
vec_list = &uservec_list[vector - UVEC_LOC];
else panic("intr_dispatch: Bogus vector %d", vector);
else
panic("intr_dispatch: Bogus vector %d", vector);
if ((ih = vec_list->lh_first) == NULL) {
printf("intr_dispatch: vector %d unexpected\n", vector);
@ -298,8 +299,8 @@ intr_dispatch(struct clockframe frame)
/* Give all the handlers a chance. */
for (; ih != NULL; ih = ih->ih_link.le_next)
handled |= (*ih->ih_fun)((ih->ih_type & ARG_CLOCKFRAME)
? &frame : ih->ih_arg, frame.cf_sr);
handled |= (*ih->ih_fun)((ih->ih_type & ARG_CLOCKFRAME) ?
&frame : ih->ih_arg, frame.cf_sr);
if (handled)
straycount = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.165 2010/02/08 19:02:26 joerg Exp $ */
/* $NetBSD: machdep.c,v 1.166 2010/03/31 14:12:55 tsutsui Exp $ */
/*
* Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
@ -77,7 +77,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.165 2010/02/08 19:02:26 joerg Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.166 2010/03/31 14:12:55 tsutsui Exp $");
#include "opt_ddb.h"
#include "opt_compat_netbsd.h"
@ -225,7 +225,6 @@ cpu_startup(void)
{
extern int iomem_malloc_safe;
char pbuf[9];
#ifdef DEBUG
extern int pmapdebug;
int opmapdebug = pmapdebug;
@ -339,7 +338,7 @@ identifycpu(void)
case CPU_68060:
{
u_int32_t pcr;
uint32_t pcr;
char cputxt[30];
__asm(".word 0x4e7a,0x0808;"
@ -454,7 +453,7 @@ reserve_dumppages(vaddr_t p)
return p + BYTES_PER_DUMP;
}
u_int32_t dumpmag = 0x8fca0101; /* magic number for savecore */
uint32_t dumpmag = 0x8fca0101; /* magic number for savecore */
int dumpsize = 0; /* also for savecore (pages) */
long dumplo = 0; /* (disk blocks) */
@ -633,8 +632,8 @@ straytrap(int pc, u_short evec)
if (prev_evec == evec) {
delay(1000000);
prev_evec = 0;
}
else prev_evec = evec;
} else
prev_evec = evec;
}
void
@ -663,13 +662,13 @@ badbaddr(void *addr, int size)
}
switch (size) {
case 1:
i = *(volatile char *)addr;
i = *(volatile uint8_t *)addr;
break;
case 2:
i = *(volatile short *)addr;
i = *(volatile uint16_t *)addr;
break;
case 4:
i = *(volatile long *)addr;
i = *(volatile uint32_t *)addr;
break;
default:
panic("badbaddr: unknown size");
@ -732,7 +731,7 @@ add_sicallback(void (*function)(void *, void *), void *rock1, void *rock2)
if (si)
++ncbd; /* count # dynamically allocated */
#endif
if (!si)
if (si == NULL)
return;
}
@ -776,7 +775,7 @@ rem_sicallback(void (*function)(void *rock1, void *rock2))
else {
si->next = si_free;
si_free = si;
if (psi)
if (psi != NULL)
psi->next = nsi;
else
si_callbacks = nsi;
@ -801,7 +800,7 @@ call_sicallbacks(void)
si_callbacks = si->next;
splx(s);
if (si) {
if (si != NULL) {
function = si->function;
rock1 = si->rock1;
rock2 = si->rock2;
@ -826,7 +825,7 @@ call_sicallbacks(void)
function(rock1, rock2);
splx(s);
}
} while (si);
} while (si != NULL);
#ifdef DIAGNOSTIC
if (ncbd) {
#ifdef DEBUG
@ -873,7 +872,7 @@ cpu_exec_aout_makecmds(struct lwp *l, struct exec_package *epp)
#ifdef COMPAT_NOMID
if (!((execp->a_midmag >> 16) & 0x0fff)
&& execp->a_midmag == ZMAGIC)
return(exec_aout_prep_zmagic(l->l_proc, epp));
return exec_aout_prep_zmagic(l->l_proc, epp);
#endif
return error;
}