Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/atari/atari Misc KNF and cosmetics.



details:   https://anonhg.NetBSD.org/src/rev/e265c840dc1c
branches:  trunk
changeset: 753517:e265c840dc1c
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Wed Mar 31 14:12:55 2010 +0000

description:
Misc KNF and cosmetics.

diffstat:

 sys/arch/atari/atari/disksubr.c |  197 +++++++++++++++++++--------------------
 sys/arch/atari/atari/intr.c     |   95 +++++++++---------
 sys/arch/atari/atari/machdep.c  |   75 +++++++-------
 3 files changed, 183 insertions(+), 184 deletions(-)

diffs (truncated from 864 to 300 lines):

diff -r 7f67c61136f8 -r e265c840dc1c sys/arch/atari/atari/disksubr.c
--- a/sys/arch/atari/atari/disksubr.c   Wed Mar 31 14:12:33 2010 +0000
+++ b/sys/arch/atari/atari/disksubr.c   Wed Mar 31 14:12:55 2010 +0000
@@ -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 @@
  * 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;
+       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 @@
        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,39 +119,41 @@
                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)
                uprintf("Warning: unknown disklabel format"
-                       "- assuming empty disk\n");
+                   "- assuming empty disk\n");
 
        /* Calulate new checksum. */
        lp->d_magic = lp->d_magic2 = DISKMAGIC;
        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 @@
                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,22 +183,23 @@
        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;
-       int                     rv;
+       struct buf *bp;
+       u_int blk;
+       int rv;
 
        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 @@
        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 @@
                rv = biowait(bp);
        }
        brelse(bp, 0);
-       return(rv);
+       return rv;
 }
 
 /*
@@ -240,15 +245,11 @@
  *          +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;
+       struct buf *bp;
+       int rv;
 
        bp = geteblk(BBMINSIZE);
        bp->b_dev      = MAKEDISKDEV(major(dev), DISKUNIT(dev), RAW_PART);
@@ -261,29 +262,28 @@
        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 @@
                }
        }
        brelse(bp, 0);
-       return(rv);
+       return rv;
 }
 
 #ifdef DISKLABEL_AHDI
@@ -307,24 +307,24 @@
 static void
 ck_label(struct disklabel *dl, struct cpu_disklabel *cdl)
 {
-       u_int                   *rp, i;
+       u_int *rp, i;
 
        for (i = 0; i < dl->d_npartitions; ++i) {
                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);
+                           " 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);
+                                   " includes AHDI auxiliary root\n", 'a' + i);
                        }
                }
        }
@@ -340,17 +340,18 @@
  *          +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;
-       int                     j;
+       struct ahdi_ptbl apt;
+       u_int i;
+       int j;
 
        /*
         * The AHDI format requires a specific block size.
         */
        if (dl->d_secsize != AHDI_BSIZE)
-               return(1);
+               return 1;
 
        /*
         * Fetch the AHDI partition descriptors.
@@ -358,11 +359,12 @@
        apt.at_cdl    = cdl;
        apt.at_nroots = apt.at_nparts = 0;
        i = ahdi_getparts(dev, strat, dl->d_secpercyl,
-                         AHDI_BBLOCK, AHDI_BBLOCK, &apt);
+           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   */



Home | Main Index | Thread Index | Old Index