From dan@obluda.cz  Wed Jun 26 17:45:22 2002
Return-Path: <dan@obluda.cz>
Received: from xkulesh.vol.cz (xkulesh.vol.cz [195.250.154.106])
	by hub.freebsd.org (Postfix) with ESMTP id DB8D637D0DF
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 26 Jun 2002 17:37:33 -0700 (PDT)
Received: from obluda.cz (localhost [127.0.0.1])
	by xkulesh.vol.cz (8.12.3/8.12.3) with ESMTP id g5R0bVU1061818
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 27 Jun 2002 02:37:31 +0200 (CEST)
	(envelope-from dan@obluda.cz)
Received: (from root@localhost)
	by obluda.cz (8.12.4/8.12.4/Submit) id g5QLX9Hm059297;
	Wed, 26 Jun 2002 23:33:09 +0200 (CEST)
Message-Id: <200206262133.g5QLX9Hm059297@obluda.cz>
Date: Wed, 26 Jun 2002 23:33:09 +0200 (CEST)
From: Dan Lukes <dan@obluda.cz>
Reply-To: Dan Lukes <dan@obluda.cz>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: cleaning sbin/newfs code from warnings
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         39906
>Category:       bin
>Synopsis:       cleaning sbin/newfs code from warnings
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    johan
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jun 26 17:50:01 PDT 2002
>Closed-Date:    Thu Nov 13 10:57:18 PST 2003
>Last-Modified:  Thu Nov 13 10:57:18 PST 2003
>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:
Responsible-Changed-From-To: freebsd-bugs->johan 
Responsible-Changed-By: johan 
Responsible-Changed-When: Sun Apr 13 13:55:43 PDT 2003 
Responsible-Changed-Why:  
I'll take a look at this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=39906 
State-Changed-From-To: open->closed 
State-Changed-By: johan 
State-Changed-When: Thu Nov 13 10:56:04 PST 2003 
State-Changed-Why:  
newfs has been rewritten in currentand all this 
stuff is fixed/removed. We normaly do not remove 
warnings in stable and therefore I'm closing this PR. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=39906 
>Unformatted:
