From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Daniel Colascione Newsgroups: gmane.emacs.devel Subject: Re: Set operations on bool-vectors Date: Sat, 21 Sep 2013 00:38:43 -0700 Message-ID: <523D4D03.7010200@dancol.org> References: <523CD363.6020400@dancol.org> <87a9j6bp90.fsf@igel.home> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="jlK94wENVqQM3SEI0ERhek0e7nJtCtrS4" X-Trace: ger.gmane.org 1379749210 23257 80.91.229.3 (21 Sep 2013 07:40:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 21 Sep 2013 07:40:10 +0000 (UTC) Cc: Emacs development discussions To: Andreas Schwab Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Sep 21 09:40:13 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VNHnX-0003YD-0v for ged-emacs-devel@m.gmane.org; Sat, 21 Sep 2013 09:40:11 +0200 Original-Received: from localhost ([::1]:58866 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VNHnW-0006I1-AX for ged-emacs-devel@m.gmane.org; Sat, 21 Sep 2013 03:40:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58870) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VNHnN-0006DL-Us for emacs-devel@gnu.org; Sat, 21 Sep 2013 03:40:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VNHnH-0005Qr-In for emacs-devel@gnu.org; Sat, 21 Sep 2013 03:40:01 -0400 Original-Received: from dancol.org ([2600:3c01::f03c:91ff:fedf:adf3]:46033) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VNHnH-0005Qn-CJ for emacs-devel@gnu.org; Sat, 21 Sep 2013 03:39:55 -0400 Original-Received: from c-76-22-66-162.hsd1.wa.comcast.net ([76.22.66.162] helo=[192.168.1.52]) by dancol.org with esmtpsa (TLS1.0:DHE_RSA_CAMELLIA_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1VNHnE-0003NB-BA; Sat, 21 Sep 2013 00:39:52 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 In-Reply-To: <87a9j6bp90.fsf@igel.home> X-Enigmail-Version: 1.5.2 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2600:3c01::f03c:91ff:fedf:adf3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:163529 Archived-At: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --jlK94wENVqQM3SEI0ERhek0e7nJtCtrS4 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 9/21/13 12:36 AM, Andreas Schwab wrote: > Daniel Colascione writes: >=20 >> +static >> +ptrdiff_t >> +bool_vector_payload_bytes (EMACS_INT length) >> +{ >> + EMACS_INT exact_needed_bytes; >> + EMACS_INT needed_bytes; >> + >> + exact_needed_bytes =3D (length + CHAR_BIT - 1) / CHAR_BIT; >> + needed_bytes =3D (exact_needed_bytes + sizeof (size_t) - 1) >> + / sizeof (size_t); >> + >> + needed_bytes *=3D sizeof (size_t); >=20 > Please check for overflow.=20 It can't overflow. The initial number of bits comes from a Lisp integer, which has a bit less range than an int. What exactly is the routine supposed to do if the value overflows? > Also, the return type should be EMACS_INT, > not ptrdiff_t. Well, vector_nbytes works with ptrdiff_t, and the allocation code works in EMACS_INT. I'm not sure the distinction actually matters in this case= =2E --jlK94wENVqQM3SEI0ERhek0e7nJtCtrS4 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (Darwin) iQIcBAEBAgAGBQJSPU0JAAoJEMAaIROpHW7IO5kP/02x4K4wmZzEoA06cOBRecTR q8/snROPg74gG9dADk/ku2/jUPIb+eLbG+hdv7g1HR5ZMX4WwoLK6e5bakZZtAFf bLaRRCDyOJLKMqUqG3hm57Vfw04m2nk15QmOMcoyor6LLB8xnADDAjaCYbxDY7vh fhAXrBX4W2UMJf7Opc7ekyGNzDCY88NTEKatV1UVDBMWdHyyvme4YYwRnXIUqWy2 SK2e4FrsWKnwhRzaw+AbjX8Uzifh3SZMJYBtyrnFF6o928rvs7quv6ttLS3vLCRN EnSuYYc3Iqs+PPaTAiBt3eI+eDr71VHgB3T6meWfu24XjjUJ8ja/3FRLyCWMtJGT yk5EA4SPqWYKT2tkrtiyE+yU+SXxlnGdYD0xSkngc1XCYC+sWmQ1JG1I+4Dwdhsb tALNAahEwnQ8vKEJUMC4cfMpOvYMGv3lwxr4zfaa+0CwN7rPw+baLHCskR4D3l8Y fe7+81MTSHKWKkNiASPk8cvXPH0pNTnnC0PeGIsWMbeyrIpMLAbBDhJMLnaPsEHo x/KlpH7ZmdzRv4y1TETIn8bmtpzcrKFlFrHHHOe3lV4itPA0qgJhrrEQWwqSkpD6 l3+WWMrEj+iKCCyOUL3Oq8wBPrKD19x93G9UwiQ6N6tzFlQTxaeZms3WEsdRNnbc yi+gUjZzLqG0uqqC5hLA =TxjT -----END PGP SIGNATURE----- --jlK94wENVqQM3SEI0ERhek0e7nJtCtrS4--