From dbc4e33db2eb7de23e775cd0c1bf886952f8109c Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 3 Apr 2015 13:52:05 +0200 Subject: [PATCH] test-tool: Fix a few sporadic crashes Avoid that Valgrind reports complaints similar to the following: Conditional jump or move depends on uninitialised value(s) at 0x405097: send_scsi_command (iscsi-support.c:240) by 0x40904B: reserve6_conflict (iscsi-support.c:1915) by 0x42231C: test_reserve6_logout (test_reserve6_logout.c:63) by 0x503EC99: ??? (in /usr/lib/libcunit.so.1.0.1) by 0x503EF27: ??? (in /usr/lib/libcunit.so.1.0.1) by 0x503F2A5: CU_run_all_tests (in /usr/lib/libcunit.so.1.0.1) by 0x404B43: main (iscsi-test-cu.c:1292) Signed-off-by: Bart Van Assche --- test-tool/test_preventallow_2_itnexuses.c | 1 + test-tool/test_reserve6_itnexus_loss.c | 1 + test-tool/test_reserve6_logout.c | 1 + test-tool/test_reserve6_lun_reset.c | 1 + test-tool/test_reserve6_target_cold_reset.c | 1 + test-tool/test_reserve6_target_warm_reset.c | 1 + test-tool/test_sanitize_reservations.c | 1 + 7 files changed, 7 insertions(+) diff --git a/test-tool/test_preventallow_2_itnexuses.c b/test-tool/test_preventallow_2_itnexuses.c index a957fe3..40cedf2 100644 --- a/test-tool/test_preventallow_2_itnexuses.c +++ b/test-tool/test_preventallow_2_itnexuses.c @@ -59,6 +59,7 @@ test_preventallow_2_itnexuses(void) CU_ASSERT_EQUAL(ret, 0); logging(LOG_VERBOSE, "Create a second connection to the target"); + memset(&sd2, 0, sizeof(sd2)); sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd->iscsi_lun); if (sd2.iscsi_ctx == NULL) { logging(LOG_VERBOSE, "Failed to login to target"); diff --git a/test-tool/test_reserve6_itnexus_loss.c b/test-tool/test_reserve6_itnexus_loss.c index 0555f18..3dbe486 100644 --- a/test-tool/test_reserve6_itnexus_loss.c +++ b/test-tool/test_reserve6_itnexus_loss.c @@ -53,6 +53,7 @@ test_reserve6_itnexus_loss(void) logging(LOG_VERBOSE, "Create a second connection to the target"); + memset(&sd2, 0, sizeof(sd2)); sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); if (sd2.iscsi_ctx == NULL) { logging(LOG_VERBOSE, "Failed to login to target"); diff --git a/test-tool/test_reserve6_logout.c b/test-tool/test_reserve6_logout.c index 5feacba..0f3c36a 100644 --- a/test-tool/test_reserve6_logout.c +++ b/test-tool/test_reserve6_logout.c @@ -53,6 +53,7 @@ test_reserve6_logout(void) logging(LOG_VERBOSE, "Create a second connection to the target"); + memset(&sd2, 0, sizeof(sd2)); sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); if (sd2.iscsi_ctx == NULL) { logging(LOG_VERBOSE, "Failed to login to target"); diff --git a/test-tool/test_reserve6_lun_reset.c b/test-tool/test_reserve6_lun_reset.c index 9175056..04cc5d5 100644 --- a/test-tool/test_reserve6_lun_reset.c +++ b/test-tool/test_reserve6_lun_reset.c @@ -64,6 +64,7 @@ test_reserve6_lun_reset(void) logging(LOG_VERBOSE, "Create a second connection to the target"); + memset(&sd2, 0, sizeof(sd2)); sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); if (sd2.iscsi_ctx == NULL) { logging(LOG_VERBOSE, "Failed to login to target"); diff --git a/test-tool/test_reserve6_target_cold_reset.c b/test-tool/test_reserve6_target_cold_reset.c index 9b98168..e39c37b 100644 --- a/test-tool/test_reserve6_target_cold_reset.c +++ b/test-tool/test_reserve6_target_cold_reset.c @@ -63,6 +63,7 @@ test_reserve6_target_cold_reset(void) sleep(3); logging(LOG_VERBOSE, "Create a second connection to the target"); + memset(&sd2, 0, sizeof(sd2)); sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); if (sd2.iscsi_ctx == NULL) { logging(LOG_VERBOSE, "Failed to login to target"); diff --git a/test-tool/test_reserve6_target_warm_reset.c b/test-tool/test_reserve6_target_warm_reset.c index cf31e84..1387a77 100644 --- a/test-tool/test_reserve6_target_warm_reset.c +++ b/test-tool/test_reserve6_target_warm_reset.c @@ -64,6 +64,7 @@ test_reserve6_target_warm_reset(void) logging(LOG_VERBOSE, "Create a second connection to the target"); + memset(&sd2, 0, sizeof(sd2)); sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); if (sd2.iscsi_ctx == NULL) { logging(LOG_VERBOSE, "Failed to login to target"); diff --git a/test-tool/test_sanitize_reservations.c b/test-tool/test_sanitize_reservations.c index ce133e7..973c192 100644 --- a/test-tool/test_sanitize_reservations.c +++ b/test-tool/test_sanitize_reservations.c @@ -49,6 +49,7 @@ test_sanitize_reservations(void) } logging(LOG_VERBOSE, "Create a second connection to the target"); + memset(&sd2, 0, sizeof(sd2)); sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); if (sd2.iscsi_ctx == NULL) { logging(LOG_VERBOSE, "Failed to login to target");