summaryrefslogtreecommitdiffstats
path: root/usr.bin/fstat
diff options
context:
space:
mode:
authordwmalone <dwmalone@FreeBSD.org>2004-06-29 21:28:09 +0000
committerdwmalone <dwmalone@FreeBSD.org>2004-06-29 21:28:09 +0000
commit82c790f916d0e107de65511b0c9a912ed613d3c1 (patch)
tree85aee1e52cf7ca381c86b5b46cf3e8d89a619ee8 /usr.bin/fstat
parent7091d2d55fe3cc852134ddc00429904db47e8c72 (diff)
downloadFreeBSD-src-82c790f916d0e107de65511b0c9a912ed613d3c1.zip
FreeBSD-src-82c790f916d0e107de65511b0c9a912ed613d3c1.tar.gz
1) ANSIfy.
2) Use %p to print a pointer. 3) Use longs for fileids and ino to avoid comparing signed and unsigned. 4) Make the KVM_READ macro a little more cranky. 5) Set WARNS while I'm here.
Diffstat (limited to 'usr.bin/fstat')
-rw-r--r--usr.bin/fstat/Makefile1
-rw-r--r--usr.bin/fstat/cd9660.c4
-rw-r--r--usr.bin/fstat/fstat.c52
-rw-r--r--usr.bin/fstat/fstat.h5
-rw-r--r--usr.bin/fstat/msdosfs.c4
5 files changed, 21 insertions, 45 deletions
diff --git a/usr.bin/fstat/Makefile b/usr.bin/fstat/Makefile
index 80c61c7..1be1d7f 100644
--- a/usr.bin/fstat/Makefile
+++ b/usr.bin/fstat/Makefile
@@ -7,5 +7,6 @@ DPADD= ${LIBKVM}
LDADD= -lkvm
BINGRP= kmem
BINMODE=2555
+WARNS?= 6
.include <bsd.prog.mk>
diff --git a/usr.bin/fstat/cd9660.c b/usr.bin/fstat/cd9660.c
index c289a7d..8e4be03 100644
--- a/usr.bin/fstat/cd9660.c
+++ b/usr.bin/fstat/cd9660.c
@@ -57,9 +57,7 @@ __FBSDID("$FreeBSD$");
#include "fstat.h"
int
-isofs_filestat(vp, fsp)
- struct vnode *vp;
- struct filestat *fsp;
+isofs_filestat(struct vnode *vp, struct filestat *fsp)
{
struct iso_node isonode;
diff --git a/usr.bin/fstat/fstat.c b/usr.bin/fstat/fstat.c
index b329ec8..7ab2857 100644
--- a/usr.bin/fstat/fstat.c
+++ b/usr.bin/fstat/fstat.c
@@ -156,9 +156,7 @@ void usage(void);
int
-main(argc, argv)
- int argc;
- char **argv;
+main(int argc, char **argv)
{
struct passwd *passwd;
int arg, ch, what;
@@ -320,8 +318,7 @@ int Pid;
* print open files attributed to this process
*/
void
-dofiles(kp)
- struct kinfo_proc *kp;
+dofiles(struct kinfo_proc *kp)
{
int i;
struct file file;
@@ -408,8 +405,7 @@ dofiles(kp)
}
void
-dommap(kp)
- struct kinfo_proc *kp;
+dommap(struct kinfo_proc *kp)
{
vm_map_t map;
struct vmspace vmspace;
@@ -466,10 +462,7 @@ dommap(kp)
}
void
-vtrans(vp, i, flag)
- struct vnode *vp;
- int i;
- int flag;
+vtrans(struct vnode *vp, int i, int flag)
{
struct vnode vn;
struct filestat fst;
@@ -573,9 +566,7 @@ vtrans(vp, i, flag)
}
int
-ufs_filestat(vp, fsp)
- struct vnode *vp;
- struct filestat *fsp;
+ufs_filestat(struct vnode *vp, struct filestat *fsp)
{
struct inode inode;
@@ -607,9 +598,7 @@ ufs_filestat(vp, fsp)
}
int
-devfs_filestat(vp, fsp)
- struct vnode *vp;
- struct filestat *fsp;
+devfs_filestat(struct vnode *vp, struct filestat *fsp)
{
struct devfs_dirent devfs_dirent;
struct mount mount;
@@ -640,9 +629,7 @@ devfs_filestat(vp, fsp)
}
int
-nfs_filestat(vp, fsp)
- struct vnode *vp;
- struct filestat *fsp;
+nfs_filestat(struct vnode *vp, struct filestat *fsp)
{
struct nfsnode nfsnode;
mode_t mode;
@@ -690,8 +677,7 @@ nfs_filestat(vp, fsp)
char *
-getmnton(m)
- struct mount *m;
+getmnton(struct mount *m)
{
static struct mount mount;
static struct mtab {
@@ -718,10 +704,7 @@ getmnton(m)
}
void
-pipetrans(pi, i, flag)
- struct pipe *pi;
- int i;
- int flag;
+pipetrans(struct pipe *pi, int i, int flag)
{
struct pipe pip;
char rw[3];
@@ -750,9 +733,7 @@ bad:
}
void
-socktrans(sock, i)
- struct socket *sock;
- int i;
+socktrans(struct socket *sock, int i)
{
static const char *stypename[] = {
"unused", /* 0 */
@@ -879,15 +860,14 @@ bad:
* associated dev_t
*/
dev_t
-dev2udev(dev)
- struct cdev *dev;
+dev2udev(struct cdev *dev)
{
struct cdev si;
if (KVM_READ(dev, &si, sizeof si)) {
return si.si_udev;
} else {
- dprintf(stderr, "can't convert cdev *%x to a dev_t\n", dev);
+ dprintf(stderr, "can't convert cdev *%p to a dev_t\n", dev);
return -1;
}
}
@@ -897,8 +877,7 @@ dev2udev(dev)
* print name of protocol number
*/
void
-getinetproto(number)
- int number;
+getinetproto(int number)
{
static int isopen;
struct protoent *pe;
@@ -912,8 +891,7 @@ getinetproto(number)
}
int
-getfname(filename)
- const char *filename;
+getfname(const char *filename)
{
struct stat statbuf;
DEVS *cur;
@@ -934,7 +912,7 @@ getfname(filename)
}
void
-usage()
+usage(void)
{
(void)fprintf(stderr,
"usage: fstat [-fmnv] [-p pid] [-u user] [-N system] [-M core] [file ...]\n");
diff --git a/usr.bin/fstat/fstat.h b/usr.bin/fstat/fstat.h
index cf4e15a..dda8bbf 100644
--- a/usr.bin/fstat/fstat.h
+++ b/usr.bin/fstat/fstat.h
@@ -40,14 +40,15 @@
* a kvm_read that returns true if everything is read
*/
#define KVM_READ(kaddr, paddr, len) \
- (kvm_read(kd, (u_long)(kaddr), (char *)(paddr), (len)) == (len))
+ ((len) < SSIZE_MAX && \
+ kvm_read(kd, (u_long)(kaddr), (char *)(paddr), (len)) == (ssize_t)(len))
#define dprintf if (vflg) fprintf
typedef struct devs {
struct devs *next;
long fsid;
- ino_t ino;
+ long ino;
const char *name;
} DEVS;
diff --git a/usr.bin/fstat/msdosfs.c b/usr.bin/fstat/msdosfs.c
index dda7d17..5bae63e 100644
--- a/usr.bin/fstat/msdosfs.c
+++ b/usr.bin/fstat/msdosfs.c
@@ -73,9 +73,7 @@ struct dosmount {
};
int
-msdosfs_filestat(vp, fsp)
- struct vnode *vp;
- struct filestat *fsp;
+msdosfs_filestat(struct vnode *vp, struct filestat *fsp)
{
struct denode denode;
static struct dosmount *mounts;
OpenPOWER on IntegriCloud