WARNSfy and fix dumb bugs noticed by warnings.

This commit is contained in:
tsutsui 2011-05-21 15:50:42 +00:00
parent 99c9ae6dfa
commit c95f237aba
10 changed files with 54 additions and 59 deletions

View File

@ -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 @@ OF_claim(void *virt, u_int size, u_int align)
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 @@ OF_claim(void *virt, u_int size, u_int align)
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;

View File

@ -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 @@ S= ${CURDIR}/../../../..
# 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

View File

@ -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 @@ bootoptions(const char *ap, char *loaddev, char *kernel, char *options)
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 @@ ksyms_copyout(void **ssym, void **esym)
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 @@ parse_boot_config(char *cfg, size_t len)
static void
check_boot_config(void)
{
int fd, err, off, len;
int fd, off, len;
struct stat st;
char *bc;
@ -515,7 +514,7 @@ main(void *ofw)
for (;; *kernel = '\0') {
if (boothowto & RB_ASKNAME) {
char *cp, cmdline[PROM_MAX_PATH];
char cmdline[PROM_MAX_PATH];
printf("Boot: ");
gets(cmdline);

View File

@ -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_memcpy(void *, const void *, size_t);
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);

View File

@ -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 @@ net_close(struct of_dev *op)
netif_close(netdev_sock);
netdev_sock = -1;
}
return 0;
}
static void
@ -178,14 +181,13 @@ net_mountroot_bootp(void)
}
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);
}

View File

@ -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 */

View File

@ -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 @@ netif_open(void *machdep_hint)
{
struct of_dev *op = machdep_hint;
struct iodesc *io;
int fd, error;
char addr[32];
#ifdef NETIF_DEBUG
printf("netif_open...");

View File

@ -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 @@ devclose(struct open_file *of)
#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 @@ static struct of_dev ofdev = {
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 @@ static char *
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 @@ search_label(struct of_dev *devp, u_long off, char *buf,
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 @@ devopen(struct open_file *of, const char *name, char **file)
} 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;
if (ofdev.handle != -1)
@ -475,8 +466,8 @@ open_again:
/* First try to find a disklabel without MBR partitions */
DPRINTF(("devopen: trying to read disklabel\n"));
if (strategy(&ofdev, F_READ,
LABELSECTOR, DEV_BSIZE, b.buf, &read) != 0
|| read != DEV_BSIZE
LABELSECTOR, DEV_BSIZE, b.buf, &readsize) != 0
|| readsize != DEV_BSIZE
|| (errmsg = getdisklabel(b.buf, &label))) {
if (errmsg) {
DPRINTF(("devopen: getdisklabel returned %s\n",
@ -536,7 +527,7 @@ open_again:
}
#ifdef NETBOOT
if (!strcmp(b.buf, "network")) {
if (error = net_open(&ofdev))
if ((error = net_open(&ofdev)) != 0)
goto bad;
ofdev.type = OFDEV_NET;
@ -546,14 +537,14 @@ open_again:
if (!strncmp(*file,"/tftp:",6)) {
*file += 6;
memcpy(&file_system[0], &file_system_tftp, sizeof file_system[0]);
if (net_tftp_bootp((int**)&of->f_devdata)) {
if (net_tftp_bootp(of->f_devdata)) {
net_close(&ofdev);
goto bad;
}
root_fs_quickseekable = false;
} else {
memcpy(&file_system[0], &file_system_nfs, sizeof file_system[0]);
if (error = net_mountroot()) {
if ((error = net_mountroot()) != 0) {
net_close(&ofdev);
goto bad;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: openfirm.h,v 1.4 2009/05/18 11:39:30 nakayama Exp $ */
/* $NetBSD: openfirm.h,v 1.5 2011/05/21 15:50:42 tsutsui Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@ -58,7 +58,8 @@ int OF_seek(u_int handle, uint64_t pos);
void* OF_claim(void *, u_int, u_int);
void OF_release(void *, u_int);
int OF_milliseconds(void);
void OF_chain(void *, u_int, void (*)(), void *, u_int);
void OF_chain(void *, u_int,
void (*)(int, int, int (*)(void *), void *, u_int), void *, u_int);
int OF_peer(int);
int OF_child(int);
vaddr_t OF_claim_virt(vaddr_t, int);

View File

@ -1,4 +1,4 @@
/* $NetBSD: promlib.c,v 1.2 2008/04/28 20:23:36 martin Exp $ */
/* $NetBSD: promlib.c,v 1.3 2011/05/21 15:50:42 tsutsui Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@ -37,6 +37,9 @@
#include <sys/types.h>
#include <machine/promlib.h>
#include <lib/libsa/stand.h>
#include <lib/libkern/libkern.h>
#include "openfirm.h"
@ -139,7 +142,7 @@ prom_init(void)
OF_initialize();
memset(promops, 0, sizeof(promops));
memset(&promops, 0, sizeof(promops));
/* Access to boot arguments */
promops.po_bootpath = openfirmware_bootpath;