From owner-cvs-all@FreeBSD.ORG Sun Jan 27 06:35:33 2008 Return-Path: Delivered-To: cvs-all@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 69E8716A418; Sun, 27 Jan 2008 06:35:33 +0000 (UTC) (envelope-from yar@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 52C4313C4CE; Sun, 27 Jan 2008 06:35:33 +0000 (UTC) (envelope-from yar@FreeBSD.org) Received: from freefall.freebsd.org (yar@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m0R6ZXFv066160; Sun, 27 Jan 2008 06:35:33 GMT (envelope-from yar@freefall.freebsd.org) Received: (from yar@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m0R6ZXvJ066159; Sun, 27 Jan 2008 06:35:33 GMT (envelope-from yar) Date: Sun, 27 Jan 2008 06:35:33 +0000 From: Yar Tikhiy To: John Birrell Message-ID: <20080127063533.GA62684@freefall.freebsd.org> References: <200801270119.m0R1JlKn096256@repoman.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200801270119.m0R1JlKn096256@repoman.freebsd.org> User-Agent: Mutt/1.4.2.3i Cc: cvs-src@FreeBSD.org, src-committers@FreeBSD.org, rwatson@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/usr.sbin/setfmac setfmac.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Jan 2008 06:35:33 -0000 On Sun, Jan 27, 2008 at 01:19:47AM +0000, John Birrell wrote: > jb 2008-01-27 01:19:47 UTC > > FreeBSD src repository > > Modified files: > usr.sbin/setfmac setfmac.c > Log: > fts_pathlen is now a size_t rather than an int so a cast is needed. > I'm not sure why warn() and err() string formatted variables need > to be right-justified. > > Revision Changes Path > 1.10 +6 -6 src/usr.sbin/setfmac/setfmac.c Thank you for fixing this! The format strings in question might just have a bug in them. My guess is that the author of the format strings feared that fts_path might not be NUL-terminated, so he explicitly specified variable precision of fts_pathlen; but he forgot to left-justify the field as well. In fact, fts_path in a fresh FTSENT just returned by fts_read() is always NUL-terminated. (See fts(3).) Tricks with fts_pathlen are necessary only if referring to old, saved FTSENTs, but this is dangerous and unportable anyway. setfmac seems to refer to fresh FTSENTs only, so the format can be changed safely from "%.*s" to just "%s". It will eliminate the fts_pathlen arguments to the printf-like functions completely. It was Robert Watson who committed the lines to setfmac.c, according to cvs annotate, so I added him to Cc:. Robert, do you think it's OK to simplify the format strings by changing "%.*s" to "%s" along with removing the fts_pathlen arguments? E.g.: case FTS_NS: - err(1, "traversing %.*s", ftsent->fts_pathlen, - ftsent->fts_path); + err(1, "traversing %s", ftsent->fts_path); default: Thanks! Yar