From owner-freebsd-bugs Wed Jun 26 17:57:44 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 081B437D56A for ; Wed, 26 Jun 2002 17:50:02 -0700 (PDT) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.4/8.12.4) with ESMTP id g5R0o1JU095084 for ; Wed, 26 Jun 2002 17:50:01 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.4/8.12.4/Submit) id g5R0o1VR095083; Wed, 26 Jun 2002 17:50:01 -0700 (PDT) Received: from xkulesh.vol.cz (xkulesh.vol.cz [195.250.154.106]) by hub.freebsd.org (Postfix) with ESMTP id DB8D637D0DF for ; 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 ; 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 Reply-To: Dan Lukes To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/39906: cleaning sbin/newfs code from warnings Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >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