79c4324644
Change-Id: I2d302dda68298877c65c99147f5bf22186a59aac
80 lines
3.8 KiB
Diff
80 lines
3.8 KiB
Diff
From 75afa2f5b77edd8c34b2062074abfa5c3029437d Mon Sep 17 00:00:00 2001
|
||
From: Boris Fiuczynski <fiuczy@linux.ibm.com>
|
||
Date: Thu, 13 Aug 2020 16:03:46 +0200
|
||
Subject: [PATCH 046/108] storage: avoid maybe-uninitialized warning by GCC 10
|
||
MIME-Version: 1.0
|
||
Content-Type: text/plain; charset=UTF-8
|
||
Content-Transfer-Encoding: 8bit
|
||
|
||
GCC 10 complains about variables may be used uninitialized.
|
||
Even though it might be false positives, we can easily avoid them.
|
||
|
||
Avoiding
|
||
../src/storage/storage_backend_iscsi_direct.c:634:11: error: ‘nb_block’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
|
||
634 | while (lba < nb_block) {
|
||
| ^
|
||
../src/storage/storage_backend_iscsi_direct.c:619:14: note: ‘nb_block’ was declared here
|
||
619 | uint64_t nb_block;
|
||
| ^~~~~~~~
|
||
../src/storage/storage_backend_iscsi_direct.c:637:16: error: ‘block_size’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
|
||
637 | task = iscsi_write16_sync(iscsi, lun, lba, data,
|
||
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
638 | block_size * to_write,
|
||
| ~~~~~~~~~~~~~~~~~~~~~~
|
||
639 | block_size, 0, 0, 0, 0, 0);
|
||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
../src/storage/storage_backend_iscsi_direct.c:618:14: note: ‘block_size’ was declared here
|
||
618 | uint32_t block_size;
|
||
| ^~~~~~~~~~
|
||
../src/storage/storage_backend_iscsi_direct.c: In function ‘virStorageBackendISCSIDirectRefreshPool’:
|
||
../src/storage/storage_backend_iscsi_direct.c:320:39: error: ‘nb_block’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
|
||
320 | vol->target.capacity = block_size * nb_block;
|
||
| ~~~~~~~~~~~^~~~~~~~~~
|
||
../src/storage/storage_backend_iscsi_direct.c:306:14: note: ‘nb_block’ was declared here
|
||
306 | uint64_t nb_block;
|
||
| ^~~~~~~~
|
||
../src/storage/storage_backend_iscsi_direct.c:320:39: error: ‘block_size’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
|
||
320 | vol->target.capacity = block_size * nb_block;
|
||
| ~~~~~~~~~~~^~~~~~~~~~
|
||
../src/storage/storage_backend_iscsi_direct.c:305:14: note: ‘block_size’ was declared here
|
||
305 | uint32_t block_size;
|
||
| ^~~~~~~~~~
|
||
|
||
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
|
||
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
|
||
Reviewed-by: Erik Skultety <eskultet@redhat.com>
|
||
(cherry picked from commit ae8a83c35378d8d3eac2e41b3a10cac0e587ce54)
|
||
---
|
||
src/storage/storage_backend_iscsi_direct.c | 8 ++++----
|
||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||
|
||
diff --git a/src/storage/storage_backend_iscsi_direct.c b/src/storage/storage_backend_iscsi_direct.c
|
||
index c37c671db6..027fa83de7 100644
|
||
--- a/src/storage/storage_backend_iscsi_direct.c
|
||
+++ b/src/storage/storage_backend_iscsi_direct.c
|
||
@@ -302,8 +302,8 @@ virISCSIDirectRefreshVol(virStoragePoolObjPtr pool,
|
||
char *portal)
|
||
{
|
||
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
|
||
- uint32_t block_size;
|
||
- uint64_t nb_block;
|
||
+ uint32_t block_size = 0;
|
||
+ uint64_t nb_block = 0;
|
||
g_autoptr(virStorageVolDef) vol = NULL;
|
||
|
||
if (virISCSIDirectTestUnitReady(iscsi, lun) < 0)
|
||
@@ -615,8 +615,8 @@ virStorageBackendISCSIDirectVolWipeZero(virStorageVolDefPtr vol,
|
||
struct iscsi_context *iscsi)
|
||
{
|
||
uint64_t lba = 0;
|
||
- uint32_t block_size;
|
||
- uint64_t nb_block;
|
||
+ uint32_t block_size = 0;
|
||
+ uint64_t nb_block = 0;
|
||
struct scsi_task *task = NULL;
|
||
int lun = 0;
|
||
int ret = -1;
|
||
--
|
||
2.33.0
|
||
|