From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49162) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1br4vM-0000KZ-As for qemu-devel@nongnu.org; Mon, 03 Oct 2016 11:13:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1br4vG-000354-Bk for qemu-devel@nongnu.org; Mon, 03 Oct 2016 11:12:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43362) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1br4vG-00034h-2z for qemu-devel@nongnu.org; Mon, 03 Oct 2016 11:12:54 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1F33981253 for ; Mon, 3 Oct 2016 15:12:52 +0000 (UTC) References: <20160920113759.23a1ee06@fiorina> <806811cc-5788-a93c-43a3-59271b2cdfbb@redhat.com> <20161003155045.6889f89d@fiorina> From: Eric Blake Message-ID: <28217cec-a26d-0a42-b6d2-06f9524864a0@redhat.com> Date: Mon, 3 Oct 2016 10:12:50 -0500 MIME-Version: 1.0 In-Reply-To: <20161003155045.6889f89d@fiorina> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Hnf1PBaKVm2nBrArqKJQ4JtKTfoSRUHpH" Subject: Re: [Qemu-devel] [PATCH 1/2] qemu-nbd: Shrink image size by specified offset List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= Cc: Paolo Bonzini , qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Hnf1PBaKVm2nBrArqKJQ4JtKTfoSRUHpH From: Eric Blake To: =?UTF-8?B?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= Cc: Paolo Bonzini , qemu-devel@nongnu.org Message-ID: <28217cec-a26d-0a42-b6d2-06f9524864a0@redhat.com> Subject: Re: [Qemu-devel] [PATCH 1/2] qemu-nbd: Shrink image size by specified offset References: <20160920113759.23a1ee06@fiorina> <806811cc-5788-a93c-43a3-59271b2cdfbb@redhat.com> <20161003155045.6889f89d@fiorina> In-Reply-To: <20161003155045.6889f89d@fiorina> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 10/03/2016 08:50 AM, Tom=C3=A1=C5=A1 Golembiovsk=C3=BD wrote: >> Additional context: >> >> off_t dev_offset =3D 0; >> >> off_t fd_size; >> >>> =20 >>> + if (dev_offset >=3D fd_size) { >>> + error_report("Offset (%lu) has to be smaller than the image = size (%lu)", >>> + dev_offset, fd_size); =20 >> >> Whoops, this fails to compile on 32-bit platforms. %lu is not >> necessarily synonymous with off_t values. >=20 > After some digging I figured off_t is in fact signed type. That makes > the formatting wrong everywhere. Unfortunately I didn't find any good > definition of the type. Any suggestion what format flag should I use? O= r > should I just use a temporary variable of known size for that? Easiest is probably casting to a type with an easier format flag, as in either of: error_report("offset %lld ...", (long long) dev_offset) error_report("offset %jd ...", (intmax_t) dev_offset) off_t is particularly problematic because there is no magic % sequence reserved for it, nothing in for it, and there are 32-bit compilation environments where it is still 32 bits (although qemu prefers to explicitly request large-file compilation so that off_t is always 64 bits) --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --Hnf1PBaKVm2nBrArqKJQ4JtKTfoSRUHpH Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJX8nVyAAoJEKeha0olJ0NqOksH/0fk0ycvGBZILoFNysxHk0j8 E2hYJfK9j3+BadwYuNeajeCNp/owlQUvB/lQZ4rh0U5HawdJyMrMCq126SpdM82Y Zg+e+GVXKxD6abhLOWvNIlRXERqv3ptR9eeXfBddUiTprq+mdBEu/+j1JPZoXALV VKHnVgEg2UKdxh/odkkXZEnGEIQ/oCvYqGi03LwIjw6sIAEhcByZbLK/U5MwIKXk Zx+RLB58WIDxrIj0pd/aA1AlV+o8Bk0FjmcX8S9xRS9Ddgf+rS8xpEiiSTWS1iLV LEvV4Lg0JwigNzf64+g/ATksfQI3S0siTPOFqQ8WEgCf5nioNdKSydbcMrZf+34= =jiyl -----END PGP SIGNATURE----- --Hnf1PBaKVm2nBrArqKJQ4JtKTfoSRUHpH--