From owner-svn-src-all@FreeBSD.ORG Sat Jan 9 07:45:10 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 63C0C1065670; Sat, 9 Jan 2010 07:45:10 +0000 (UTC) (envelope-from gleb.kurtsou@gmail.com) Received: from mail-ew0-f213.google.com (mail-ew0-f213.google.com [209.85.219.213]) by mx1.freebsd.org (Postfix) with ESMTP id 4AC988FC13; Sat, 9 Jan 2010 07:45:09 +0000 (UTC) Received: by ewy5 with SMTP id 5so8814822ewy.14 for ; Fri, 08 Jan 2010 23:45:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=uC8beMhbuB7ZObAcY/BGmDEA4tjjp9qI3HlgelK2bX8=; b=A9vJOpMSRmA69PYbgdqQafV2rT4JK7zeRzErgD/QeQdS/U3VHOa20htAZiwmesF+YQ Rq2qR4FXRu6ceKLJzbpCdw9T6yarc+1zNCyNRgEp3/Zi47OGveapUNXGQQfZIsVs5Ftd QbTZU7pbaqCWKljnPh8MFOCNEskZJHVmfIDhI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=wFG7p5DSIayrWDu+iPraoVed6zr1MubqgpSP6z9EfCYu09T0Egod13mwZyBbdw8qz2 RwhYGCzK3/cYZ3hBjPwleFGv3rXfwmQEd7vEHafNMLwdB2lwcGHofnjSNhdu70SM2LgO UA0zQshbXS96IxXItdsyV99eTdc1iBfOk8uPE= Received: by 10.213.0.151 with SMTP id 23mr424398ebb.43.1263023101363; Fri, 08 Jan 2010 23:45:01 -0800 (PST) Received: from localhost (lan-78-157-90-54.vln.skynet.lt [78.157.90.54]) by mx.google.com with ESMTPS id 13sm2227517ewy.9.2010.01.08.23.45.00 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 08 Jan 2010 23:45:00 -0800 (PST) Date: Sat, 9 Jan 2010 09:44:48 +0200 From: Gleb Kurtsou To: Jaakko Heinonen Message-ID: <20100109074448.GA1865@tops.skynet.lt> References: <201001080757.o087vhrr009799@svn.freebsd.org> <20100109051536.R57595@delplex.bde.org> <20100108214821.GA985@a91-153-117-195.elisa-laajakaista.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20100108214821.GA985@a91-153-117-195.elisa-laajakaista.fi> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Bruce Evans Subject: Re: svn commit: r201773 - head/sys/fs/tmpfs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jan 2010 07:45:10 -0000 On (08/01/2010 23:48), Jaakko Heinonen wrote: > > Thank you for looking at this. > > On 2010-01-09, Bruce Evans wrote: > > The current incorrect way is to use %d. Since ino_t happens to have > > type uint32_t and u_int happens to have type uint32_t on all supported > > machines, %u would work but %d gives undefined behaviour when the > > value exceeds INT_MAX. > > > > The simplest fix is to use u_int and %u. > > > > > + u_quad_t size_max; There is also kern/138367 which tries to address the same issue, although in a bit different way. It also introduces maximum file size, fixes possible nodes and pages overflows. Thanks, Gleb > > Even larger indentation error, as above. > > Does following patch look reasonable? > > - Fix style bugs introduced in r201773. > - Change the type of nodes_max to u_int and use "%u" format string to > convert its value. > > %%% > Index: sys/fs/tmpfs/tmpfs_vfsops.c > =================================================================== > --- sys/fs/tmpfs/tmpfs_vfsops.c (revision 201818) > +++ sys/fs/tmpfs/tmpfs_vfsops.c (working copy) > @@ -185,8 +185,8 @@ tmpfs_mount(struct mount *mp) > ino_t nodes; > int error; > /* Size counters. */ > - ino_t nodes_max; > - u_quad_t size_max; > + u_int nodes_max; > + u_quad_t size_max; > > /* Root node attributes. */ > uid_t root_uid; > @@ -223,7 +223,7 @@ tmpfs_mount(struct mount *mp) > if (mp->mnt_cred->cr_ruid != 0 || > vfs_scanopt(mp->mnt_optnew, "mode", "%ho", &root_mode) != 1) > root_mode = va.va_mode; > - if (vfs_scanopt(mp->mnt_optnew, "inodes", "%d", &nodes_max) != 1) > + if (vfs_scanopt(mp->mnt_optnew, "inodes", "%u", &nodes_max) != 1) > nodes_max = 0; > if (vfs_scanopt(mp->mnt_optnew, "size", "%qu", &size_max) != 1) > size_max = 0; > @@ -239,7 +239,7 @@ tmpfs_mount(struct mount *mp) > * allowed to use, based on the maximum size the user passed in > * the mount structure. A value of zero is treated as if the > * maximum available space was requested. */ > - if (size_max < PAGE_SIZE || size_max > (SIZE_MAX - PAGE_SIZE)) > + if (size_max < PAGE_SIZE || size_max > SIZE_MAX - PAGE_SIZE) > pages = SIZE_MAX; > else > pages = howmany(size_max, PAGE_SIZE); > %%% > > -- > Jaakko > _______________________________________________ > svn-src-head@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/svn-src-head > To unsubscribe, send any mail to "svn-src-head-unsubscribe@freebsd.org"