qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [PATCH v2 3/7] qcow2: Prevent allocating compressed clu


From: Alberto Garcia
Subject: Re: [Qemu-block] [PATCH v2 3/7] qcow2: Prevent allocating compressed clusters at offset 0
Date: Mon, 06 Nov 2017 13:52:19 +0100
User-agent: Notmuch/0.18.2 (http://notmuchmail.org) Emacs/24.4.1 (i586-pc-linux-gnu)

On Mon 06 Nov 2017 01:36:01 PM CET, Max Reitz wrote:
>>>>> -        assert(offset);
>>>>
>>>> I don't think this assert() was meant as a protection against offset
>>>> being 0. :-)
>>>
>>> After the new check offset is now guaranteed to be 0, so what's the
>>> point of keeping the assert() ?
>> 
>> I meant "guaranteed _not_ to be 0" :-)
>
> That is the point of an assert.
>
> An assert should not guard against something that can occur. It should
> express that something will always be true (in this case that the
> offset is guaranteed not to be 0).

Right, and they're especially useful when it's not obvious that the
assertion is always true.

The reason why I removed the assertion in this case is that the code
that checks and guarantees that the offset is not null is immediately
before the assert() line.

But I'm not going to argue over something like this, I don't mind if you
prefer to keep it :-)

Berto



reply via email to

[Prev in Thread] Current Thread [Next in Thread]