Skip to content
  • Miroslav Rezanina's avatar
    2d369d6e
    Prevent compiler warning on block.c · 2d369d6e
    Miroslav Rezanina authored
    
    
    Commit 3108a15c (block: introduce bdrv_drop_filter()) introduced
    uninitialized variable to_cow_parent in bdrv_replace_node_common
    function that is used only when detach_subchain is true. It is used in
    two places. First if block properly initialize the variable and second
    block use it.
    
    However, compiler may treat these two blocks as two independent cases so
    it thinks first block can fail test and second one pass (although both
    use same condition). This cause warning that variable can be
    uninitialized in second block.
    
    The warning was observed with GCC 8.4.1 and 11.0.1.
    
    To prevent this warning, initialize the variable with NULL.
    
    Signed-off-by: default avatarMiroslav Rezanina <mrezanin@redhat.com>
    Message-Id: <1162368493.17178530.1620201543649.JavaMail.zimbra@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    2d369d6e
    Prevent compiler warning on block.c
    Miroslav Rezanina authored
    
    
    Commit 3108a15c (block: introduce bdrv_drop_filter()) introduced
    uninitialized variable to_cow_parent in bdrv_replace_node_common
    function that is used only when detach_subchain is true. It is used in
    two places. First if block properly initialize the variable and second
    block use it.
    
    However, compiler may treat these two blocks as two independent cases so
    it thinks first block can fail test and second one pass (although both
    use same condition). This cause warning that variable can be
    uninitialized in second block.
    
    The warning was observed with GCC 8.4.1 and 11.0.1.
    
    To prevent this warning, initialize the variable with NULL.
    
    Signed-off-by: default avatarMiroslav Rezanina <mrezanin@redhat.com>
    Message-Id: <1162368493.17178530.1620201543649.JavaMail.zimbra@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
Loading