qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v2 1/3] block: Add bdrv_co_get_lba_status


From: Stefan Hajnoczi
Subject: Re: [PATCH v2 1/3] block: Add bdrv_co_get_lba_status
Date: Mon, 29 Jun 2020 11:20:54 +0100

On Thu, Jun 25, 2020 at 01:07:14PM +0000, Lin Ma wrote:
> On 2020-06-25 20:59, Lin Ma wrote:
> > Please initialize is_deallocated to false at the beginning of the
> > function to avoid accidental uninitialized variable accesses in the
> > caller.
> 
> It has already been initialized to 0 by 'data = g_new0(GetLbaStatusCBData, 
> 1);'
> in function scsi_disk_emulate_get_lba_status of patch 3/3, Do I still need to
> initialize it at the beginning of this function?

It's safer to set output arguments in all code paths. That way callers
don't need to remember to initialize the variable to a specific value
(false in this case).

You can leave this assumptnion but please include it in the doc comment
so it's clear that callers are responsible for setting it to false.

Stefan

Attachment: signature.asc
Description: PGP signature


reply via email to

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