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 <bart.vanassche@sandisk.com>
This commit is contained in:
Bart Van Assche
2016-01-28 16:06:43 -08:00
parent 9df32565a6
commit 71c797fd1c
2 changed files with 8 additions and 5 deletions
+3 -2
View File
@@ -418,7 +418,7 @@ do { \
} while (0); } while (0);
#define RECEIVE_COPY_RESULTS(...) \ #define RECEIVE_COPY_RESULTS(...) \
do { \ ({ \
int _r; \ int _r; \
_r = receive_copy_results(__VA_ARGS__); \ _r = receive_copy_results(__VA_ARGS__); \
if (_r == -2) { \ if (_r == -2) { \
@@ -429,7 +429,8 @@ do { \
return; \ return; \
} \ } \
CU_ASSERT_EQUAL(_r, 0); \ CU_ASSERT_EQUAL(_r, 0); \
} while (0); _r; \
})
#define RELEASE6(...) \ #define RELEASE6(...) \
do { \ do { \
@@ -32,14 +32,16 @@ test_receive_copy_results_op_params(void)
{ {
struct scsi_task *op_task = NULL; struct scsi_task *op_task = NULL;
struct scsi_copy_results_op_params *opp; struct scsi_copy_results_op_params *opp;
int ret;
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test RECEIVE COPY RESULTS, OPERATING PARAMS"); logging(LOG_VERBOSE, "Test RECEIVE COPY RESULTS, OPERATING PARAMS");
RECEIVE_COPY_RESULTS(&op_task, sd, SCSI_COPY_RESULTS_OP_PARAMS, 0, ret = RECEIVE_COPY_RESULTS(&op_task, sd, SCSI_COPY_RESULTS_OP_PARAMS, 0,
(void **)&opp, EXPECT_STATUS_GOOD); (void **)&opp, EXPECT_STATUS_GOOD);
logging(LOG_NORMAL, if (ret == 0)
logging(LOG_NORMAL,
"max_target_desc=%d, max_seg_desc=%d", "max_target_desc=%d, max_seg_desc=%d",
opp->max_target_desc_count, opp->max_target_desc_count,
opp->max_segment_desc_count); opp->max_segment_desc_count);