Date: Wed, 26 Jun 2002 23:33:09 +0200 (CEST) From: Dan Lukes <dan@obluda.cz> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/39906: cleaning sbin/newfs code from warnings Message-ID: <200206262133.g5QLX9Hm059297@obluda.cz>
next in thread | raw e-mail | index | archive | help
>Number: 39906
>Category: bin
>Synopsis: cleaning sbin/newfs code from warnings
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Wed Jun 26 17:50:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Dan Lukes
>Release: FreeBSD 4.6-STABLE i386
>Organization:
Obludarium
>Environment:
System: FreeBSD xkulesh.vol.cz 4.6-STABLE FreeBSD
src/sbin/newfs/newfs.c,v 1.30.2.8 2001/12/14 09:03:48
src/sbin/newfs/mkfs.c,v 1.29.2.6 2001/09/21 19:15:21
>Description:
sbin/newfs/newfs.c: In function `main':
232: warning: `fsi' might be used uninitialized in this function
233: warning: `cp' might be used uninitialized in this function
fsi IS used uninitialized under certain condition
cp is NOT used uninitialized
mfs is set when program is invoked under name containing
string 'mfs' (mount_mfs for example)
disktype contain the '-T' option value
1. when (mfs && disktype != NULL) then fsi is NEVER initialized
2. if (mfs && !strcmp(special, "swap") then
"goto havelabel" skip fsi initialisation also
despite of it, close(fsi) IS called.
mkfs(pp, special, fsi, fso) is called too, but it doesn't use fsi in mfs
mode
================================================================
there are some non-critical warnings also:
sbin/newfs/newfs.c:
626: warning: implicit declaration of function `rewritelabel'
warning: return-type defaults to `int'
In function `rewritelabel':
702: warning: `return' with no value, in function returning non-void
710: warning: control reaches end of non-void function
1. missing 'void' in rewritelabel declaration
2. rewritelabel used before declared
sbin/newfs/mkfs.c: In function `started':
1203: warning: implicit declaration of function `fatal'
fatal really used without declaration
>How-To-Repeat:
N/A
>Fix:
--- src/sbin/newfs/newfs.c.ORIG Mon Dec 17 00:03:01 2001
+++ src/sbin/newfs/newfs.c Wed Jun 26 23:20:46 2002
@@ -216,6 +216,8 @@
extern void mkfs __P((struct partition *, char *, int, int));
static void usage __P((void));
+void rewritelabel __P((char *, int, register struct disklabel *));
+
int
main(argc, argv)
int argc;
@@ -229,8 +231,8 @@
struct partition oldpartition;
struct stat st;
struct statfs *mp;
- int fsi, fso, len, n, vflag;
- char *cp, *s1, *s2, *special, *opstring;
+ int fsi = -1, fso, len, n, vflag;
+ char *cp = NULL, *s1, *s2, *special, *opstring;
#ifdef MFS
struct vfsconf vfc;
int error;
@@ -626,7 +628,8 @@
rewritelabel(special, fso, lp);
if (!Nflag)
close(fso);
- close(fsi);
+ if ( fsi >= 0 )
+ close(fsi);
#ifdef MFS
if (mfs) {
struct mfs_args args;
@@ -692,6 +695,7 @@
return (&lab);
}
+void
rewritelabel(s, fd, lp)
char *s;
int fd;
--- src/sbin/newfs/mkfs.c.ORIG Mon Sep 24 19:58:55 2001
+++ src/sbin/newfs/mkfs.c Wed Jun 26 23:28:01 2002
@@ -168,6 +168,12 @@
caddr_t realloc __P((char *, u_long));
#endif
+#if __STDC__
+void fatal(const char *fmt, ...);
+#else
+void fatal();
+#endif
+
int mfs_ppid = 0;
void
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200206262133.g5QLX9Hm059297>
