From 71c797fd1c01237eed9e6d6d71ccf74deca905c4 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 28 Jan 2016 16:06:43 -0800 Subject: [PATCH] test-tool: Fix a segmentation fault in test_receive_copy_results_op_params() Do not access the RECEIVE_COPY_RESULTS() output if this operation failed. Signed-off-by: Bart Van Assche --- test-tool/iscsi-support.h | 5 +++-- test-tool/test_receive_copy_results_op_params.c | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/test-tool/iscsi-support.h b/test-tool/iscsi-support.h index 3830f9e..b301b6f 100644 --- a/test-tool/iscsi-support.h +++ b/test-tool/iscsi-support.h @@ -418,7 +418,7 @@ do { \ } while (0); #define RECEIVE_COPY_RESULTS(...) \ - do { \ + ({ \ int _r; \ _r = receive_copy_results(__VA_ARGS__); \ if (_r == -2) { \ @@ -429,7 +429,8 @@ do { \ return; \ } \ CU_ASSERT_EQUAL(_r, 0); \ - } while (0); + _r; \ + }) #define RELEASE6(...) \ do { \ diff --git a/test-tool/test_receive_copy_results_op_params.c b/test-tool/test_receive_copy_results_op_params.c index 2ee0b99..6d1e76a 100644 --- a/test-tool/test_receive_copy_results_op_params.c +++ b/test-tool/test_receive_copy_results_op_params.c @@ -32,14 +32,16 @@ test_receive_copy_results_op_params(void) { struct scsi_task *op_task = NULL; struct scsi_copy_results_op_params *opp; + int ret; logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test RECEIVE COPY RESULTS, OPERATING PARAMS"); - RECEIVE_COPY_RESULTS(&op_task, sd, SCSI_COPY_RESULTS_OP_PARAMS, 0, - (void **)&opp, EXPECT_STATUS_GOOD); + ret = RECEIVE_COPY_RESULTS(&op_task, sd, SCSI_COPY_RESULTS_OP_PARAMS, 0, + (void **)&opp, EXPECT_STATUS_GOOD); - logging(LOG_NORMAL, + if (ret == 0) + logging(LOG_NORMAL, "max_target_desc=%d, max_seg_desc=%d", opp->max_target_desc_count, opp->max_segment_desc_count);