From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60154) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJ872-0005UG-DS for qemu-devel@nongnu.org; Wed, 04 Feb 2015 17:07:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YJ86z-0006OF-6l for qemu-devel@nongnu.org; Wed, 04 Feb 2015 17:07:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49425) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJ86y-0006O7-Uz for qemu-devel@nongnu.org; Wed, 04 Feb 2015 17:07:53 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t14M7pMK017183 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 4 Feb 2015 17:07:52 -0500 Message-ID: <54D29836.9040105@redhat.com> Date: Wed, 04 Feb 2015 15:07:50 -0700 From: Eric Blake MIME-Version: 1.0 References: <1423079623-4253-1-git-send-email-mreitz@redhat.com> <54D2965B.3040309@redhat.com> In-Reply-To: <54D2965B.3040309@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="RUJXrXvjauM13XgGWEPNV0HAjVbe9GGPA" Subject: Re: [Qemu-devel] [PATCH] qcow2: Rewrite qcow2_alloc_bytes() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --RUJXrXvjauM13XgGWEPNV0HAjVbe9GGPA Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 02/04/2015 02:59 PM, Eric Blake wrote: >> qcow2_alloc_bytes() is a function with insufficient error handling and= >> an unnecessary goto. This patch rewrites it. >> - redo: >> + >> free_in_cluster =3D s->cluster_size - >> offset_into_cluster(s, s->free_byte_offset); >=20 > Based on [0], free_in_cluster is either s->cluster_size > (s->free_byte_offset was 0 and we have no tail) or smaller than > s->cluster_size (s->free_byte_offset was non-zero). Maybe even worth an assert? assert(free_in_cluster < s->cluster_size + !s->free_byte_offset); --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --RUJXrXvjauM13XgGWEPNV0HAjVbe9GGPA 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 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJU0pg2AAoJEKeha0olJ0Nqz2EH/3rMp8ZqeJmDbY3LEh+AkfNV xN7Bn3teKSJILz6X1Uyzqj9kpNOLntYeDut8cDPSqiiY824qkB0kKevZobJY88E/ WrETcSVOk/N3F6E1+oQtKHjSQazfGIV0H5ivvCUz5HWJPMvpRDWjSP/Lx/d5k3v3 oSvSrsvu08qjVJ6ItmFyI9Mxg9eLurOK0bm+tNt3rr1dUwdfPXisz46+OA22YmGE wcCpe63VY8WEh2yJ89LIm84fWUOlIO7MHx5crwg+6/HB8MiyCpVV6/mCA5FEadb6 bKkQqv+DE0tRTZJ0LuoGpVrWhFsRo5d7kPvSVybbOLciJwTRcWzmYp6jq1U/Xtw= =l2Rx -----END PGP SIGNATURE----- --RUJXrXvjauM13XgGWEPNV0HAjVbe9GGPA--