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