From owner-freebsd-bugs Thu Jul 20 16:11:19 1995 Return-Path: bugs-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.11/8.6.6) id QAA28315 for bugs-outgoing; Thu, 20 Jul 1995 16:11:19 -0700 Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.34]) by freefall.cdrom.com (8.6.11/8.6.6) with ESMTP id QAA28308 for ; Thu, 20 Jul 1995 16:11:15 -0700 Received: (from bde@localhost) by godzilla.zeta.org.au (8.6.9/8.6.9) id JAA10420; Fri, 21 Jul 1995 09:08:47 +1000 Date: Fri, 21 Jul 1995 09:08:47 +1000 From: Bruce Evans Message-Id: <199507202308.JAA10420@godzilla.zeta.org.au> To: bde@zeta.org.au, terry@cs.weber.edu Subject: Re: possible ffs_vget() race condition Cc: bugs@freebsd.org Sender: bugs-owner@freebsd.org Precedence: bulk [Cc list trimmed] >> The shift method has the advantage of giving the correct result :-). >> You meant ((~(u_quad_t)0) >> 1). This depends on u_quad_t being >> larger than int. >I don't understand why this would depend on quad being larger than int; >because the naked 1 is of type int? I should have said larger or the same size as an int. ~(foo_t)0 is usually wrong if foo_t is shorter than an int (it is the same as ~0 because of the broken ANSI value-preserving promotion rules), so using it gives a bad example for beginners to follow. ((foo_t)(-1)) always works although you may need further casts (e.g., on the i386, (u_short)(-1) is (int)0xffff, so shifting right 1 works right but shifting left 16 and then shifting right gives surprising results. The type of the shift count doesn't affect the type of the result. Bruce