[vbox-dev] handleConvertFromRaw() code question

Frank Mehnert frank.mehnert at oracle.com
Wed Apr 3 00:58:34 PDT 2013


Hi Skippy,

On Tuesday 02 April 2013 21:38:45 Skippy VonDrake wrote:
> I don't understand some code in handleConvertFromRaw(int argc, char
> *argv[])
> (file VBoxManageDisk.cpp, version 4.1.10).
> 
> Specifically:
> 
> Assert(RT_MIN(cbFile / 512 / 16 / 63, 16383) -
>            (unsigned int)RT_MIN(cbFile / 512 / 16 / 63, 16383) == 0);
> 
> cbFile is of type uint64_t, and I don't understand how this test could
> *ever* fail!?
> 
> What am I missing? Sorry if this is a "learning C" question... but I hope
> someone will enlighten me as to how that assert could ever fail.

correct, that assertion is always true. I assume the intention of this
assertion is to verify that the cast to 'unsigned int' will not chop
any bits but the RT_MIN() term will be never bigger than 16383.

So let's call this assertion superfluous but it will not cause any harm.
And it's disabled in normal (non-debug) builds anyway.

Kind regards,

Frank
-- 
Dr.-Ing. Frank Mehnert | Software Development Director, VirtualBox
ORACLE Deutschland B.V. & Co. KG | Werkstr. 24 | 71384 Weinstadt, Germany

Hauptverwaltung: Riesstr. 25, D-80992 München
Registergericht: Amtsgericht München, HRA 95603
Geschäftsführer: Jürgen Kunz

Komplementärin: ORACLE Deutschland Verwaltung B.V.
Hertogswetering 163/167, 3543 AS Utrecht, Niederlande
Handelsregister der Handelskammer Midden-Niederlande, Nr. 30143697
Geschäftsführer: Alexander van der Ven, Astrid Kepper, Val Maher
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
Url : http://www.virtualbox.org/pipermail/vbox-dev/attachments/20130403/545fe055/attachment.bin 


More information about the vbox-dev mailing list