[Spice-devel] [spice-common 7/8] quic: Remove test which is always TRUE

Uri Lublin uril at redhat.com
Mon Jan 13 01:30:02 PST 2014


On 01/07/2014 02:47 PM, Christophe Fergeau wrote:
> Hey,
>
> On Mon, Jan 06, 2014 at 03:35:24PM +0200, Uri Lublin wrote:
>> On 01/06/2014 01:22 PM, Christophe Fergeau wrote:
>>> find_model_params() is first dereferencing nbuckets when setting
>>> it to 0, and then it checks it for NULL. The NULL-check will never trigger
>>> as if the pointer was NULL, we'd crash when we dereference it.
>>> This commit removes the redundant test, but adds an assert so that we
>>> catch this condition if it ever happens.
>>> ---
>>>   common/quic.c | 12 +++++++-----
>>>   1 file changed, 7 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/common/quic.c b/common/quic.c
>>> index 2cffde5..cef05ae 100644
>>> --- a/common/quic.c
>>> +++ b/common/quic.c
>>> @@ -954,11 +954,13 @@ static void find_model_params(Encoder *encoder,
>>>       bsize = *firstsize;
>>>       do { /* other buckets */
>> Hi Christophe,
>>
>> Maybe the condition was supposed to be
>>     if (*nbuckets)
> That indeed makes a lot of sense. However, I'm uncomfortable changing code
> I don't understand, even quic still seems to be working after changning
> this. So not sure which way to go here :-/
>
> Christophe

I know what you mean :-)
The change I suggested seems correct to me.
Since the existing code exist for so long without causing problems,
if you prefer to keep it as is, it's fine by me too.

Thanks,
     Uri.



More information about the Spice-devel mailing list