aio: Avoid spurious coverity warning
authorAndres Freund <[email protected]>
Fri, 4 Apr 2025 19:15:39 +0000 (15:15 -0400)
committerAndres Freund <[email protected]>
Sun, 6 Apr 2025 16:07:02 +0000 (12:07 -0400)
PgAioResult.result is never accessed in the relevant path, but coverity
complains about an uninitialized access anyway. So just zero-initialize the
whole thing.  While at it, reduce the scope of the variable.

Reported-by: Ranier Vilela <[email protected]>
Reviewed-by: Noah Misch <[email protected]>
Discussion: https://postgr.es/m/CAEudQApsKqd-s+fsUQ0OmxJAMHmBSXxrAz3dCs+uvqb3iRtjSw@mail.gmail.com

src/backend/storage/buffer/bufmgr.c

index 1c37d7dfe2f92befd6440bd0755241e5e66ec09d..ffaca5ee54dee011eef31b96861361cdfdb18e21 100644 (file)
@@ -6868,8 +6868,6 @@ buffer_readv_complete_one(PgAioTargetData *td, uint8 buf_off, Buffer buffer,
    /* Check for garbage data. */
    if (!failed)
    {
-       PgAioResult result_one;
-
        if (!PageIsVerified((Page) bufdata, tag.blockNum, piv_flags,
                            failed_checksum))
        {
@@ -6904,6 +6902,8 @@ buffer_readv_complete_one(PgAioTargetData *td, uint8 buf_off, Buffer buffer,
         */
        if (*buffer_invalid || *failed_checksum || *zeroed_buffer)
        {
+           PgAioResult result_one = {0};
+
            buffer_readv_encode_error(&result_one, is_temp,
                                      *zeroed_buffer,
                                      *ignored_checksum,