Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc/stand/ofwboot WARNSfy and fix dumb bugs notic...



details:   https://anonhg.NetBSD.org/src/rev/011bbaa3465b
branches:  trunk
changeset: 765207:011bbaa3465b
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sat May 21 15:50:42 2011 +0000

description:
WARNSfy and fix dumb bugs noticed by warnings.

diffstat:

 sys/arch/sparc/stand/ofwboot/Locore.c           |   9 ++--
 sys/arch/sparc/stand/ofwboot/Makefile           |   4 +-
 sys/arch/sparc/stand/ofwboot/boot.c             |  11 ++---
 sys/arch/sparc/stand/ofwboot/loadfile_machdep.c |   4 +-
 sys/arch/sparc/stand/ofwboot/net.c              |   8 ++-
 sys/arch/sparc/stand/ofwboot/net.h              |  12 ++---
 sys/arch/sparc/stand/ofwboot/netif_of.c         |   4 +-
 sys/arch/sparc/stand/ofwboot/ofdev.c            |  49 ++++++++++--------------
 sys/arch/sparc/stand/ofwboot/openfirm.h         |   5 +-
 sys/arch/sparc/stand/ofwboot/promlib.c          |   7 ++-
 10 files changed, 54 insertions(+), 59 deletions(-)

diffs (truncated from 385 to 300 lines):

diff -r 02bb91cd9f74 -r 011bbaa3465b sys/arch/sparc/stand/ofwboot/Locore.c
--- a/sys/arch/sparc/stand/ofwboot/Locore.c     Sat May 21 15:22:49 2011 +0000
+++ b/sys/arch/sparc/stand/ofwboot/Locore.c     Sat May 21 15:50:42 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: Locore.c,v 1.11 2009/05/18 11:39:30 nakayama Exp $     */
+/*     $NetBSD: Locore.c,v 1.12 2011/05/21 15:50:42 tsutsui Exp $      */
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -764,12 +764,12 @@
 
        if (virt == NULL) {
                if ((virt = (void*)OF_alloc_virt(size, align)) == (void*)-1) {
-                       printf("OF_alloc_virt(%d,%d) failed w/%x\n", size, align, virt);
+                       printf("OF_alloc_virt(%d,%d) failed w/%p\n", size, align, virt);
                        return (void *)-1;
                }
        } else {
                if ((newvirt = (void*)OF_claim_virt((vaddr_t)virt, size)) == (void*)-1) {
-                       printf("OF_claim_virt(%x,%d) failed w/%x\n", virt, size, newvirt);
+                       printf("OF_claim_virt(%p,%d) failed w/%p\n", virt, size, newvirt);
                        return (void *)-1;
                }
        }
@@ -779,7 +779,8 @@
                return (void *)-1;
        }
        if (OF_map_phys(paddr, size, (vaddr_t)virt, -1) == -1) {
-               printf("OF_map_phys(%x,%d,%x,%d) failed\n", paddr, size, virt, -1);
+               printf("OF_map_phys(0x%lx,%d,%p,%d) failed\n",
+                   (u_long)paddr, size, virt, -1);
                OF_free_phys((paddr_t)paddr, size);
                OF_free_virt((vaddr_t)virt, size);
                return (void *)-1;
diff -r 02bb91cd9f74 -r 011bbaa3465b sys/arch/sparc/stand/ofwboot/Makefile
--- a/sys/arch/sparc/stand/ofwboot/Makefile     Sat May 21 15:22:49 2011 +0000
+++ b/sys/arch/sparc/stand/ofwboot/Makefile     Sat May 21 15:50:42 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.28 2011/01/23 11:29:46 nakayama Exp $
+#      $NetBSD: Makefile,v 1.29 2011/05/21 15:50:42 tsutsui Exp $
 
 CURDIR=        ${.CURDIR}
 S=     ${CURDIR}/../../../..
@@ -7,7 +7,7 @@
 # Override normal settings
 #
 
-WARNS=         0
+WARNS?=                2
 
 PROG?=         ofwboot
 SRCS=          srt0.s Locore.c boot.c ofdev.c alloc.c net.c netif_of.c vers.c
diff -r 02bb91cd9f74 -r 011bbaa3465b sys/arch/sparc/stand/ofwboot/boot.c
--- a/sys/arch/sparc/stand/ofwboot/boot.c       Sat May 21 15:22:49 2011 +0000
+++ b/sys/arch/sparc/stand/ofwboot/boot.c       Sat May 21 15:50:42 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: boot.c,v 1.27 2011/01/22 19:19:24 joerg Exp $  */
+/*     $NetBSD: boot.c,v 1.28 2011/05/21 15:50:42 tsutsui Exp $        */
 
 /*
  * Copyright (c) 1997, 1999 Eduardo E. Horvath.  All rights reserved.
@@ -230,8 +230,8 @@
 static void
 ksyms_copyout(void **ssym, void **esym)
 {
-       void *addr;
-       int kssize = (int)(long)(*esym - *ssym + 1);
+       uint8_t *addr;
+       int kssize = (int)(long)((char *)*esym - (char *)*ssym + 1);
 
        DPRINTF(("ksyms_copyout(): ssym = %p, esym = %p, kssize = %d\n",
                                *ssym, *esym, kssize));
@@ -253,7 +253,6 @@
 static void
 jump_to_kernel(u_long *marks, char *kernel, char *args, void *ofw)
 {
-       extern char end[];
        int l, machine_tag;
        long newargs[4];
        void *ssym, *esym;
@@ -467,7 +466,7 @@
 static void
 check_boot_config(void)
 {
-       int fd, err, off, len;
+       int fd, off, len;
        struct stat st;
        char *bc;
 
@@ -515,7 +514,7 @@
 
        for (;; *kernel = '\0') {
                if (boothowto & RB_ASKNAME) {
-                       char *cp, cmdline[PROM_MAX_PATH];
+                       char cmdline[PROM_MAX_PATH];
 
                        printf("Boot: ");
                        gets(cmdline);
diff -r 02bb91cd9f74 -r 011bbaa3465b sys/arch/sparc/stand/ofwboot/loadfile_machdep.c
--- a/sys/arch/sparc/stand/ofwboot/loadfile_machdep.c   Sat May 21 15:22:49 2011 +0000
+++ b/sys/arch/sparc/stand/ofwboot/loadfile_machdep.c   Sat May 21 15:50:42 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: loadfile_machdep.c,v 1.8 2011/05/20 14:49:54 he Exp $  */
+/*     $NetBSD: loadfile_machdep.c,v 1.9 2011/05/21 15:50:42 tsutsui Exp $     */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -71,7 +71,9 @@
 static void*   ofw_memset(void *, int, size_t);
 static void    ofw_freeall(void);
 
+#if 0
 static int     nop_mapin(vaddr_t, vsize_t);
+#endif
 static ssize_t nop_read(int, void *, size_t);
 static void*   nop_memcpy(void *, const void *, size_t);
 static void*   nop_memset(void *, int, size_t);
diff -r 02bb91cd9f74 -r 011bbaa3465b sys/arch/sparc/stand/ofwboot/net.c
--- a/sys/arch/sparc/stand/ofwboot/net.c        Sat May 21 15:22:49 2011 +0000
+++ b/sys/arch/sparc/stand/ofwboot/net.c        Sat May 21 15:50:42 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: net.c,v 1.6 2011/05/21 15:10:34 christos Exp $ */
+/*     $NetBSD: net.c,v 1.7 2011/05/21 15:50:42 tsutsui Exp $  */
 
 /*
  * Copyright (C) 1995 Wolfgang Solfrank.
@@ -60,12 +60,14 @@
 #include <lib/libsa/stand.h>
 #include <lib/libsa/net.h>
 #include <lib/libsa/netif.h>
+#include <lib/libsa/bootp.h>
 #include <lib/libsa/bootparam.h>
 #include <lib/libsa/nfs.h>
 
 #include <lib/libkern/libkern.h>
 
 #include "ofdev.h"
+#include "net.h"
 
 
 static int net_mountroot_bootparams(void);
@@ -116,6 +118,7 @@
                        netif_close(netdev_sock);
                        netdev_sock = -1;
                }
+       return 0;
 }
 
 static void
@@ -178,14 +181,13 @@
 }
 
 int
-net_tftp_bootp(int **sock)
+net_tftp_bootp(struct of_dev *op)
 {
 
        net_mountroot_bootp();
        if (myip.s_addr == 0)
                return(ENOENT);
 
-       *sock = &netdev_sock;
        return (0);
 }
 
diff -r 02bb91cd9f74 -r 011bbaa3465b sys/arch/sparc/stand/ofwboot/net.h
--- a/sys/arch/sparc/stand/ofwboot/net.h        Sat May 21 15:22:49 2011 +0000
+++ b/sys/arch/sparc/stand/ofwboot/net.h        Sat May 21 15:50:42 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: net.h,v 1.1 2011/05/20 14:49:54 he Exp $ */
+/* $NetBSD: net.h,v 1.2 2011/05/21 15:50:42 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -32,11 +32,9 @@
 #ifndef _OFWBOOT_NET_H
 #define _OFWBOOT_NET_H
 
-extern int     net_open(struct of_dev *);
-extern int     net_close(struct of_dev *);
-extern int     net_mountroot_bootparams(void);
-extern int     net_mountroot_bootp(void);
-extern int     net_tftp_bootp(int **);
-extern int     net_mountroot(void);
+int    net_open(struct of_dev *);
+int    net_close(struct of_dev *);
+int    net_tftp_bootp(struct of_dev *);
+int    net_mountroot(void);
 
 #endif /* _OFWBOOT_NET_H */
diff -r 02bb91cd9f74 -r 011bbaa3465b sys/arch/sparc/stand/ofwboot/netif_of.c
--- a/sys/arch/sparc/stand/ofwboot/netif_of.c   Sat May 21 15:22:49 2011 +0000
+++ b/sys/arch/sparc/stand/ofwboot/netif_of.c   Sat May 21 15:50:42 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netif_of.c,v 1.7 2009/03/18 16:00:15 cegger Exp $      */
+/*     $NetBSD: netif_of.c,v 1.8 2011/05/21 15:50:42 tsutsui Exp $     */
 
 /*
  * Copyright (C) 1995 Wolfgang Solfrank.
@@ -73,8 +73,6 @@
 {
        struct of_dev *op = machdep_hint;
        struct iodesc *io;
-       int fd, error;
-       char addr[32];
        
 #ifdef NETIF_DEBUG
        printf("netif_open...");
diff -r 02bb91cd9f74 -r 011bbaa3465b sys/arch/sparc/stand/ofwboot/ofdev.c
--- a/sys/arch/sparc/stand/ofwboot/ofdev.c      Sat May 21 15:22:49 2011 +0000
+++ b/sys/arch/sparc/stand/ofwboot/ofdev.c      Sat May 21 15:50:42 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ofdev.c,v 1.29 2011/05/20 14:49:54 he Exp $    */
+/*     $NetBSD: ofdev.c,v 1.30 2011/05/21 15:50:42 tsutsui Exp $       */
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -57,6 +57,7 @@
 #include "ofdev.h"
 #include "net.h"
 #include "boot.h"
+#include "net.h"
 
 extern char bootdev[];
 extern bool root_fs_quickseekable;
@@ -180,14 +181,17 @@
 #endif
        prom_close(op->handle);
        op->handle = -1;
+       return 0;
 }
 
 static struct devsw ofdevsw[1] = {
-       "OpenFirmware",
-       strategy,
-       (int (*)(struct open_file *, ...))nodev,
-       devclose,
-       noioctl
+       {
+               "OpenFirmware",
+               strategy,
+               (int (*)(struct open_file *, ...))nodev,
+               devclose,
+               noioctl
+       }
 };
 int ndevs = sizeof ofdevsw / sizeof ofdevsw[0];
 
@@ -214,13 +218,6 @@
 char opened_name[256];
 int floppyboot;
 
-static u_long
-get_long(const void *p)
-{
-       const unsigned char *cp = p;
-
-       return cp[0] | (cp[1] << 8) | (cp[2] << 16) | (cp[3] << 24);
-}
 /************************************************************************
  *
  * The rest of this was taken from arch/sparc64/scsi/sun_disklabel.c
@@ -326,15 +323,9 @@
 search_label(struct of_dev *devp, u_long off, char *buf,
             struct disklabel *lp, u_long off0)
 {
-       size_t read;
-       struct mbr_partition *p;
-       int i;
-       u_long poff;
-       static int recursion;
-
+       size_t readsize;
        struct disklabel *dlp;
        struct sun_disklabel *slp;
-       int error;
 
        /* minimal requirements for archtypal disk label */
        if (lp->d_secperunit == 0)
@@ -344,8 +335,8 @@
                lp->d_partitions[0].p_size = 0x1fffffff;
        lp->d_partitions[0].p_offset = 0;
 
-       if (strategy(devp, F_READ, LABELSECTOR, DEV_BSIZE, buf, &read)
-           || read != DEV_BSIZE)
+       if (strategy(devp, F_READ, LABELSECTOR, DEV_BSIZE, buf, &readsize)
+           || readsize != DEV_BSIZE)
                return ("Cannot read label");
        /* Check for a NetBSD disk label. */
        dlp = (struct disklabel *) (buf + LABELOFFSET);
@@ -379,8 +370,8 @@
        } b;
        struct disklabel label;
        int handle, part, try = 0;
-       size_t read;
-       char *errmsg = NULL, *pp, savedpart = 0;
+       size_t readsize;
+       char *errmsg = NULL, *pp = NULL, savedpart = 0;
        int error = 0;
 



Home | Main Index | Thread Index | Old Index