Subject: bin/14184: sbin/badsect with corrected style
To: None <gnats-bugs@gnats.netbsd.org>
From: Petri Koistinen <thoron@mb-u12ip016.mbnet.fi>
List: netbsd-bugs
Date: 10/07/2001 23:22:01
>Number: 14184
>Category: bin
>Synopsis: sbin/badsect with corrected style
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Sun Oct 07 13:23:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Petri Koistinen
>Release: NetBSD-current Sun Oct 7 23:17:48 EEST 2001
>Organization:
>Environment:
System: NetBSD mb-u12ip016.mbnet.fi 1.5Y NetBSD 1.5Y (SPEEDBALL) #14: Sun Oct 7 16:58:44 EEST 2001 thoron@mb-u10ip207.mbnet.fi:/usr/src/sys/arch/amiga/compile/SPEEDBALL amiga
Architecture: m68k
Machine: amiga
>Description:
Patch for sbin/badsect. Style improvement.
>How-To-Repeat:
>Fix:
Index: badsect.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/badsect/badsect.c,v
retrieving revision 1.20
diff -u -r1.20 badsect.c
--- badsect.c 2001/08/17 02:18:46 1.20
+++ badsect.c 2001/10/07 20:17:48
@@ -1,4 +1,4 @@
-/* $NetBSD: badsect.c,v 1.20 2001/08/17 02:18:46 lukem Exp $ */
+/* $NetBSD: badsect.c,v 1.20 2001/08/17 02:18:46 lukem Exp $ */
/*
* Copyright (c) 1981, 1983, 1993
@@ -34,18 +34,18 @@
*/
#include <sys/cdefs.h>
-#ifndef lint
+#ifndef __lint
__COPYRIGHT("@(#) Copyright (c) 1981, 1983, 1993\n\
The Regents of the University of California. All rights reserved.\n");
-#endif /* not lint */
+#endif /* !__lint */
-#ifndef lint
+#ifndef __lint
#if 0
static char sccsid[] = "@(#)badsect.c 8.2 (Berkeley) 5/4/95";
#else
__RCSID("$NetBSD: badsect.c,v 1.20 2001/08/17 02:18:46 lukem Exp $");
#endif
-#endif /* not lint */
+#endif /* !__lint */
/*
* badsect
@@ -66,40 +66,38 @@
#include <ufs/ffs/fs.h>
#include <ufs/ffs/ffs_extern.h>
+#include <err.h>
#include <fcntl.h>
#include <paths.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <err.h>
union {
- struct fs fs;
- char fsx[SBSIZE];
+ struct fs fs;
+ char fsx[SBSIZE];
} ufs;
-#define sblock ufs.fs
union {
- struct cg cg;
- char cgx[MAXBSIZE];
+ struct cg cg;
+ char cgx[MAXBSIZE];
} ucg;
-#define acg ucg.cg
-struct fs *fs;
-int fso, fsi;
-int errs;
-long dev_bsize = 1;
-int needswap = 0;
+#define sblock ufs.fs
+#define acg ucg.cg
+struct fs *fs;
+int fso, fsi;
+int errs;
+long dev_bsize = 1;
+int needswap = 0;
char buf[MAXBSIZE];
-void rdfs __P((daddr_t, int, char *));
-int chkuse __P((daddr_t, int));
-int main __P((int, char *[]));
+void rdfs(daddr_t, int, char *);
+int chkuse(daddr_t, int);
+int main(int, char *[]);
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char *argv[])
{
daddr_t number;
struct stat stbuf, devstat;
@@ -107,8 +105,10 @@
DIR *dirp;
char name[MAXPATHLEN];
+ setprogname(argv[0]);
+
if (argc < 3) {
- (void) fprintf(stderr, "Usage: %s bbdir blkno [ blkno ]\n",
+ (void)fprintf(stderr, "Usage: %s bbdir blkno [ blkno ]\n",
getprogname());
exit(1);
}
@@ -118,12 +118,12 @@
if (stat(".", &stbuf) == -1)
err(1, "Cannot stat `%s'", argv[1]);
- (void) strcpy(name, _PATH_DEV);
+ (void)strcpy(name, _PATH_DEV);
if ((dirp = opendir(name)) == NULL)
err(1, "Cannot opendir `%s'", argv[1]);
while ((dp = readdir(dirp)) != NULL) {
- (void) snprintf(name, sizeof(name), "%s%s", _PATH_DEV,
+ (void)snprintf(name, sizeof(name), "%s%s", _PATH_DEV,
dp->d_name);
if (stat(name, &devstat) == -1)
err(1, "Cannot stat `%s'", name);
@@ -133,7 +133,7 @@
}
if (dp == NULL) {
closedir(dirp);
- errx(1, "Cannot find dev 0%o corresponding to %s",
+ errx(1, "Cannot find dev 0%o corresponding to %s",
stbuf.st_rdev, argv[1]);
}
@@ -142,9 +142,9 @@
* XXX - Assume that prepending an `r' will give us the name of
* the character device.
*/
- (void) snprintf(name, sizeof(name), "%sr%s", _PATH_DEV, dp->d_name);
+ (void)snprintf(name, sizeof(name), "%sr%s", _PATH_DEV, dp->d_name);
- closedir(dirp); /* now *dp is invalid */
+ closedir(dirp); /* now *dp is invalid */
if ((fsi = open(name, O_RDONLY)) == -1)
err(1, "Cannot open `%s'", argv[1]);
@@ -152,7 +152,7 @@
fs = &sblock;
rdfs(SBOFF, SBSIZE, (char *)fs);
if (fs->fs_magic != FS_MAGIC) {
- if(fs->fs_magic == bswap32(FS_MAGIC))
+ if (fs->fs_magic == bswap32(FS_MAGIC))
needswap = 1;
else
errx(1, "%s: bad superblock", name);
@@ -164,7 +164,7 @@
number = atoi(*argv);
if (chkuse(number, 1))
continue;
- if (mknod(*argv, S_IFMT|S_IRUSR|S_IWUSR,
+ if (mknod(*argv, S_IFMT | S_IRUSR | S_IWUSR,
dbtofsb(fs, number)) == -1) {
warn("Cannot mknod `%s'", *argv);
errs++;
@@ -176,28 +176,26 @@
}
int
-chkuse(blkno, cnt)
- daddr_t blkno;
- int cnt;
+chkuse(daddr_t blkno, int cnt)
{
int cg;
daddr_t fsbn, bn;
fsbn = dbtofsb(fs, blkno);
- if ((unsigned)(fsbn+cnt) > fs->fs_size) {
+ if ((unsigned)(fsbn + cnt) > fs->fs_size) {
warnx("block %d out of range of file system", blkno);
return (1);
}
cg = dtog(fs, fsbn);
if (fsbn < cgdmin(fs, cg)) {
- if (cg == 0 || (fsbn+cnt) > cgsblock(fs, cg)) {
+ if (cg == 0 || (fsbn + cnt) > cgsblock(fs, cg)) {
warnx("block %d in non-data area: cannot attach",
blkno);
return (1);
}
} else {
- if ((fsbn+cnt) > cgbase(fs, cg+1)) {
+ if ((fsbn + cnt) > cgbase(fs, cg + 1)) {
warnx("block %d in non-data area: cannot attach",
blkno);
return (1);
@@ -224,10 +222,7 @@
* read a block from the file system
*/
void
-rdfs(bno, size, bf)
- daddr_t bno;
- int size;
- char *bf;
+rdfs(daddr_t bno, int size, char *bf)
{
int n;
>Release-Note:
>Audit-Trail:
>Unformatted: