diff --git a/test-tool/iscsi-support.c b/test-tool/iscsi-support.c index 6846715..4c83d44 100644 --- a/test-tool/iscsi-support.c +++ b/test-tool/iscsi-support.c @@ -109,6 +109,7 @@ struct scsi_inquiry_block_limits *inq_bl; struct scsi_readcapacity16 *rc16; struct scsi_report_supported_op_codes *rsop; +unsigned char *scratch; size_t block_size; uint64_t num_blocks; int lbppb; diff --git a/test-tool/iscsi-support.h b/test-tool/iscsi-support.h index 6b1c161..6793590 100644 --- a/test-tool/iscsi-support.h +++ b/test-tool/iscsi-support.h @@ -314,6 +314,7 @@ extern struct scsi_inquiry_block_limits *inq_bl; extern struct scsi_readcapacity16 *rc16; extern struct scsi_report_supported_op_codes *rsop; +extern unsigned char *scratch; extern size_t block_size; extern uint64_t num_blocks; extern int lbppb; diff --git a/test-tool/iscsi-test-cu.c b/test-tool/iscsi-test-cu.c index 78336cb..f4e17fd 100644 --- a/test-tool/iscsi-test-cu.c +++ b/test-tool/iscsi-test-cu.c @@ -1249,6 +1249,9 @@ main(int argc, char *argv[]) lbppb = 1 << rc16->lbppbe; } + /* create a really big buffer we can use in the tests */ + scratch = malloc(65536 * block_size); + inq_task = NULL; inquiry(sd, &inq_task, 0, 0, 64, EXPECT_STATUS_GOOD); if (inq_task == NULL || inq_task->status != SCSI_STATUS_GOOD) { @@ -1452,12 +1455,13 @@ main(int argc, char *argv[]) for (i = 0; i < mp_num_sds; i++) { free_scsi_device(mp_sds[i]); } - + free(scratch); return 0; err_sds_free: for (i = 0; i < mp_num_sds; i++) { free_scsi_device(mp_sds[i]); } + free(scratch); return -1; } diff --git a/test-tool/test_compareandwrite_dpofua.c b/test-tool/test_compareandwrite_dpofua.c index a63ada8..77d18da 100644 --- a/test-tool/test_compareandwrite_dpofua.c +++ b/test-tool/test_compareandwrite_dpofua.c @@ -34,7 +34,6 @@ test_compareandwrite_dpofua(void) struct scsi_mode_sense *ms; struct scsi_task *rso_task = NULL; struct scsi_report_supported_op_codes_one_command *rsoc; - unsigned char *buf = alloca(2 * block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test COMPAREANDWRITE DPO/FUA flags"); @@ -54,13 +53,13 @@ test_compareandwrite_dpofua(void) logging(LOG_VERBOSE, "Read the first block"); ret = read10(sd, NULL, 0, block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); if (ret == 0) - memcpy(buf + block_size, buf, block_size); + memcpy(scratch + block_size, scratch, block_size); else - memset(buf, 0xa6, 2 * block_size); + memset(scratch, 0xa6, 2 * block_size); if (dpofua) { logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow " @@ -72,11 +71,11 @@ test_compareandwrite_dpofua(void) logging(LOG_VERBOSE, "Test COMPAREANDWRITE with DPO==1"); if (dpofua) { - ret = compareandwrite(sd, 0, buf, 2 * block_size, + ret = compareandwrite(sd, 0, scratch, 2 * block_size, block_size, 0, 1, 0, 0, EXPECT_STATUS_GOOD); } else { - ret = compareandwrite(sd, 0, buf, 2 * block_size, + ret = compareandwrite(sd, 0, scratch, 2 * block_size, block_size, 0, 1, 0, 0, EXPECT_INVALID_FIELD_IN_CDB); } @@ -89,12 +88,12 @@ test_compareandwrite_dpofua(void) logging(LOG_VERBOSE, "Test COMPAREANDWRITE with FUA==1"); if (dpofua) { - ret = compareandwrite(sd, 0, buf, 2 * block_size, + ret = compareandwrite(sd, 0, scratch, 2 * block_size, block_size, 0, 0, 1, 0, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); } else { - ret = compareandwrite(sd, 0, buf, 2 * block_size, + ret = compareandwrite(sd, 0, scratch, 2 * block_size, block_size, 0, 0, 1, 0, EXPECT_INVALID_FIELD_IN_CDB); CU_ASSERT_EQUAL(ret, 0); @@ -102,12 +101,12 @@ test_compareandwrite_dpofua(void) logging(LOG_VERBOSE, "Test COMPAREANDWRITE with DPO==1 FUA==1"); if (dpofua) { - ret = compareandwrite(sd, 0, buf, 2 * block_size, + ret = compareandwrite(sd, 0, scratch, 2 * block_size, block_size, 0, 1, 1, 0, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); } else { - ret = compareandwrite(sd, 0, buf, 2 * block_size, + ret = compareandwrite(sd, 0, scratch, 2 * block_size, block_size, 0, 1, 1, 0, EXPECT_INVALID_FIELD_IN_CDB); CU_ASSERT_EQUAL(ret, 0); diff --git a/test-tool/test_compareandwrite_miscompare.c b/test-tool/test_compareandwrite_miscompare.c index d0a2612..a02093b 100644 --- a/test-tool/test_compareandwrite_miscompare.c +++ b/test-tool/test_compareandwrite_miscompare.c @@ -33,7 +33,6 @@ test_compareandwrite_miscompare(void) { int i, ret; unsigned j; - unsigned char *buf = alloca(2 * 256 * block_size); int maxbl; CHECK_FOR_DATALOSS; @@ -50,12 +49,12 @@ test_compareandwrite_miscompare(void) "start of the LUN. One Byte miscompare in the final block."); for (i = 1; i < 256; i++) { logging(LOG_VERBOSE, "Write %d blocks of 'A' at LBA:0", i); - memset(buf, 'A', 2 * i * block_size); + memset(scratch, 'A', 2 * i * block_size); if (maximum_transfer_length && maximum_transfer_length < i) { break; } ret = write16(sd, 0, i * block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); if (ret == -2) { logging(LOG_NORMAL, "[SKIPPED] WRITE16 is not implemented."); @@ -66,7 +65,7 @@ test_compareandwrite_miscompare(void) logging(LOG_VERBOSE, "Change byte 27 from the end to 'C' so that it does not match."); - buf[i * block_size - 27] = 'C'; + scratch[i * block_size - 27] = 'C'; if (i > maxbl) { logging(LOG_VERBOSE, "Number of blocks %d is greater than " @@ -74,7 +73,7 @@ test_compareandwrite_miscompare(void) "Command should fail with INVALID_FIELD_IN_CDB", i, maxbl); ret = compareandwrite(sd, 0, - buf, 2 * i * block_size, + scratch, 2 * i * block_size, block_size, 0, 0, 0, 0, EXPECT_INVALID_FIELD_IN_CDB); if (ret == -2) { @@ -87,12 +86,12 @@ test_compareandwrite_miscompare(void) continue; } - memset(buf + i * block_size, 'B', i * block_size); + memset(scratch + i * block_size, 'B', i * block_size); logging(LOG_VERBOSE, "Overwrite %d blocks with 'B' " "at LBA:0 (if they all contain 'A')", i); ret = compareandwrite(sd, 0, - buf, 2 * i * block_size, block_size, + scratch, 2 * i * block_size, block_size, 0, 0, 0, 0, EXPECT_MISCOMPARE); if (ret == -2) { @@ -105,12 +104,12 @@ test_compareandwrite_miscompare(void) logging(LOG_VERBOSE, "Read %d blocks at LBA:0 and verify " "they are still unchanged as 'A'", i); ret = read16(sd, NULL, 0, i * block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); for (j = 0; j < i * block_size; j++) { - if (buf[j] != 'A') { + if (scratch[j] != 'A') { logging(LOG_VERBOSE, "[FAILED] Data changed " "eventhough there was a miscompare"); CU_FAIL("Block was written to"); @@ -125,17 +124,17 @@ test_compareandwrite_miscompare(void) for (i = 1; i < 256; i++) { logging(LOG_VERBOSE, "Write %d blocks of 'A' at LBA:%" PRIu64, i, num_blocks - i); - memset(buf, 'A', 2 * i * block_size); + memset(scratch, 'A', 2 * i * block_size); if (maximum_transfer_length && maximum_transfer_length < i) { break; } ret = write16(sd, num_blocks - i, i * block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); logging(LOG_VERBOSE, "Change byte 27 from the end to 'C' so that it does not match."); - buf[i * block_size - 27] = 'C'; + scratch[i * block_size - 27] = 'C'; if (i > maxbl) { @@ -144,20 +143,20 @@ test_compareandwrite_miscompare(void) "Command should fail with INVALID_FIELD_IN_CDB", i, maxbl); ret = compareandwrite(sd, 0, - buf, 2 * i * block_size, + scratch, 2 * i * block_size, block_size, 0, 0, 0, 0, EXPECT_INVALID_FIELD_IN_CDB); CU_ASSERT_EQUAL(ret, 0); continue; } - memset(buf + i * block_size, 'B', i * block_size); + memset(scratch + i * block_size, 'B', i * block_size); logging(LOG_VERBOSE, "Overwrite %d blocks with 'B' " "at LBA:%" PRIu64 " (if they all contain 'A')", i, num_blocks - i); ret = compareandwrite(sd, num_blocks - i, - buf, 2 * i * block_size, block_size, + scratch, 2 * i * block_size, block_size, 0, 0, 0, 0, EXPECT_MISCOMPARE); CU_ASSERT_EQUAL(ret, 0); @@ -166,12 +165,12 @@ test_compareandwrite_miscompare(void) "they are still unchanged as 'A'", i, num_blocks - i); ret = read16(sd, NULL, num_blocks - i, i * block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); for (j = 0; j < i * block_size; j++) { - if (buf[j] != 'A') { + if (scratch[j] != 'A') { logging(LOG_VERBOSE, "[FAILED] Data changed " "eventhough there was a miscompare"); CU_FAIL("Block was written to"); diff --git a/test-tool/test_compareandwrite_simple.c b/test-tool/test_compareandwrite_simple.c index bec4be6..0d9f62f 100644 --- a/test-tool/test_compareandwrite_simple.c +++ b/test-tool/test_compareandwrite_simple.c @@ -33,7 +33,6 @@ test_compareandwrite_simple(void) { int i, ret; unsigned j; - unsigned char *buf = alloca(2 * 256 * block_size); int maxbl; CHECK_FOR_DATALOSS; @@ -51,12 +50,12 @@ test_compareandwrite_simple(void) "start of the LUN"); for (i = 1; i < 256; i++) { logging(LOG_VERBOSE, "Write %d blocks of 'A' at LBA:0", i); - memset(buf, 'A', 2 * i * block_size); + memset(scratch, 'A', 2 * i * block_size); if (maximum_transfer_length && maximum_transfer_length < i) { break; } ret = write16(sd, 0, i * block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); if (ret == -2) { logging(LOG_NORMAL, "[SKIPPED] WRITE16 is not implemented."); @@ -71,7 +70,7 @@ test_compareandwrite_simple(void) "Command should fail with INVALID_FIELD_IN_CDB", i, maxbl); ret = compareandwrite(sd, 0, - buf, 2 * i * block_size, + scratch, 2 * i * block_size, block_size, 0, 0, 0, 0, EXPECT_INVALID_FIELD_IN_CDB); if (ret == -2) { @@ -84,12 +83,12 @@ test_compareandwrite_simple(void) continue; } - memset(buf + i * block_size, 'B', i * block_size); + memset(scratch + i * block_size, 'B', i * block_size); logging(LOG_VERBOSE, "Overwrite %d blocks with 'B' " "at LBA:0 (if they all contain 'A')", i); ret = compareandwrite(sd, 0, - buf, 2 * i * block_size, block_size, + scratch, 2 * i * block_size, block_size, 0, 0, 0, 0, EXPECT_STATUS_GOOD); if (ret == -2) { @@ -102,15 +101,15 @@ test_compareandwrite_simple(void) logging(LOG_VERBOSE, "Read %d blocks at LBA:0 and verify " "they are all 'B'", i); ret = read16(sd, NULL, 0, i * block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); for (j = 0; j < i * block_size; j++) { - if (buf[j] != 'B') { + if (scratch[j] != 'B') { logging(LOG_VERBOSE, "[FAILED] Data did not " - "read back as 'B' (buf[%d] = %#02x)", - j, buf[j]); + "read back as 'B' (scratch[%d] = %#02x)", + j, scratch[j]); CU_FAIL("Block was not written correctly"); return; } @@ -123,12 +122,12 @@ test_compareandwrite_simple(void) for (i = 1; i < 256; i++) { logging(LOG_VERBOSE, "Write %d blocks of 'A' at LBA:%" PRIu64, i, num_blocks - i); - memset(buf, 'A', 2 * i * block_size); + memset(scratch, 'A', 2 * i * block_size); if (maximum_transfer_length && maximum_transfer_length < i) { break; } ret = write16(sd, num_blocks - i, i * block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); @@ -138,20 +137,20 @@ test_compareandwrite_simple(void) "Command should fail with INVALID_FIELD_IN_CDB", i, maxbl); ret = compareandwrite(sd, 0, - buf, 2 * i * block_size, + scratch, 2 * i * block_size, block_size, 0, 0, 0, 0, EXPECT_INVALID_FIELD_IN_CDB); CU_ASSERT_EQUAL(ret, 0); continue; } - memset(buf + i * block_size, 'B', i * block_size); + memset(scratch + i * block_size, 'B', i * block_size); logging(LOG_VERBOSE, "Overwrite %d blocks with 'B' " "at LBA:%" PRIu64 " (if they all contain 'A')", i, num_blocks - i); ret = compareandwrite(sd, num_blocks - i, - buf, 2 * i * block_size, block_size, + scratch, 2 * i * block_size, block_size, 0, 0, 0, 0, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); @@ -160,15 +159,15 @@ test_compareandwrite_simple(void) " and verify they are all 'B'", i, num_blocks - i); ret = read16(sd, NULL, num_blocks - i, i * block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); for (j = 0; j < i * block_size; j++) { - if (buf[j] != 'B') { + if (scratch[j] != 'B') { logging(LOG_VERBOSE, "[FAILED] Data did not " - "read back as 'B' (buf[%d] = %#02x)", - j, buf[j]); + "read back as 'B' (scratch[%d] = %#02x)", + j, scratch[j]); CU_FAIL("Block was not written correctly"); return; } diff --git a/test-tool/test_get_lba_status_unmap_single.c b/test-tool/test_get_lba_status_unmap_single.c index 2200b82..3ddb717 100644 --- a/test-tool/test_get_lba_status_unmap_single.c +++ b/test-tool/test_get_lba_status_unmap_single.c @@ -31,7 +31,6 @@ test_get_lba_status_unmap_single(void) { int ret; uint64_t i; - unsigned char *buf = alloca((256 + lbppb + 1) * block_size); struct unmap_list list[1]; struct scsi_task *t = NULL; struct scsi_get_lba_status *lbas = NULL; @@ -41,7 +40,7 @@ test_get_lba_status_unmap_single(void) CHECK_FOR_THIN_PROVISIONING; CHECK_FOR_LBPU; - memset(buf, 'A', (256 + lbppb + 1) * block_size); + memset(scratch, 'A', (256 + lbppb + 1) * block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test GET_LBA_STATUS for a single unmapped block " @@ -52,7 +51,7 @@ test_get_lba_status_unmap_single(void) logging(LOG_VERBOSE, "Write the first %i blocks with a known " "pattern and thus map the blocks", 256 + lbppb); ret = write10(sd, 0, (256 + lbppb) * block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); @@ -118,7 +117,7 @@ test_get_lba_status_unmap_single(void) logging(LOG_VERBOSE, "Write the first %i blocks with a known " "pattern and thus map the blocks", (256 + lbppb)); ret = write10(sd, 0, (256 + lbppb) * block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Unmap %" PRIu64 " blocks at LBA 0", i); diff --git a/test-tool/test_iscsi_datasn_invalid.c b/test-tool/test_iscsi_datasn_invalid.c index 92cb94c..db04777 100644 --- a/test-tool/test_iscsi_datasn_invalid.c +++ b/test-tool/test_iscsi_datasn_invalid.c @@ -59,7 +59,6 @@ static int my_iscsi_queue_pdu(struct iscsi_context *iscsi _U_, struct iscsi_pdu void test_iscsi_datasn_invalid(void) { int ret; - unsigned char *buf = alloca(2 * block_size); CHECK_FOR_DATALOSS; @@ -83,10 +82,10 @@ void test_iscsi_datasn_invalid(void) iscsi_set_noautoreconnect(sd->iscsi_ctx, 1); iscsi_set_timeout(sd->iscsi_ctx, 3); - memset(buf, 0xa6, 2 * block_size); + memset(scratch, 0xa6, 2 * block_size); ret = write10(sd, 100, 2 * block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); if (ret == -2) { logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented."); @@ -109,7 +108,7 @@ void test_iscsi_datasn_invalid(void) iscsi_set_timeout(sd->iscsi_ctx, 3); ret = write10(sd, 100, block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); if (ret == -2) { logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented."); @@ -132,7 +131,7 @@ void test_iscsi_datasn_invalid(void) iscsi_set_timeout(sd->iscsi_ctx, 3); ret = write10(sd, 100, block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); if (ret == -2) { logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented."); @@ -156,7 +155,7 @@ void test_iscsi_datasn_invalid(void) iscsi_set_timeout(sd->iscsi_ctx, 3); ret = write10(sd, 100, 2 * block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); if (ret == -2) { logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented."); diff --git a/test-tool/test_modesense6_control_swp.c b/test-tool/test_modesense6_control_swp.c index b95d244..b902083 100644 --- a/test-tool/test_modesense6_control_swp.c +++ b/test-tool/test_modesense6_control_swp.c @@ -32,7 +32,6 @@ test_modesense6_control_swp(void) struct scsi_task *ms_task = NULL; struct scsi_mode_sense *ms; struct scsi_mode_page *page; - unsigned char *buf = alloca(block_size); int ret; CHECK_FOR_DATALOSS; @@ -90,13 +89,13 @@ test_modesense6_control_swp(void) logging(LOG_VERBOSE, "Read a block from the now Read-Only device"); ret = read10(sd, NULL, 0, block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); logging(LOG_VERBOSE, "Try to write a block to the Read-Only device"); ret = write10(sd, 0, block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_WRITE_PROTECTED); CU_ASSERT_EQUAL(ret, 0); diff --git a/test-tool/test_multipathio_compareandwrite.c b/test-tool/test_multipathio_compareandwrite.c index 066de62..2de0cca 100644 --- a/test-tool/test_multipathio_compareandwrite.c +++ b/test-tool/test_multipathio_compareandwrite.c @@ -35,7 +35,6 @@ test_multipathio_compareandwrite(void) int io_bl = 1; /* 1 block CAW IOs */ int path; int i, ret; - unsigned char *buf = alloca(2 * io_bl * block_size); int maxbl; CHECK_FOR_DATALOSS; @@ -56,9 +55,9 @@ test_multipathio_compareandwrite(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Initialising data prior to COMPARE_AND_WRITE"); - memset(buf, 0, io_bl * block_size); + memset(scratch, 0, io_bl * block_size); ret = writesame10(mp_sds[0], 0, - block_size, 256, 0, 0, 0, 0, buf, + block_size, 256, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); if (ret == -2) { CU_PASS("[SKIPPED] Target does not support WRITESAME10. Skipping test"); @@ -75,13 +74,13 @@ test_multipathio_compareandwrite(void) path, path + 1, path); /* compare data is first half */ - memset(buf, path, io_bl * block_size); + memset(scratch, path, io_bl * block_size); /* write data is the second half, wrap around */ - memset(buf + io_bl * block_size, path + 1, + memset(scratch + io_bl * block_size, path + 1, io_bl * block_size); ret = compareandwrite(mp_sds[path], i, - buf, 2 * io_bl * block_size, + scratch, 2 * io_bl * block_size, block_size, 0, 0, 0, 0, EXPECT_STATUS_GOOD); if (ret == -2) { @@ -96,7 +95,7 @@ test_multipathio_compareandwrite(void) path, path + 1); ret = compareandwrite(mp_sds[path], i, - buf, 2 * io_bl * block_size, + scratch, 2 * io_bl * block_size, block_size, 0, 0, 0, 0, EXPECT_MISCOMPARE); CU_ASSERT_EQUAL(ret, 0); diff --git a/test-tool/test_orwrite_beyond_eol.c b/test-tool/test_orwrite_beyond_eol.c index 8670821..ed5e121 100644 --- a/test-tool/test_orwrite_beyond_eol.c +++ b/test-tool/test_orwrite_beyond_eol.c @@ -30,20 +30,19 @@ void test_orwrite_beyond_eol(void) { int i, ret; - unsigned char *buf = alloca(256 * block_size); CHECK_FOR_DATALOSS; CHECK_FOR_SBC; logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test ORWRITE 1-256 blocks one block beyond the end"); - memset(buf, 0xa6, 256 * block_size); + memset(scratch, 0xa6, 256 * block_size); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } ret = orwrite(sd, num_blocks + 1 - i, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); if (ret == -2) { logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented."); @@ -60,7 +59,8 @@ test_orwrite_beyond_eol(void) break; } ret = orwrite(sd, 0x8000000000000000ULL, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, + 0, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); CU_ASSERT_EQUAL(ret, 0); } @@ -72,7 +72,8 @@ test_orwrite_beyond_eol(void) break; } ret = orwrite(sd, -1, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, + 0, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); CU_ASSERT_EQUAL(ret, 0); } @@ -84,7 +85,8 @@ test_orwrite_beyond_eol(void) break; } ret = orwrite(sd, num_blocks - 1, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, + 0, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); CU_ASSERT_EQUAL(ret, 0); } diff --git a/test-tool/test_orwrite_dpofua.c b/test-tool/test_orwrite_dpofua.c index c557b9c..9a9a5dd 100644 --- a/test-tool/test_orwrite_dpofua.c +++ b/test-tool/test_orwrite_dpofua.c @@ -34,7 +34,6 @@ test_orwrite_dpofua(void) struct scsi_mode_sense *ms; struct scsi_task *rso_task = NULL; struct scsi_report_supported_op_codes_one_command *rsoc; - unsigned char *buf = alloca(block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test ORWRITE DPO/FUA flags"); @@ -61,10 +60,10 @@ test_orwrite_dpofua(void) } logging(LOG_VERBOSE, "Test ORWRITE with DPO==1"); - memset(buf, 0xa6, block_size); + memset(scratch, 0xa6, block_size); if (dpofua) { ret = orwrite(sd, 0, block_size, - block_size, 0, 1, 0, 0, 0, buf, + block_size, 0, 1, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); if (ret == -2) { logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented."); @@ -74,7 +73,7 @@ test_orwrite_dpofua(void) CU_ASSERT_EQUAL(ret, 0); } else { ret = orwrite(sd, 0, block_size, - block_size, 0, 1, 0, 0, 0, buf, + block_size, 0, 1, 0, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); if (ret == -2) { logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented."); @@ -87,12 +86,12 @@ test_orwrite_dpofua(void) logging(LOG_VERBOSE, "Test ORWRITE with FUA==1"); if (dpofua) { ret = orwrite(sd, 0, block_size, - block_size, 0, 0, 1, 0, 0, buf, + block_size, 0, 0, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); } else { ret = orwrite(sd, 0, block_size, - block_size, 0, 0, 1, 0, 0, buf, + block_size, 0, 0, 1, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); CU_ASSERT_EQUAL(ret, 0); } @@ -100,12 +99,12 @@ test_orwrite_dpofua(void) logging(LOG_VERBOSE, "Test ORWRITE with DPO==1 FUA==1"); if (dpofua) { ret = orwrite(sd, 0, block_size, - block_size, 0, 1, 1, 0, 0, buf, + block_size, 0, 1, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); } else { ret = orwrite(sd, 0, block_size, - block_size, 0, 1, 1, 0, 0, buf, + block_size, 0, 1, 1, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); CU_ASSERT_EQUAL(ret, 0); } diff --git a/test-tool/test_orwrite_simple.c b/test-tool/test_orwrite_simple.c index 3104d73..838bb25 100644 --- a/test-tool/test_orwrite_simple.c +++ b/test-tool/test_orwrite_simple.c @@ -31,20 +31,19 @@ void test_orwrite_simple(void) { int i, ret; - unsigned char *buf = alloca(256 * block_size); CHECK_FOR_DATALOSS; CHECK_FOR_SBC; logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test ORWRITE of 1-256 blocks at the start of the LUN"); - memset(buf, 0xa6, 256 * block_size); + memset(scratch, 0xa6, 256 * block_size); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } ret = orwrite(sd, 0, i * block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); if (ret == -2) { logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented."); @@ -60,7 +59,8 @@ test_orwrite_simple(void) break; } ret = orwrite(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, + 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); } diff --git a/test-tool/test_orwrite_verify.c b/test-tool/test_orwrite_verify.c index 021ee2b..47e01e9 100644 --- a/test-tool/test_orwrite_verify.c +++ b/test-tool/test_orwrite_verify.c @@ -32,8 +32,8 @@ void test_orwrite_verify(void) { int i, ret; - unsigned char *buf = alloca(256 * block_size); - unsigned char *readbuf = alloca(256 * block_size); + unsigned char *buf = &scratch[0]; + unsigned char *readbuf = &scratch[256 * block_size]; CHECK_FOR_DATALOSS; diff --git a/test-tool/test_orwrite_wrprotect.c b/test-tool/test_orwrite_wrprotect.c index 644d774..f3f9632 100644 --- a/test-tool/test_orwrite_wrprotect.c +++ b/test-tool/test_orwrite_wrprotect.c @@ -31,7 +31,6 @@ void test_orwrite_wrprotect(void) { int i, ret; - unsigned char *buf = alloca(block_size); /* * Try out different non-zero values for WRPROTECT. @@ -42,12 +41,12 @@ test_orwrite_wrprotect(void) CHECK_FOR_DATALOSS; CHECK_FOR_SBC; - memset(buf, 0xa6, block_size); + memset(scratch, 0xa6, block_size); if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); for (i = 1; i < 8; i++) { ret = orwrite(sd, 0, block_size, - block_size, i, 0, 0, 0, 0, buf, + block_size, i, 0, 0, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); if (ret == -2) { diff --git a/test-tool/test_prout_reserve_access.c b/test-tool/test_prout_reserve_access.c index 431cddb..1d84872 100644 --- a/test-tool/test_prout_reserve_access.c +++ b/test-tool/test_prout_reserve_access.c @@ -68,29 +68,28 @@ verify_persistent_reserve_access(struct scsi_device *sd1, struct scsi_device *sd pr_type); CU_ASSERT_EQUAL(0, ret); - read_write_buf = malloc(512); /* allocate a buffer */ - CU_ASSERT_PTR_NOT_NULL_FATAL(read_write_buf); + CU_ASSERT_PTR_NOT_NULL_FATAL(scratch); /* make sure init1 can read */ - ret = verify_read_works(sd1, read_write_buf); + ret = verify_read_works(sd1, scratch); CU_ASSERT_EQUAL(0, ret); /* make sure init1 can write */ - ret = verify_write_works(sd1, read_write_buf); + ret = verify_write_works(sd1, scratch); CU_ASSERT_EQUAL(0, ret); /* verify registered init2 read access */ if (reg_i2_can_read) - ret = verify_read_works(sd2, read_write_buf); + ret = verify_read_works(sd2, scratch); else - ret = verify_read_fails(sd2, read_write_buf); + ret = verify_read_fails(sd2, scratch); CU_ASSERT_EQUAL(0, ret); /* verify registered init2 write access */ if (reg_i2_can_write) - ret = verify_write_works(sd2, read_write_buf); + ret = verify_write_works(sd2, scratch); else - ret = verify_write_fails(sd2, read_write_buf); + ret = verify_write_fails(sd2, scratch); CU_ASSERT_EQUAL(0, ret); /* unregister init2 */ @@ -99,16 +98,16 @@ verify_persistent_reserve_access(struct scsi_device *sd1, struct scsi_device *sd /* verify unregistered init2 read access */ if (unreg_i2_can_read) - ret = verify_read_works(sd2, read_write_buf); + ret = verify_read_works(sd2, scratch); else - ret = verify_read_fails(sd2, read_write_buf); + ret = verify_read_fails(sd2, scratch); CU_ASSERT_EQUAL(0, ret); /* verify unregistered init2 write access */ if (unreg_i2_can_write) - ret = verify_write_works(sd2, read_write_buf); + ret = verify_write_works(sd2, scratch); else - ret = verify_write_fails(sd2, read_write_buf); + ret = verify_write_fails(sd2, scratch); CU_ASSERT_EQUAL(0, ret); /* release our reservation */ diff --git a/test-tool/test_read10_invalid.c b/test-tool/test_read10_invalid.c index 4303b9d..7d9eb4d 100644 --- a/test-tool/test_read10_invalid.c +++ b/test-tool/test_read10_invalid.c @@ -33,7 +33,6 @@ void test_read10_invalid(void) { struct iscsi_data data; - char *buf = alloca(block_size); struct scsi_task *task_ret; logging(LOG_VERBOSE, LOG_BLANK_LINE); @@ -246,9 +245,9 @@ test_read10_invalid(void) task->xfer_dir = SCSI_XFER_WRITE; task->expxferlen = block_size; - memset(buf, 0xa6, block_size); + memset(scratch, 0xa6, block_size); data.size = block_size; - data.data = (unsigned char *)buf; + data.data = (unsigned char *)scratch; iscsi_set_noautoreconnect(sd->iscsi_ctx, 1); iscsi_set_timeout(sd->iscsi_ctx, 3); diff --git a/test-tool/test_unmap_simple.c b/test-tool/test_unmap_simple.c index 228cb57..55c432c 100644 --- a/test-tool/test_unmap_simple.c +++ b/test-tool/test_unmap_simple.c @@ -27,13 +27,13 @@ #include "iscsi-test-cu.h" static void -init_lun_with_data(unsigned char *buf, uint64_t lba) +init_lun_with_data(uint64_t lba) { int ret; - memset(buf, 'a', 256 * block_size); + memset(scratch, 'a', 256 * block_size); ret = write10(sd, lba, 256 * block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); } @@ -43,7 +43,6 @@ test_unmap_simple(void) { int i, ret; struct unmap_list list[257]; - unsigned char *buf = alloca(256 * block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test basic UNMAP"); @@ -57,7 +56,7 @@ test_unmap_simple(void) "LUN as a single descriptor"); logging(LOG_VERBOSE, "Write 'a' to the first 256 LBAs"); - init_lun_with_data(buf, 0); + init_lun_with_data(0); for (i = 1; i <= 256; i++) { logging(LOG_VERBOSE, "UNMAP blocks 0-%d", i); @@ -69,14 +68,14 @@ test_unmap_simple(void) logging(LOG_VERBOSE, "Read blocks 0-%d", i); ret = read10(sd, NULL, 0, i * block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); if (rc16 && rc16->lbprz) { logging(LOG_VERBOSE, "LBPRZ==1 All UNMAPPED blocks " "should read back as 0"); - if (all_zeroes(buf, i * block_size) == 0) { + if (all_zeroes(scratch, i * block_size) == 0) { logging(LOG_NORMAL, "[FAILED] Blocks did not " "read back as zero"); CU_FAIL("[FAILED] Blocks did not read back " @@ -92,7 +91,7 @@ test_unmap_simple(void) "LUN with one descriptor per block"); logging(LOG_VERBOSE, "Write 'a' to the first 256 LBAs"); - init_lun_with_data(buf, 0); + init_lun_with_data(0); CU_ASSERT_EQUAL(ret, 0); for (i = 0; i < 256; i++) { @@ -104,14 +103,14 @@ test_unmap_simple(void) logging(LOG_VERBOSE, "Read blocks 0-%d", i); ret = read10(sd, NULL, 0, i * block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); if (rc16 && rc16->lbprz) { logging(LOG_VERBOSE, "LBPRZ==1 All UNMAPPED blocks " "should read back as 0"); - if (all_zeroes(buf, i * block_size) == 0) { + if (all_zeroes(scratch, i * block_size) == 0) { logging(LOG_NORMAL, "[FAILED] Blocks did not " "read back as zero"); CU_FAIL("[FAILED] Blocks did not read back " diff --git a/test-tool/test_verify10_beyond_eol.c b/test-tool/test_verify10_beyond_eol.c index 59ae3c3..ea3b418 100644 --- a/test-tool/test_verify10_beyond_eol.c +++ b/test-tool/test_verify10_beyond_eol.c @@ -30,7 +30,6 @@ void test_verify10_beyond_eol(void) { int i; - unsigned char *buf = alloca(256 * block_size); if (num_blocks >= 0x80000000) { CU_PASS("LUN is too big for read-beyond-eol tests with VERIFY10. Skipping test.\n"); @@ -39,13 +38,13 @@ test_verify10_beyond_eol(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY10 1-256 blocks one block beyond the end"); - memset(buf, 0xa6, 256 * block_size); + memset(scratch, 0xa6, 256 * block_size); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } VERIFY10(sd, num_blocks + 1 - i, - i * block_size, block_size, 0, 0, 1, buf, + i * block_size, block_size, 0, 0, 1, scratch, EXPECT_LBA_OOB); } @@ -55,7 +54,7 @@ test_verify10_beyond_eol(void) break; } VERIFY10(sd, 0x80000000, - i * block_size, block_size, 0, 0, 1, buf, + i * block_size, block_size, 0, 0, 1, scratch, EXPECT_LBA_OOB); } @@ -64,7 +63,7 @@ test_verify10_beyond_eol(void) if (maximum_transfer_length && maximum_transfer_length < i) { break; } - VERIFY10(sd, -1, i * block_size, block_size, 0, 0, 1, buf, + VERIFY10(sd, -1, i * block_size, block_size, 0, 0, 1, scratch, EXPECT_LBA_OOB); } @@ -75,7 +74,7 @@ test_verify10_beyond_eol(void) break; } VERIFY10(sd, num_blocks - 1, - i * block_size, block_size, 0, 0, 1, buf, + i * block_size, block_size, 0, 0, 1, scratch, EXPECT_LBA_OOB); } } diff --git a/test-tool/test_verify10_dpo.c b/test-tool/test_verify10_dpo.c index aa3e073..27b63c9 100644 --- a/test-tool/test_verify10_dpo.c +++ b/test-tool/test_verify10_dpo.c @@ -34,7 +34,6 @@ test_verify10_dpo(void) struct scsi_mode_sense *ms; struct scsi_task *rso_task = NULL; struct scsi_report_supported_op_codes_one_command *rsoc; - unsigned char *buf = alloca(block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY10 DPO flag"); @@ -42,7 +41,7 @@ test_verify10_dpo(void) CHECK_FOR_SBC; ret = read10(sd, NULL, 0, block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); @@ -66,10 +65,10 @@ test_verify10_dpo(void) logging(LOG_VERBOSE, "Test VERIFY10 with DPO==1"); if (dpofua) { - VERIFY10(sd, 0, block_size, block_size, 0, 1, 0, buf, + VERIFY10(sd, 0, block_size, block_size, 0, 1, 0, scratch, EXPECT_STATUS_GOOD); } else { - VERIFY10(sd, 0, block_size, block_size, 0, 1, 0, buf, + VERIFY10(sd, 0, block_size, block_size, 0, 1, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); } diff --git a/test-tool/test_verify10_flags.c b/test-tool/test_verify10_flags.c index 97c7598..b1865d5 100644 --- a/test-tool/test_verify10_flags.c +++ b/test-tool/test_verify10_flags.c @@ -30,18 +30,17 @@ void test_verify10_flags(void) { int ret; - unsigned char *buf = alloca(block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY10 flags"); ret = read10(sd, NULL, 0, block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); logging(LOG_VERBOSE, "Test VERIFY10 with BYTCHK==1"); - VERIFY10(sd, 0, block_size, block_size, 0, 0, 1, buf, + VERIFY10(sd, 0, block_size, block_size, 0, 0, 1, scratch, EXPECT_STATUS_GOOD); } diff --git a/test-tool/test_verify10_mismatch.c b/test-tool/test_verify10_mismatch.c index 90ff600..a6be763 100644 --- a/test-tool/test_verify10_mismatch.c +++ b/test-tool/test_verify10_mismatch.c @@ -31,7 +31,6 @@ void test_verify10_mismatch(void) { int i, ret; - unsigned char *buf = alloca(256 * block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY10 for blocks 1-255"); @@ -42,15 +41,15 @@ test_verify10_mismatch(void) break; } ret = read10(sd, NULL, 0, i * block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); /* flip a random byte in the data */ - buf[offset] ^= 'X'; + scratch[offset] ^= 'X'; logging(LOG_VERBOSE, "Flip some bits in the data"); - VERIFY10(sd, 0, i * block_size, block_size, 0, 0, 1, buf, + VERIFY10(sd, 0, i * block_size, block_size, 0, 0, 1, scratch, EXPECT_MISCOMPARE); } @@ -62,16 +61,16 @@ test_verify10_mismatch(void) break; } ret = read10(sd, NULL, num_blocks - i, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); /* flip a random byte in the data */ - buf[offset] ^= 'X'; + scratch[offset] ^= 'X'; logging(LOG_VERBOSE, "Flip some bits in the data"); VERIFY10(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 1, buf, + i * block_size, block_size, 0, 0, 1, scratch, EXPECT_MISCOMPARE); } } diff --git a/test-tool/test_verify10_mismatch_no_cmp.c b/test-tool/test_verify10_mismatch_no_cmp.c index 0faa3c0..d9517f8 100644 --- a/test-tool/test_verify10_mismatch_no_cmp.c +++ b/test-tool/test_verify10_mismatch_no_cmp.c @@ -31,7 +31,6 @@ void test_verify10_mismatch_no_cmp(void) { int i, ret; - unsigned char *buf = alloca(256 * block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY10 without BYTCHK for blocks 1-255"); @@ -42,15 +41,15 @@ test_verify10_mismatch_no_cmp(void) break; } ret = read10(sd, NULL, 0, i * block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); /* flip a random byte in the data */ - buf[offset] ^= 'X'; + scratch[offset] ^= 'X'; logging(LOG_VERBOSE, "Flip some bits in the data"); - VERIFY10(sd, 0, i * block_size, block_size, 0, 0, 0, buf, + VERIFY10(sd, 0, i * block_size, block_size, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); } @@ -62,16 +61,16 @@ test_verify10_mismatch_no_cmp(void) break; } ret = read10(sd, NULL, num_blocks - i, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); /* flip a random byte in the data */ - buf[offset] ^= 'X'; + scratch[offset] ^= 'X'; logging(LOG_VERBOSE, "Flip some bits in the data"); VERIFY10(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); } } diff --git a/test-tool/test_verify10_simple.c b/test-tool/test_verify10_simple.c index 9f28166..a3d22ee 100644 --- a/test-tool/test_verify10_simple.c +++ b/test-tool/test_verify10_simple.c @@ -31,7 +31,6 @@ void test_verify10_simple(void) { int i, ret; - unsigned char *buf = alloca(256 * block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY10 of 1-256 blocks at the start of the LUN"); @@ -40,11 +39,11 @@ test_verify10_simple(void) break; } ret = read10(sd, NULL, 0, i * block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); - VERIFY10(sd, 0, i * block_size, block_size, 0, 0, 1, buf, + VERIFY10(sd, 0, i * block_size, block_size, 0, 0, 1, scratch, EXPECT_STATUS_GOOD); } @@ -54,12 +53,12 @@ test_verify10_simple(void) break; } ret = read10(sd, NULL, num_blocks - i, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); VERIFY10(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 1, buf, + i * block_size, block_size, 0, 0, 1, scratch, EXPECT_STATUS_GOOD); } } diff --git a/test-tool/test_verify10_vrprotect.c b/test-tool/test_verify10_vrprotect.c index e7aec87..086a4ae 100644 --- a/test-tool/test_verify10_vrprotect.c +++ b/test-tool/test_verify10_vrprotect.c @@ -31,7 +31,6 @@ void test_verify10_vrprotect(void) { int i, ret; - unsigned char *buf = alloca(block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY10 with non-zero VRPROTECT"); @@ -42,12 +41,12 @@ test_verify10_vrprotect(void) logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); for (i = 1; i < 8; i++) { ret = read10(sd, NULL, 0, block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); VERIFY10(sd, 0, block_size, - block_size, i, 0, 1, buf, + block_size, i, 0, 1, scratch, EXPECT_INVALID_FIELD_IN_CDB); } return; diff --git a/test-tool/test_verify12_beyond_eol.c b/test-tool/test_verify12_beyond_eol.c index 1b13ffa..b08379e 100644 --- a/test-tool/test_verify12_beyond_eol.c +++ b/test-tool/test_verify12_beyond_eol.c @@ -30,7 +30,6 @@ void test_verify12_beyond_eol(void) { int i; - unsigned char *buf = alloca(256 * block_size); if (num_blocks >= 0x80000000) { CU_PASS("LUN is too big for read-beyond-eol tests with VERIFY12. Skipping test.\n"); @@ -39,13 +38,13 @@ test_verify12_beyond_eol(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY12 1-256 blocks one block beyond the end"); - memset(buf, 0xa6, 256 * block_size); + memset(scratch, 0xa6, 256 * block_size); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } VERIFY12(sd, num_blocks + 1 - i, - i * block_size, block_size, 0, 0, 1, buf, + i * block_size, block_size, 0, 0, 1, scratch, EXPECT_LBA_OOB); } @@ -55,7 +54,7 @@ test_verify12_beyond_eol(void) break; } VERIFY12(sd, 0x80000000, - i * block_size, block_size, 0, 0, 1, buf, + i * block_size, block_size, 0, 0, 1, scratch, EXPECT_LBA_OOB); } @@ -65,7 +64,7 @@ test_verify12_beyond_eol(void) break; } VERIFY12(sd, -1, i * block_size, - block_size, 0, 0, 1, buf, + block_size, 0, 0, 1, scratch, EXPECT_LBA_OOB); } @@ -75,7 +74,7 @@ test_verify12_beyond_eol(void) break; } VERIFY12(sd, num_blocks - 1, - i * block_size, block_size, 0, 0, 1, buf, + i * block_size, block_size, 0, 0, 1, scratch, EXPECT_LBA_OOB); } } diff --git a/test-tool/test_verify12_dpo.c b/test-tool/test_verify12_dpo.c index 9bde476..b62766d 100644 --- a/test-tool/test_verify12_dpo.c +++ b/test-tool/test_verify12_dpo.c @@ -34,7 +34,6 @@ test_verify12_dpo(void) struct scsi_mode_sense *ms; struct scsi_task *rso_task = NULL; struct scsi_report_supported_op_codes_one_command *rsoc; - unsigned char *buf = alloca(block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY12 DPO flag"); @@ -42,7 +41,7 @@ test_verify12_dpo(void) CHECK_FOR_SBC; ret = read10(sd, NULL, 0, block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); @@ -66,10 +65,10 @@ test_verify12_dpo(void) logging(LOG_VERBOSE, "Test VERIFY12 with DPO==1"); if (dpofua) { - VERIFY12(sd, 0, block_size, block_size, 0, 1, 0, buf, + VERIFY12(sd, 0, block_size, block_size, 0, 1, 0, scratch, EXPECT_STATUS_GOOD); } else { - VERIFY12(sd, 0, block_size, block_size, 0, 1, 0, buf, + VERIFY12(sd, 0, block_size, block_size, 0, 1, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); } diff --git a/test-tool/test_verify12_flags.c b/test-tool/test_verify12_flags.c index c2f00e6..d19f193 100644 --- a/test-tool/test_verify12_flags.c +++ b/test-tool/test_verify12_flags.c @@ -31,18 +31,17 @@ void test_verify12_flags(void) { int ret; - unsigned char *buf = alloca(block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY12 flags"); ret = read12(sd, NULL, 0, block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); logging(LOG_VERBOSE, "Test VERIFY12 with BYTCHK==1"); - VERIFY12(sd, 0, block_size, block_size, 0, 0, 1, buf, + VERIFY12(sd, 0, block_size, block_size, 0, 0, 1, scratch, EXPECT_STATUS_GOOD); } diff --git a/test-tool/test_verify12_mismatch.c b/test-tool/test_verify12_mismatch.c index 8703e6e..6672249 100644 --- a/test-tool/test_verify12_mismatch.c +++ b/test-tool/test_verify12_mismatch.c @@ -31,7 +31,6 @@ void test_verify12_mismatch(void) { int i, ret; - unsigned char *buf = alloca(256 * block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY12 for blocks 1-255"); @@ -42,14 +41,14 @@ test_verify12_mismatch(void) break; } ret = read12(sd, NULL, 0, i * block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); /* flip a random byte in the data */ - buf[offset] ^= 'X'; + scratch[offset] ^= 'X'; logging(LOG_VERBOSE, "Flip some bits in the data"); - VERIFY12(sd, 0, i * block_size, block_size, 0, 0, 1, buf, + VERIFY12(sd, 0, i * block_size, block_size, 0, 0, 1, scratch, EXPECT_MISCOMPARE); } @@ -61,16 +60,16 @@ test_verify12_mismatch(void) break; } ret = read12(sd, NULL, num_blocks - i, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); /* flip a random byte in the data */ - buf[offset] ^= 'X'; + scratch[offset] ^= 'X'; logging(LOG_VERBOSE, "Flip some bits in the data"); VERIFY12(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 1, buf, + i * block_size, block_size, 0, 0, 1, scratch, EXPECT_MISCOMPARE); } } diff --git a/test-tool/test_verify12_mismatch_no_cmp.c b/test-tool/test_verify12_mismatch_no_cmp.c index a2d8126..c4e6bf1 100644 --- a/test-tool/test_verify12_mismatch_no_cmp.c +++ b/test-tool/test_verify12_mismatch_no_cmp.c @@ -31,7 +31,6 @@ void test_verify12_mismatch_no_cmp(void) { int i, ret; - unsigned char *buf = alloca(256 * block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY12 without BYTCHK for blocks 1-255"); @@ -42,14 +41,14 @@ test_verify12_mismatch_no_cmp(void) break; } ret = read12(sd, NULL, 0, i * block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); /* flip a random byte in the data */ - buf[offset] ^= 'X'; + scratch[offset] ^= 'X'; logging(LOG_VERBOSE, "Flip some bits in the data"); - VERIFY12(sd, 0, i * block_size, block_size, 0, 0, 0, buf, + VERIFY12(sd, 0, i * block_size, block_size, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); } @@ -61,16 +60,16 @@ test_verify12_mismatch_no_cmp(void) break; } ret = read12(sd, NULL, num_blocks - i, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); /* flip a random byte in the data */ - buf[offset] ^= 'X'; + scratch[offset] ^= 'X'; logging(LOG_VERBOSE, "Flip some bits in the data"); VERIFY12(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); } } diff --git a/test-tool/test_verify12_simple.c b/test-tool/test_verify12_simple.c index 64c8824..921d4a9 100644 --- a/test-tool/test_verify12_simple.c +++ b/test-tool/test_verify12_simple.c @@ -31,7 +31,6 @@ void test_verify12_simple(void) { int i, ret; - unsigned char *buf = alloca(256 * block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY12 of 1-256 blocks at the start of the LUN"); @@ -40,11 +39,11 @@ test_verify12_simple(void) break; } ret = read10(sd, NULL, 0, i * block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); - VERIFY12(sd, 0, i * block_size, block_size, 0, 0, 1, buf, + VERIFY12(sd, 0, i * block_size, block_size, 0, 0, 1, scratch, EXPECT_STATUS_GOOD); } @@ -54,12 +53,12 @@ test_verify12_simple(void) break; } ret = read12(sd, NULL, num_blocks - i, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); VERIFY12(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 1, buf, + i * block_size, block_size, 0, 0, 1, scratch, EXPECT_STATUS_GOOD); } } diff --git a/test-tool/test_verify12_vrprotect.c b/test-tool/test_verify12_vrprotect.c index d68ee43..900d781 100644 --- a/test-tool/test_verify12_vrprotect.c +++ b/test-tool/test_verify12_vrprotect.c @@ -31,7 +31,6 @@ void test_verify12_vrprotect(void) { int i, ret; - unsigned char *buf = alloca(block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY12 with non-zero VRPROTECT"); @@ -43,12 +42,12 @@ test_verify12_vrprotect(void) for (i = 1; i < 8; i++) { ret = read10(sd, NULL, 0, block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); VERIFY12(sd, 0, block_size, - block_size, i, 0, 1, buf, + block_size, i, 0, 1, scratch, EXPECT_INVALID_FIELD_IN_CDB); } return; diff --git a/test-tool/test_verify16_beyond_eol.c b/test-tool/test_verify16_beyond_eol.c index 72e095c..0f49083 100644 --- a/test-tool/test_verify16_beyond_eol.c +++ b/test-tool/test_verify16_beyond_eol.c @@ -30,18 +30,16 @@ void test_verify16_beyond_eol(void) { int i; - unsigned char *buf = alloca(256 * block_size); - logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY16 1-256 blocks one block beyond the end"); - memset(buf, 0xa6, 256 * block_size); + memset(scratch, 0xa6, 256 * block_size); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } VERIFY16(sd, num_blocks + 1 - i, - i * block_size, block_size, 0, 0, 1, buf, + i * block_size, block_size, 0, 0, 1, scratch, EXPECT_LBA_OOB); } @@ -51,7 +49,7 @@ test_verify16_beyond_eol(void) break; } VERIFY16(sd, 0x8000000000000000ULL, - i * block_size, block_size, 0, 0, 1, buf, + i * block_size, block_size, 0, 0, 1, scratch, EXPECT_LBA_OOB); } @@ -60,7 +58,7 @@ test_verify16_beyond_eol(void) if (maximum_transfer_length && maximum_transfer_length < i) { break; } - VERIFY16(sd, -1, i * block_size, block_size, 0, 0, 1, buf, + VERIFY16(sd, -1, i * block_size, block_size, 0, 0, 1, scratch, EXPECT_LBA_OOB); } @@ -70,7 +68,7 @@ test_verify16_beyond_eol(void) break; } VERIFY16(sd, num_blocks - 1, - i * block_size, block_size, 0, 0, 1, buf, + i * block_size, block_size, 0, 0, 1, scratch, EXPECT_LBA_OOB); } } diff --git a/test-tool/test_verify16_dpo.c b/test-tool/test_verify16_dpo.c index 568ad11..8f0b32f 100644 --- a/test-tool/test_verify16_dpo.c +++ b/test-tool/test_verify16_dpo.c @@ -34,7 +34,6 @@ test_verify16_dpo(void) struct scsi_mode_sense *ms; struct scsi_task *rso_task = NULL; struct scsi_report_supported_op_codes_one_command *rsoc; - unsigned char *buf = alloca(block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY16 DPO flag"); @@ -42,7 +41,7 @@ test_verify16_dpo(void) CHECK_FOR_SBC; ret = read10(sd, NULL, 0, block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); @@ -66,10 +65,10 @@ test_verify16_dpo(void) logging(LOG_VERBOSE, "Test VERIFY16 with DPO==1"); if (dpofua) { - VERIFY16(sd, 0, block_size, block_size, 0, 1, 0, buf, + VERIFY16(sd, 0, block_size, block_size, 0, 1, 0, scratch, EXPECT_STATUS_GOOD); } else { - VERIFY16(sd, 0, block_size, block_size, 0, 1, 0, buf, + VERIFY16(sd, 0, block_size, block_size, 0, 1, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); } diff --git a/test-tool/test_verify16_flags.c b/test-tool/test_verify16_flags.c index df91fbb..99ea1cf 100644 --- a/test-tool/test_verify16_flags.c +++ b/test-tool/test_verify16_flags.c @@ -31,17 +31,16 @@ void test_verify16_flags(void) { int ret; - unsigned char *buf = alloca(block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY16 flags"); ret = read16(sd, NULL, 0, block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); logging(LOG_VERBOSE, "Test VERIFY16 with BYTCHK==1"); - VERIFY16(sd, 0, block_size, block_size, 0, 0, 1, buf, + VERIFY16(sd, 0, block_size, block_size, 0, 0, 1, scratch, EXPECT_STATUS_GOOD); } diff --git a/test-tool/test_verify16_mismatch.c b/test-tool/test_verify16_mismatch.c index 01ceaa7..9177e1b 100644 --- a/test-tool/test_verify16_mismatch.c +++ b/test-tool/test_verify16_mismatch.c @@ -31,7 +31,6 @@ void test_verify16_mismatch(void) { int i, ret; - unsigned char *buf = alloca(256 * block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY16 for blocks 1-255"); @@ -43,14 +42,14 @@ test_verify16_mismatch(void) } ret = read16(sd, NULL, 0, i * block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); /* flip a random byte in the data */ - buf[offset] ^= 'X'; + scratch[offset] ^= 'X'; logging(LOG_VERBOSE, "Flip some bits in the data"); - VERIFY16(sd, 0, i * block_size, block_size, 0, 0, 1, buf, + VERIFY16(sd, 0, i * block_size, block_size, 0, 0, 1, scratch, EXPECT_MISCOMPARE); } @@ -63,16 +62,16 @@ test_verify16_mismatch(void) } ret = read16(sd, NULL, num_blocks - i, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); /* flip a random byte in the data */ - buf[offset] ^= 'X'; + scratch[offset] ^= 'X'; logging(LOG_VERBOSE, "Flip some bits in the data"); VERIFY16(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 1, buf, + i * block_size, block_size, 0, 0, 1, scratch, EXPECT_MISCOMPARE); } } diff --git a/test-tool/test_verify16_mismatch_no_cmp.c b/test-tool/test_verify16_mismatch_no_cmp.c index e6b3df1..50e7957 100644 --- a/test-tool/test_verify16_mismatch_no_cmp.c +++ b/test-tool/test_verify16_mismatch_no_cmp.c @@ -31,7 +31,6 @@ void test_verify16_mismatch_no_cmp(void) { int i, ret; - unsigned char *buf = alloca(256 * block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY16 without BYTCHK for blocks 1-255"); @@ -43,14 +42,14 @@ test_verify16_mismatch_no_cmp(void) } ret = read16(sd, NULL, 0, i * block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); /* flip a random byte in the data */ - buf[offset] ^= 'X'; + scratch[offset] ^= 'X'; logging(LOG_VERBOSE, "Flip some bits in the data"); - VERIFY16(sd, 0, i * block_size, block_size, 0, 0, 0, buf, + VERIFY16(sd, 0, i * block_size, block_size, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); } @@ -63,16 +62,16 @@ test_verify16_mismatch_no_cmp(void) } ret = read16(sd, NULL, num_blocks - i, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); /* flip a random byte in the data */ - buf[offset] ^= 'X'; + scratch[offset] ^= 'X'; logging(LOG_VERBOSE, "Flip some bits in the data"); VERIFY16(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); } } diff --git a/test-tool/test_verify16_simple.c b/test-tool/test_verify16_simple.c index 659f6ee..4e786df 100644 --- a/test-tool/test_verify16_simple.c +++ b/test-tool/test_verify16_simple.c @@ -31,7 +31,6 @@ void test_verify16_simple(void) { int i, ret; - unsigned char *buf = alloca(256 * block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY16 of 1-256 blocks at the start of the LUN"); @@ -40,10 +39,10 @@ test_verify16_simple(void) break; } ret = read10(sd, NULL, 0, i * block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); VERIFY16(sd, 0, i * block_size, - block_size, 0, 0, 1, buf, + block_size, 0, 0, 1, scratch, EXPECT_STATUS_GOOD); } @@ -54,12 +53,12 @@ test_verify16_simple(void) } ret = read16(sd, NULL, num_blocks - i, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); VERIFY16(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 1, buf, + i * block_size, block_size, 0, 0, 1, scratch, EXPECT_STATUS_GOOD); } } diff --git a/test-tool/test_verify16_vrprotect.c b/test-tool/test_verify16_vrprotect.c index 7676597..73fad58 100644 --- a/test-tool/test_verify16_vrprotect.c +++ b/test-tool/test_verify16_vrprotect.c @@ -31,7 +31,6 @@ void test_verify16_vrprotect(void) { int i, ret; - unsigned char *buf = alloca(block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY16 with non-zero VRPROTECT"); @@ -42,12 +41,12 @@ test_verify16_vrprotect(void) logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); for (i = 1; i < 8; i++) { ret = read16(sd, NULL, 0, block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); VERIFY16(sd, 0, block_size, - block_size, i, 0, 1, buf, + block_size, i, 0, 1, scratch, EXPECT_INVALID_FIELD_IN_CDB); } return; diff --git a/test-tool/test_write10_beyond_eol.c b/test-tool/test_write10_beyond_eol.c index 45d5e09..244fa6a 100644 --- a/test-tool/test_write10_beyond_eol.c +++ b/test-tool/test_write10_beyond_eol.c @@ -30,7 +30,6 @@ void test_write10_beyond_eol(void) { int i; - unsigned char *buf = alloca(256 * block_size); CHECK_FOR_DATALOSS; @@ -41,13 +40,13 @@ test_write10_beyond_eol(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITE10 1-256 blocks one block beyond the end"); - memset(buf, 0xa6, 256 * block_size); + memset(scratch, 0xa6, 256 * block_size); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } WRITE10(sd, num_blocks + 1 - i, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); } @@ -57,7 +56,7 @@ test_write10_beyond_eol(void) break; } WRITE10(sd, 0x80000000, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); } @@ -67,7 +66,7 @@ test_write10_beyond_eol(void) break; } WRITE10(sd, -1, i * block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); } @@ -77,7 +76,7 @@ test_write10_beyond_eol(void) break; } WRITE10(sd, num_blocks - 1, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); } } diff --git a/test-tool/test_write10_dpofua.c b/test-tool/test_write10_dpofua.c index 8717c04..9d5a973 100644 --- a/test-tool/test_write10_dpofua.c +++ b/test-tool/test_write10_dpofua.c @@ -34,7 +34,6 @@ test_write10_dpofua(void) struct scsi_mode_sense *ms; struct scsi_task *rso_task = NULL; struct scsi_report_supported_op_codes_one_command *rsoc; - unsigned char *buf = alloca(block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITE10 DPO/FUA flags"); @@ -61,31 +60,31 @@ test_write10_dpofua(void) } logging(LOG_VERBOSE, "Test WRITE10 with DPO==1"); - memset(buf, 0xa6, block_size); + memset(scratch, 0xa6, block_size); if (dpofua) { - WRITE10(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, buf, + WRITE10(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); } else { - WRITE10(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, buf, + WRITE10(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); } logging(LOG_VERBOSE, "Test WRITE10 with FUA==1"); if (dpofua) { - WRITE10(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, buf, + WRITE10(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); } else { - WRITE10(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, buf, + WRITE10(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); } logging(LOG_VERBOSE, "Test WRITE10 with DPO==1 FUA==1"); if (dpofua) { - WRITE10(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, buf, + WRITE10(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); } else { - WRITE10(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, buf, + WRITE10(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); } diff --git a/test-tool/test_write10_flags.c b/test-tool/test_write10_flags.c index 2abeba8..284bdae 100644 --- a/test-tool/test_write10_flags.c +++ b/test-tool/test_write10_flags.c @@ -29,32 +29,30 @@ void test_write10_flags(void) -{ - unsigned char *buf = alloca(block_size); - +{ CHECK_FOR_DATALOSS; logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITE10 flags"); logging(LOG_VERBOSE, "Test WRITE10 with DPO==1"); - memset(buf, 0xa6, block_size); - WRITE10(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, buf, + memset(scratch, 0xa6, block_size); + WRITE10(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Test WRITE10 with FUA==1 FUA_NV==0"); - WRITE10(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, buf, + WRITE10(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Test WRITE10 with FUA==1 FUA_NV==1"); - WRITE10(sd, 0, block_size, block_size, 0, 0, 1, 1, 0, buf, + WRITE10(sd, 0, block_size, block_size, 0, 0, 1, 1, 0, scratch, EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Test WRITE10 with FUA==0 FUA_NV==1"); - WRITE10(sd, 0, block_size, block_size, 0, 0, 0, 1, 0, buf, + WRITE10(sd, 0, block_size, block_size, 0, 0, 0, 1, 0, scratch, EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Test WRITE10 with DPO==1 FUA==1 FUA_NV==1"); - WRITE10(sd, 0, block_size, block_size, 0, 1, 1, 1, 0, buf, + WRITE10(sd, 0, block_size, block_size, 0, 1, 1, 1, 0, scratch, EXPECT_STATUS_GOOD); } diff --git a/test-tool/test_write10_simple.c b/test-tool/test_write10_simple.c index b4a341f..d5a4dc2 100644 --- a/test-tool/test_write10_simple.c +++ b/test-tool/test_write10_simple.c @@ -31,19 +31,18 @@ void test_write10_simple(void) { int i; - unsigned char *buf = alloca(256 * block_size); - CHECK_FOR_DATALOSS; logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITE10 of 1-256 blocks at the start of the LUN"); - memset(buf, 0xa6, 256 * block_size); + memset(scratch, 0xa6, 256 * block_size); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } - WRITE10(sd, 0, i * block_size, block_size, 0, 0, 0, 0, 0, buf, + WRITE10(sd, 0, i * block_size, block_size, + 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); } @@ -53,7 +52,7 @@ test_write10_simple(void) break; } WRITE10(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); } } diff --git a/test-tool/test_write10_wrprotect.c b/test-tool/test_write10_wrprotect.c index fbe8567..07a3a8a 100644 --- a/test-tool/test_write10_wrprotect.c +++ b/test-tool/test_write10_wrprotect.c @@ -31,7 +31,6 @@ void test_write10_wrprotect(void) { int i; - unsigned char *buf = alloca(block_size); /* * Try out different non-zero values for WRPROTECT. @@ -42,12 +41,12 @@ test_write10_wrprotect(void) CHECK_FOR_DATALOSS; CHECK_FOR_SBC; - memset(buf, 0xa6, block_size); + memset(scratch, 0xa6, block_size); if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); for (i = 1; i < 8; i++) { WRITE10(sd, 0, block_size, block_size, - i, 0, 0, 0, 0, buf, + i, 0, 0, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); } return; diff --git a/test-tool/test_write12_beyond_eol.c b/test-tool/test_write12_beyond_eol.c index f22ff73..eeb8c24 100644 --- a/test-tool/test_write12_beyond_eol.c +++ b/test-tool/test_write12_beyond_eol.c @@ -30,7 +30,6 @@ void test_write12_beyond_eol(void) { int i; - unsigned char *buf = alloca(256 * block_size); CHECK_FOR_DATALOSS; @@ -41,13 +40,13 @@ test_write12_beyond_eol(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITE12 1-256 blocks one block beyond the end"); - memset(buf, 0xa6, 256 * block_size); + memset(scratch, 0xa6, 256 * block_size); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } WRITE12(sd, num_blocks + 1 - i, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); } @@ -57,7 +56,7 @@ test_write12_beyond_eol(void) break; } WRITE12(sd, 0x80000000, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); } @@ -67,7 +66,7 @@ test_write12_beyond_eol(void) break; } WRITE12(sd, -1, i * block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); } @@ -77,7 +76,7 @@ test_write12_beyond_eol(void) break; } WRITE12(sd, num_blocks - 1, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); } } diff --git a/test-tool/test_write12_dpofua.c b/test-tool/test_write12_dpofua.c index f3fc3e4..0437dd9 100644 --- a/test-tool/test_write12_dpofua.c +++ b/test-tool/test_write12_dpofua.c @@ -34,7 +34,6 @@ test_write12_dpofua(void) struct scsi_mode_sense *ms; struct scsi_task *rso_task = NULL; struct scsi_report_supported_op_codes_one_command *rsoc; - unsigned char *buf = alloca(block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITE12 DPO/FUA flags"); @@ -61,30 +60,30 @@ test_write12_dpofua(void) } logging(LOG_VERBOSE, "Test WRITE12 with DPO==1"); - memset(buf, 0xa6, block_size); + memset(scratch, 0xa6, block_size); if (dpofua) { - WRITE12(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, buf, + WRITE12(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); } else { - WRITE12(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, buf, + WRITE12(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); } logging(LOG_VERBOSE, "Test WRITE12 with FUA==1"); if (dpofua) { - WRITE12(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, buf, + WRITE12(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); } else { - WRITE12(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, buf, + WRITE12(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); } logging(LOG_VERBOSE, "Test WRITE12 with DPO==1 FUA==1"); if (dpofua) { - WRITE12(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, buf, + WRITE12(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); } else { - WRITE12(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, buf, + WRITE12(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); } diff --git a/test-tool/test_write12_flags.c b/test-tool/test_write12_flags.c index c89bc81..7ee2a4f 100644 --- a/test-tool/test_write12_flags.c +++ b/test-tool/test_write12_flags.c @@ -29,32 +29,30 @@ void test_write12_flags(void) -{ - unsigned char *buf = alloca(block_size); - +{ CHECK_FOR_DATALOSS; logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITE12 flags"); logging(LOG_VERBOSE, "Test WRITE12 with DPO==1"); - memset(buf, 0xa6, block_size); - WRITE12(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, buf, + memset(scratch, 0xa6, block_size); + WRITE12(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Test WRITE12 with FUA==1 FUA_NV==0"); - WRITE12(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, buf, + WRITE12(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Test WRITE12 with FUA==1 FUA_NV==1"); - WRITE12(sd, 0, block_size, block_size, 0, 0, 1, 1, 0, buf, + WRITE12(sd, 0, block_size, block_size, 0, 0, 1, 1, 0, scratch, EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Test WRITE12 with FUA==0 FUA_NV==1"); - WRITE12(sd, 0, block_size, block_size, 0, 0, 0, 1, 0, buf, + WRITE12(sd, 0, block_size, block_size, 0, 0, 0, 1, 0, scratch, EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Test WRITE12 with DPO==1 FUA==1 FUA_NV==1"); - WRITE12(sd, 0, block_size, block_size, 0, 1, 1, 1, 0, buf, + WRITE12(sd, 0, block_size, block_size, 0, 1, 1, 1, 0, scratch, EXPECT_STATUS_GOOD); } diff --git a/test-tool/test_write12_simple.c b/test-tool/test_write12_simple.c index bb6ab3a..6741225 100644 --- a/test-tool/test_write12_simple.c +++ b/test-tool/test_write12_simple.c @@ -31,18 +31,18 @@ void test_write12_simple(void) { int i; - unsigned char *buf = alloca(256 * block_size); - + CHECK_FOR_DATALOSS; logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITE12 of 1-256 blocks at the start of the LUN"); - memset(buf, 0xa6, 256 * block_size); + memset(scratch, 0xa6, 256 * block_size); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } - WRITE12(sd, 0, i * block_size, block_size, 0, 0, 0, 0, 0, buf, + WRITE12(sd, 0, i * block_size, block_size, + 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); } @@ -52,7 +52,7 @@ test_write12_simple(void) break; } WRITE12(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); } } diff --git a/test-tool/test_write12_wrprotect.c b/test-tool/test_write12_wrprotect.c index f2831e9..faa6046 100644 --- a/test-tool/test_write12_wrprotect.c +++ b/test-tool/test_write12_wrprotect.c @@ -31,8 +31,6 @@ void test_write12_wrprotect(void) { int i; - unsigned char *buf = alloca(block_size); - /* * Try out different non-zero values for WRPROTECT. @@ -43,12 +41,12 @@ test_write12_wrprotect(void) CHECK_FOR_DATALOSS; CHECK_FOR_SBC; - memset(buf, 0xa6, block_size); + memset(scratch, 0xa6, block_size); if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); for (i = 1; i < 8; i++) { WRITE12(sd, 0, block_size, block_size, - i, 0, 0, 0, 0, buf, + i, 0, 0, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); } return; diff --git a/test-tool/test_write16_beyond_eol.c b/test-tool/test_write16_beyond_eol.c index ab84bcd..29b7982 100644 --- a/test-tool/test_write16_beyond_eol.c +++ b/test-tool/test_write16_beyond_eol.c @@ -30,21 +30,19 @@ void test_write16_beyond_eol(void) { int i; - unsigned char *buf = alloca(256 * block_size); - - + CHECK_FOR_DATALOSS; CHECK_FOR_SBC; logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITE16 1-256 blocks one block beyond the end"); - memset(buf, 0xa6, 256 * block_size); + memset(scratch, 0xa6, 256 * block_size); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } WRITE16(sd, num_blocks + 1 - i, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); } @@ -54,7 +52,7 @@ test_write16_beyond_eol(void) break; } WRITE16(sd, 0x8000000000000000ULL, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); } @@ -64,7 +62,7 @@ test_write16_beyond_eol(void) break; } WRITE16(sd, -1, i * block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); } @@ -74,7 +72,7 @@ test_write16_beyond_eol(void) break; } WRITE16(sd, num_blocks - 1, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); } } diff --git a/test-tool/test_write16_dpofua.c b/test-tool/test_write16_dpofua.c index 219c4d2..026e577 100644 --- a/test-tool/test_write16_dpofua.c +++ b/test-tool/test_write16_dpofua.c @@ -34,7 +34,6 @@ test_write16_dpofua(void) struct scsi_mode_sense *ms; struct scsi_task *rso_task = NULL; struct scsi_report_supported_op_codes_one_command *rsoc; - unsigned char *buf = alloca(block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITE16 DPO/FUA flags"); @@ -61,31 +60,31 @@ test_write16_dpofua(void) } logging(LOG_VERBOSE, "Test WRITE16 with DPO==1"); - memset(buf, 0xa6, block_size); + memset(scratch, 0xa6, block_size); if (dpofua) { - WRITE16(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, buf, + WRITE16(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); } else { - WRITE16(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, buf, + WRITE16(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); } logging(LOG_VERBOSE, "Test WRITE16 with FUA==1"); if (dpofua) { - WRITE16(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, buf, + WRITE16(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); } else { - WRITE16(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, buf, + WRITE16(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); } logging(LOG_VERBOSE, "Test WRITE16 with DPO==1 FUA==1"); if (dpofua) { - WRITE16(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, buf, + WRITE16(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); } else { - WRITE16(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, buf, + WRITE16(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); } diff --git a/test-tool/test_write16_flags.c b/test-tool/test_write16_flags.c index 84317bb..c67e072 100644 --- a/test-tool/test_write16_flags.c +++ b/test-tool/test_write16_flags.c @@ -30,8 +30,6 @@ void test_write16_flags(void) { - unsigned char *buf = alloca(block_size); - CHECK_FOR_DATALOSS; CHECK_FOR_SBC; @@ -39,23 +37,23 @@ test_write16_flags(void) logging(LOG_VERBOSE, "Test WRITE16 flags"); logging(LOG_VERBOSE, "Test WRITE16 with DPO==1"); - memset(buf, 0xa6, block_size); - WRITE16(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, buf, + memset(scratch, 0xa6, block_size); + WRITE16(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Test WRITE16 with FUA==1 FUA_NV==0"); - WRITE16(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, buf, + WRITE16(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Test WRITE16 with FUA==1 FUA_NV==1"); - WRITE16(sd, 0, block_size, block_size, 0, 0, 1, 1, 0, buf, + WRITE16(sd, 0, block_size, block_size, 0, 0, 1, 1, 0, scratch, EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Test WRITE16 with FUA==0 FUA_NV==1"); - WRITE16(sd, 0, block_size, block_size, 0, 0, 0, 1, 0, buf, + WRITE16(sd, 0, block_size, block_size, 0, 0, 0, 1, 0, scratch, EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Test WRITE16 with DPO==1 FUA==1 FUA_NV==1"); - WRITE16(sd, 0, block_size, block_size, 0, 1, 1, 1, 0, buf, + WRITE16(sd, 0, block_size, block_size, 0, 1, 1, 1, 0, scratch, EXPECT_STATUS_GOOD); } diff --git a/test-tool/test_write16_simple.c b/test-tool/test_write16_simple.c index 8744159..c4d89af 100644 --- a/test-tool/test_write16_simple.c +++ b/test-tool/test_write16_simple.c @@ -31,20 +31,19 @@ void test_write16_simple(void) { int i; - unsigned char *buf = alloca(256 * block_size); - CHECK_FOR_DATALOSS; CHECK_FOR_SBC; logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITE16 of 1-256 blocks at the start of the LUN"); - memset(buf, 0xa6, 256 * block_size); + memset(scratch, 0xa6, 256 * block_size); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } - WRITE16(sd, 0, i * block_size, block_size, 0, 0, 0, 0, 0, buf, + WRITE16(sd, 0, i * block_size, block_size, + 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); } @@ -54,7 +53,7 @@ test_write16_simple(void) break; } WRITE16(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); } } diff --git a/test-tool/test_write16_wrprotect.c b/test-tool/test_write16_wrprotect.c index 5a93bee..8d24577 100644 --- a/test-tool/test_write16_wrprotect.c +++ b/test-tool/test_write16_wrprotect.c @@ -31,7 +31,6 @@ void test_write16_wrprotect(void) { int i; - unsigned char *buf = alloca(block_size); /* * Try out different non-zero values for WRPROTECT. @@ -42,12 +41,12 @@ test_write16_wrprotect(void) CHECK_FOR_DATALOSS; CHECK_FOR_SBC; - memset(buf, 0xa6, block_size); + memset(scratch, 0xa6, block_size); if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); for (i = 1; i < 8; i++) { WRITE16(sd, 0, block_size, block_size, - i, 0, 0, 0, 0, buf, + i, 0, 0, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); } return; diff --git a/test-tool/test_writeatomic16_beyond_eol.c b/test-tool/test_writeatomic16_beyond_eol.c index ee5c1ed..2829f4c 100644 --- a/test-tool/test_writeatomic16_beyond_eol.c +++ b/test-tool/test_writeatomic16_beyond_eol.c @@ -31,8 +31,6 @@ test_writeatomic16_beyond_eol(void) { int align, i, gran, ret; const size_t bufsz = 256 * 2 * block_size; - unsigned char *buf = alloca(bufsz); - CHECK_FOR_DATALOSS; CHECK_FOR_SBC; @@ -44,12 +42,12 @@ test_writeatomic16_beyond_eol(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); - memset(buf, 0xa6, bufsz); + memset(scratch, 0xa6, bufsz); align = inq_bl->atomic_align ? inq_bl->atomic_align : 1; gran = inq_bl->atomic_gran ? inq_bl->atomic_gran : 1; ret = writeatomic16(sd, 0, block_size * gran, - block_size, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); if (ret == -2) { logging(LOG_NORMAL, "[SKIPPED] WRITEATOMIC16 is not implemented."); @@ -66,7 +64,7 @@ test_writeatomic16_beyond_eol(void) ret = writeatomic16(sd, num_blocks - i, 2 * i * block_size, block_size, - 0, 0, 0, 0, buf, + 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); CU_ASSERT_EQUAL(ret, 0); } @@ -77,7 +75,8 @@ test_writeatomic16_beyond_eol(void) break; } ret = writeatomic16(sd, 0x8000000000000000ULL, - i * block_size, block_size, 0, 0, 0, 0, buf, + i * block_size, block_size, + 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); CU_ASSERT_EQUAL(ret, 0); } @@ -89,7 +88,7 @@ test_writeatomic16_beyond_eol(void) break; } ret = writeatomic16(sd, -align, i * block_size, - block_size, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); CU_ASSERT_EQUAL(ret, 0); } @@ -101,7 +100,8 @@ test_writeatomic16_beyond_eol(void) break; } ret = writeatomic16(sd, num_blocks - gran, - i * block_size, block_size, 0, 0, 0, 0, buf, + i * block_size, block_size, + 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); CU_ASSERT_EQUAL(ret, 0); } diff --git a/test-tool/test_writeatomic16_dpofua.c b/test-tool/test_writeatomic16_dpofua.c index b2ce28c..0a5b298 100644 --- a/test-tool/test_writeatomic16_dpofua.c +++ b/test-tool/test_writeatomic16_dpofua.c @@ -34,7 +34,6 @@ test_writeatomic16_dpofua(void) struct scsi_mode_sense *ms; struct scsi_task *rso_task = NULL; struct scsi_report_supported_op_codes_one_command *rsoc; - unsigned char *buf; logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITEATOMIC16 DPO/FUA flags"); @@ -48,7 +47,6 @@ test_writeatomic16_dpofua(void) } gran = inq_bl->atomic_gran ? inq_bl->atomic_gran : 1; - buf = alloca(gran * block_size); logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data"); ret = modesense6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT, @@ -69,10 +67,10 @@ test_writeatomic16_dpofua(void) } logging(LOG_VERBOSE, "Test WRITEATOMIC16 with DPO==1"); - memset(buf, 0xa6, block_size); + memset(scratch, 0xa6, block_size); if (dpofua) { ret = writeatomic16(sd, 0, gran * block_size, - block_size, 0, 1, 0, 0, buf, + block_size, 0, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); if (ret == -2) { logging(LOG_NORMAL, "[SKIPPED] WRITEATOMIC16 is not implemented."); @@ -82,7 +80,7 @@ test_writeatomic16_dpofua(void) CU_ASSERT_EQUAL(ret, 0); } else { ret = writeatomic16(sd, 0, gran * block_size, - block_size, 0, 1, 0, 0, buf, + block_size, 0, 1, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); if (ret == -2) { logging(LOG_NORMAL, "[SKIPPED] WRITEATOMIC16 is not implemented."); @@ -95,12 +93,12 @@ test_writeatomic16_dpofua(void) logging(LOG_VERBOSE, "Test WRITEATOMIC16 with FUA==1"); if (dpofua) { ret = writeatomic16(sd, 0, gran * block_size, - block_size, 0, 0, 1, 0, buf, + block_size, 0, 0, 1, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); } else { ret = writeatomic16(sd, 0, gran * block_size, - block_size, 0, 0, 1, 0, buf, + block_size, 0, 0, 1, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); CU_ASSERT_EQUAL(ret, 0); } @@ -108,12 +106,12 @@ test_writeatomic16_dpofua(void) logging(LOG_VERBOSE, "Test WRITEATOMIC16 with DPO==1 FUA==1"); if (dpofua) { ret = writeatomic16(sd, 0, gran * block_size, - block_size, 0, 1, 1, 0, buf, + block_size, 0, 1, 1, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); } else { ret = writeatomic16(sd, 0, gran * block_size, - block_size, 0, 1, 1, 0, buf, + block_size, 0, 1, 1, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); CU_ASSERT_EQUAL(ret, 0); } diff --git a/test-tool/test_writeatomic16_simple.c b/test-tool/test_writeatomic16_simple.c index abe7563..41f33f8 100644 --- a/test-tool/test_writeatomic16_simple.c +++ b/test-tool/test_writeatomic16_simple.c @@ -32,8 +32,6 @@ test_writeatomic16_simple(void) { int i, gran, ret; const size_t bufsz = 256 * block_size; - unsigned char *buf = alloca(bufsz); - CHECK_FOR_DATALOSS; CHECK_FOR_SBC; @@ -45,11 +43,11 @@ test_writeatomic16_simple(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); - memset(buf, 0, bufsz); + memset(scratch, 0, bufsz); gran = inq_bl->atomic_gran ? inq_bl->atomic_gran : 1; ret = writeatomic16(sd, 0, block_size * gran, - block_size, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); if (ret == -2) { logging(LOG_NORMAL, "[SKIPPED] WRITEATOMIC16 is not implemented."); @@ -59,13 +57,13 @@ test_writeatomic16_simple(void) CU_ASSERT_EQUAL(ret, 0); logging(LOG_VERBOSE, "Test WRITEATOMIC16 of 1-256 blocks at the start of the LUN"); - memset(buf, 0xa6, 256 * block_size); + memset(scratch, 0xa6, 256 * block_size); for (i = gran; i <= 256; i += gran) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } ret = writeatomic16(sd, 0, i * block_size, - block_size, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); } @@ -76,7 +74,8 @@ test_writeatomic16_simple(void) break; } ret = writeatomic16(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 0, 0, buf, + i * block_size, block_size, + 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); } diff --git a/test-tool/test_writeatomic16_vpd.c b/test-tool/test_writeatomic16_vpd.c index df3872c..b7b9249 100644 --- a/test-tool/test_writeatomic16_vpd.c +++ b/test-tool/test_writeatomic16_vpd.c @@ -33,7 +33,6 @@ test_writeatomic16_vpd(void) struct scsi_inquiry_block_limits *bl; struct scsi_task *bl_task = NULL; int gran; - unsigned char *buf; logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITEATOMIC16 VPD data"); @@ -63,10 +62,9 @@ test_writeatomic16_vpd(void) logging(LOG_VERBOSE, "Check if WRITEATOMIC16 is supported"); gran = inq_bl->atomic_gran ? inq_bl->atomic_gran : 1; - buf = alloca(block_size * gran); - memset(buf, 0x00, block_size * gran); + memset(scratch , 0x00, block_size * gran); ret = writeatomic16(sd, 0, block_size * gran, - block_size, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); if (ret == -2) { logging(LOG_VERBOSE, "WRITEATOMIC16 is NOT supported by the target."); @@ -110,7 +108,7 @@ test_writeatomic16_vpd(void) } else { logging(LOG_VERBOSE, "Atomic Write at LBA 1 should fail due to misalignment"); ret = writeatomic16(sd, 1, block_size * gran, - block_size, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); if (ret) { logging(LOG_VERBOSE, "[FAILED] Misaligned write did NOT fail with INVALID_FIELD_IN_CDB"); @@ -124,7 +122,7 @@ test_writeatomic16_vpd(void) } else { logging(LOG_VERBOSE, "Atomic Write of 1 block should fail due to invalid granularity"); ret = writeatomic16(sd, 0, block_size, - block_size, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); if (ret) { logging(LOG_VERBOSE, "[FAILED] Misgranularity write did NOT fail with INVALID_FIELD_IN_CDB"); diff --git a/test-tool/test_writeatomic16_wrprotect.c b/test-tool/test_writeatomic16_wrprotect.c index dec3810..85343cc 100644 --- a/test-tool/test_writeatomic16_wrprotect.c +++ b/test-tool/test_writeatomic16_wrprotect.c @@ -31,7 +31,6 @@ void test_writeatomic16_wrprotect(void) { int i, gran, ret; - unsigned char *buf = alloca(block_size); CHECK_FOR_DATALOSS; CHECK_FOR_SBC; @@ -44,10 +43,10 @@ test_writeatomic16_wrprotect(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); gran = inq_bl->atomic_gran ? inq_bl->atomic_gran : 1; - memset(buf, 0, block_size); + memset(scratch, 0, block_size); ret = writeatomic16(sd, 0, block_size * gran, - block_size, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); if (ret == -2) { logging(LOG_NORMAL, "[SKIPPED] WRITEATOMIC16 is not implemented."); @@ -59,13 +58,13 @@ test_writeatomic16_wrprotect(void) logging(LOG_VERBOSE, "Test WRITEATOMIC16 with non-zero WRPROTECT"); - memset(buf, 0xa6, block_size); + memset(scratch, 0xa6, block_size); if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); for (i = 1; i < 8; i++) { ret = writeatomic16(sd, 0, gran * block_size, block_size, - i, 0, 0, 0, buf, + i, 0, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); if (ret == -2) { logging(LOG_NORMAL, "[SKIPPED] WRITEATOMIC16 is not implemented."); diff --git a/test-tool/test_writesame10_0blocks.c b/test-tool/test_writesame10_0blocks.c index 47b8971..20c65df 100644 --- a/test-tool/test_writesame10_0blocks.c +++ b/test-tool/test_writesame10_0blocks.c @@ -28,7 +28,6 @@ void test_writesame10_0blocks(void) { int ret; - unsigned char *buf = alloca(block_size); CHECK_FOR_DATALOSS; CHECK_FOR_SBC; @@ -46,11 +45,11 @@ test_writesame10_0blocks(void) logging(LOG_VERBOSE, "Test WRITESAME10 0-blocks at LBA==0 (WSNZ=%d)", inq_bl->wsnz); - memset(buf, 0, block_size); + memset(scratch, 0, block_size); if (inq_bl->wsnz) { ret = writesame10(sd, 0, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); logging(LOG_NORMAL, "[SKIPPED] WRITESAME10 does not support 0-blocks."); CU_ASSERT_EQUAL(ret, 0); @@ -58,7 +57,7 @@ test_writesame10_0blocks(void) } ret = writesame10(sd, 0, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); if (ret == -2) { CU_PASS("[SKIPPED] Target does not support WRITESAME10. Skipping test"); @@ -73,21 +72,21 @@ test_writesame10_0blocks(void) logging(LOG_VERBOSE, "Test WRITESAME10 0-blocks one block past end-of-LUN"); ret = writesame10(sd, num_blocks + 1, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); CU_ASSERT_EQUAL(ret, 0); logging(LOG_VERBOSE, "Test WRITESAME10 0-blocks at LBA==2^31"); ret = writesame10(sd, 0x80000000, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); CU_ASSERT_EQUAL(ret, 0); logging(LOG_VERBOSE, "Test WRITESAME10 0-blocks at LBA==-1"); ret = writesame10(sd, -1, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); CU_ASSERT_EQUAL(ret, 0); } diff --git a/test-tool/test_writesame10_beyond_eol.c b/test-tool/test_writesame10_beyond_eol.c index e47b51b..89f7732 100644 --- a/test-tool/test_writesame10_beyond_eol.c +++ b/test-tool/test_writesame10_beyond_eol.c @@ -30,7 +30,6 @@ void test_writesame10_beyond_eol(void) { int i, ret; - unsigned char *buf = alloca(block_size); CHECK_FOR_DATALOSS; CHECK_FOR_SBC; @@ -42,10 +41,10 @@ test_writesame10_beyond_eol(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITESAME10 1-256 blocks one block beyond the end"); - memset(buf, 0, block_size); + memset(scratch, 0, block_size); for (i = 1; i <= 256; i++) { ret = writesame10(sd, num_blocks - i + 1, - block_size, i, 0, 0, 0, 0, buf, + block_size, i, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); if (ret == -2) { CU_PASS("[SKIPPED] Target does not support WRITESAME10. Skipping test"); @@ -58,7 +57,7 @@ test_writesame10_beyond_eol(void) logging(LOG_VERBOSE, "Test WRITESAME10 1-256 blocks at LBA==2^31"); for (i = 1; i <= 256; i++) { ret = writesame10(sd, 0x80000000, - block_size, i, 0, 0, 0, 0, buf, + block_size, i, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); CU_ASSERT_EQUAL(ret, 0); } @@ -67,7 +66,7 @@ test_writesame10_beyond_eol(void) logging(LOG_VERBOSE, "Test WRITESAME10 1-256 blocks at LBA==-1"); for (i = 1; i <= 256; i++) { ret = writesame10(sd, -1, - block_size, i, 0, 0, 0, 0, buf, + block_size, i, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); CU_ASSERT_EQUAL(ret, 0); } @@ -76,7 +75,7 @@ test_writesame10_beyond_eol(void) logging(LOG_VERBOSE, "Test WRITESAME10 2-256 blocks all but one block beyond the end"); for (i = 2; i <= 256; i++) { ret = writesame10(sd, num_blocks - 1, - block_size, i, 0, 0, 0, 0, buf, + block_size, i, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); CU_ASSERT_EQUAL(ret, 0); } diff --git a/test-tool/test_writesame10_simple.c b/test-tool/test_writesame10_simple.c index 2742e84..3eafeb6 100644 --- a/test-tool/test_writesame10_simple.c +++ b/test-tool/test_writesame10_simple.c @@ -31,7 +31,6 @@ void test_writesame10_simple(void) { int i, ret; - unsigned char *buf = alloca(block_size); CHECK_FOR_DATALOSS; CHECK_FOR_SBC; @@ -39,10 +38,10 @@ test_writesame10_simple(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITESAME10 of 1-256 blocks at the start of the LUN"); - memset(buf, 0, block_size); + memset(scratch, 0, block_size); for (i = 1; i <= 256; i++) { ret = writesame10(sd, 0, - block_size, i, 0, 0, 0, 0, buf, + block_size, i, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); if (ret == -2) { CU_PASS("[SKIPPED] Target does not support WRITESAME10. Skipping test"); @@ -54,7 +53,7 @@ test_writesame10_simple(void) logging(LOG_VERBOSE, "Test WRITESAME10 of 1-256 blocks at the end of the LUN"); for (i = 1; i <= 256; i++) { ret = writesame10(sd, num_blocks - i, - block_size, i, 0, 0, 0, 0, buf, + block_size, i, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); } diff --git a/test-tool/test_writesame10_unmap.c b/test-tool/test_writesame10_unmap.c index 97fe97d..d348137 100644 --- a/test-tool/test_writesame10_unmap.c +++ b/test-tool/test_writesame10_unmap.c @@ -32,7 +32,6 @@ test_writesame10_unmap(void) { int ret; unsigned int i; - unsigned char *buf = alloca(256 * block_size); CHECK_FOR_DATALOSS; CHECK_FOR_THIN_PROVISIONING; @@ -42,17 +41,18 @@ test_writesame10_unmap(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITESAME10 of 1-256 blocks at the start of " "the LUN"); - memset(buf, 0xa6, 256 * block_size); + memset(scratch, 0xa6, 256 * block_size); for (i = 1; i <= 256; i++) { logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i); - memset(buf, 0xff, i * block_size); - WRITE10(sd, 0, i * block_size, block_size, 0, 0, 0, 0, 0, buf, + memset(scratch, 0xff, i * block_size); + WRITE10(sd, 0, i * block_size, block_size, + 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10", i); - memset(buf, 0, block_size); + memset(scratch, 0, block_size); ret = writesame10(sd, 0, - block_size, i, 0, 1, 0, 0, buf, + block_size, i, 0, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); @@ -64,9 +64,9 @@ test_writesame10_unmap(void) "are now zero", i); ret = read10(sd, NULL, 0, i * block_size, block_size, - 0, 0, 0, 0, 0, buf, + 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); - CU_ASSERT(all_zeroes(buf, i * block_size)); + CU_ASSERT(all_zeroes(scratch, i * block_size)); } else { logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read " "and verify zero test"); @@ -78,15 +78,15 @@ test_writesame10_unmap(void) "the LUN"); for (i = 1; i <= 256; i++) { logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i); - memset(buf, 0xff, i * block_size); + memset(scratch, 0xff, i * block_size); WRITE10(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10", i); - memset(buf, 0, block_size); + memset(scratch, 0, block_size); ret = writesame10(sd, num_blocks - i, - block_size, i, 0, 1, 0, 0, buf, + block_size, i, 0, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); @@ -98,9 +98,9 @@ test_writesame10_unmap(void) "are now zero", i); ret = read10(sd, NULL, num_blocks - i, i * block_size, block_size, - 0, 0, 0, 0, 0, buf, + 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); - CU_ASSERT(all_zeroes(buf, i * block_size)); + CU_ASSERT(all_zeroes(scratch, i * block_size)); } else { logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read " "and verify zero test"); @@ -110,7 +110,7 @@ test_writesame10_unmap(void) logging(LOG_VERBOSE, "Verify that WRITESAME10 ANCHOR==1 + UNMAP==0 is " "invalid"); ret = writesame10(sd, 0, - block_size, 1, 1, 0, 0, 0, buf, + block_size, 1, 1, 0, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); CU_ASSERT_EQUAL(ret, 0); @@ -118,15 +118,15 @@ test_writesame10_unmap(void) if (inq_lbp->anc_sup) { logging(LOG_VERBOSE, "Test WRITESAME10 ANCHOR==1 + UNMAP==0"); - memset(buf, 0, block_size); + memset(scratch, 0, block_size); ret = writesame10(sd, 0, - block_size, 1, 1, 1, 0, 0, buf, + block_size, 1, 1, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); } else { logging(LOG_VERBOSE, "Test WRITESAME10 ANCHOR==1 + UNMAP==0 no " "ANC_SUP so expecting to fail"); ret = writesame10(sd, 0, - block_size, 1, 1, 1, 0, 0, buf, + block_size, 1, 1, 1, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); } CU_ASSERT_EQUAL(ret, 0); @@ -149,15 +149,15 @@ test_writesame10_unmap(void) "lengths", i, i); logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i); - memset(buf, 0xff, i * block_size); + memset(scratch, 0xff, i * block_size); WRITE10(sd, 0, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10", i); - memset(buf, 0, block_size); + memset(scratch, 0, block_size); ret = writesame10(sd, 0, - block_size, i, 0, 1, 0, 0, buf, + block_size, i, 0, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); @@ -169,9 +169,9 @@ test_writesame10_unmap(void) "are now zero", i); ret = read10(sd, NULL, 0, i * block_size, block_size, - 0, 0, 0, 0, 0, buf, + 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); - CU_ASSERT(all_zeroes(buf, i * block_size)); + CU_ASSERT(all_zeroes(scratch, i * block_size)); } else { logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read " "and verify zero test"); @@ -183,7 +183,7 @@ test_writesame10_unmap(void) logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10", i); ret = writesame10(sd, 0, - block_size, i, 0, 1, 0, 0, buf, + block_size, i, 0, 1, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); CU_ASSERT_EQUAL(ret, 0); } diff --git a/test-tool/test_writesame10_unmap_unaligned.c b/test-tool/test_writesame10_unmap_unaligned.c index 91de3c5..65ea079 100644 --- a/test-tool/test_writesame10_unmap_unaligned.c +++ b/test-tool/test_writesame10_unmap_unaligned.c @@ -30,7 +30,6 @@ void test_writesame10_unmap_unaligned(void) { int i, ret; - unsigned char *buf = alloca(block_size); CHECK_FOR_DATALOSS; CHECK_FOR_THIN_PROVISIONING; @@ -40,11 +39,11 @@ test_writesame10_unmap_unaligned(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test that unaligned WRITESAME10 Unmap succeeds. LBPPB==%d", lbppb); - memset(buf, 0xa6, block_size); + memset(scratch, 0xa6, block_size); for (i = 1; i < lbppb; i++) { logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10 at LBA:%d", lbppb - i, i); ret = writesame10(sd, i, - block_size, lbppb - i, 0, 1, 0, 0, buf, + block_size, lbppb - i, 0, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); } diff --git a/test-tool/test_writesame10_unmap_until_end.c b/test-tool/test_writesame10_unmap_until_end.c index 98275b3..540971b 100644 --- a/test-tool/test_writesame10_unmap_until_end.c +++ b/test-tool/test_writesame10_unmap_until_end.c @@ -46,17 +46,15 @@ test_writesame10_unmap_until_end(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITESAME10 of 1-256 blocks at the end of the LUN by setting number-of-blocks==0"); for (i = 1; i <= 256; i++) { - unsigned char *buf = malloc(block_size * i); - logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i); - memset(buf, 0xff, block_size * i); + memset(scratch, 0xff, block_size * i); WRITE10(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10", i); ret = writesame10(sd, num_blocks - i, - block_size, 0, 0, 1, 0, 0, buf, + block_size, 0, 0, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); @@ -68,13 +66,12 @@ test_writesame10_unmap_until_end(void) "are now zero", i); ret = read10(sd, NULL, num_blocks - i, i * block_size, block_size, - 0, 0, 0, 0, 0, buf, + 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); - CU_ASSERT(all_zeroes(buf, i * block_size)); + CU_ASSERT(all_zeroes(scratch, i * block_size)); } else { logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read " "and verify zero test"); } - free(buf); } } diff --git a/test-tool/test_writesame10_unmap_vpd.c b/test-tool/test_writesame10_unmap_vpd.c index e151be9..f8d8e0b 100644 --- a/test-tool/test_writesame10_unmap_vpd.c +++ b/test-tool/test_writesame10_unmap_vpd.c @@ -31,7 +31,6 @@ void test_writesame10_unmap_vpd(void) { int ret; - unsigned char *buf = alloca(block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITESAME10 UNMAP availability is " @@ -42,9 +41,8 @@ test_writesame10_unmap_vpd(void) logging(LOG_VERBOSE, "Check if WRITESAME10 can be used for UNMAP."); logging(LOG_VERBOSE, "Unmap 1 block using WRITESAME10"); - memset(buf, 0, block_size); - ret = writesame10(sd, 0, - block_size, 1, 0, 1, 0, 0, buf, + memset(scratch, 0, block_size); + ret = writesame10(sd, 0, block_size, 1, 0, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); if (ret != 0) { logging(LOG_VERBOSE, "WRITESAME10 UNMAP is not available. " diff --git a/test-tool/test_writesame10_wrprotect.c b/test-tool/test_writesame10_wrprotect.c index 4992a8a..bf54f5c 100644 --- a/test-tool/test_writesame10_wrprotect.c +++ b/test-tool/test_writesame10_wrprotect.c @@ -31,7 +31,6 @@ void test_writesame10_wrprotect(void) { int i, ret; - unsigned char *buf = alloca(block_size); /* * Try out different non-zero values for WRPROTECT. @@ -42,12 +41,12 @@ test_writesame10_wrprotect(void) CHECK_FOR_DATALOSS; CHECK_FOR_SBC; - memset(buf, 0, block_size); + memset(scratch, 0, block_size); if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); for (i = 1; i < 8; i++) { ret = writesame10(sd, 0, - block_size, 1, 0, 0, i, 0, buf, + block_size, 1, 0, 0, i, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); if (ret == -2) { logging(LOG_NORMAL, "[SKIPPED] WRITESAME10 is not implemented."); diff --git a/test-tool/test_writesame16_0blocks.c b/test-tool/test_writesame16_0blocks.c index 1e226f1..d2d7618 100644 --- a/test-tool/test_writesame16_0blocks.c +++ b/test-tool/test_writesame16_0blocks.c @@ -28,7 +28,6 @@ void test_writesame16_0blocks(void) { int ret; - unsigned char *buf = alloca(block_size); CHECK_FOR_DATALOSS; CHECK_FOR_SBC; @@ -41,19 +40,18 @@ test_writesame16_0blocks(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITESAME16 0-blocks at LBA==0 (WSNZ=%d)", inq_bl->wsnz); - memset(buf, 0, block_size); + memset(scratch, 0, block_size); if (inq_bl->wsnz) { ret = writesame16(sd, 0, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 does not support 0-blocks."); CU_ASSERT_EQUAL(ret, 0); return; } - ret = writesame16(sd, 0, - block_size, 0, 0, 0, 0, 0, buf, + ret = writesame16(sd, 0, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); if (ret == -2) { logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented."); @@ -69,21 +67,21 @@ test_writesame16_0blocks(void) logging(LOG_VERBOSE, "Test WRITESAME16 0-blocks one block past end-of-LUN"); ret = writesame16(sd, num_blocks + 1, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); CU_ASSERT_EQUAL(ret, 0); logging(LOG_VERBOSE, "Test WRITESAME16 0-blocks at LBA==2^63"); ret = writesame16(sd, 0x8000000000000000ULL, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); CU_ASSERT_EQUAL(ret, 0); logging(LOG_VERBOSE, "Test WRITESAME16 0-blocks at LBA==-1"); ret = writesame16(sd, -1, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); CU_ASSERT_EQUAL(ret, 0); } diff --git a/test-tool/test_writesame16_beyond_eol.c b/test-tool/test_writesame16_beyond_eol.c index e5dd8bc..a3fa9a4 100644 --- a/test-tool/test_writesame16_beyond_eol.c +++ b/test-tool/test_writesame16_beyond_eol.c @@ -30,17 +30,16 @@ void test_writesame16_beyond_eol(void) { int i, ret; - unsigned char *buf = alloca(block_size); CHECK_FOR_DATALOSS; CHECK_FOR_SBC; logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITESAME16 1-256 blocks one block beyond the end"); - memset(buf, 0, block_size); + memset(scratch, 0, block_size); for (i = 1; i <= 256; i++) { ret = writesame16(sd, num_blocks - i + 1, - block_size, i, 0, 0, 0, 0, buf, + block_size, i, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); if (ret == -2) { logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented."); @@ -54,7 +53,7 @@ test_writesame16_beyond_eol(void) logging(LOG_VERBOSE, "Test WRITESAME16 1-256 blocks at LBA==2^63"); for (i = 1; i <= 256; i++) { ret = writesame16(sd, 0x8000000000000000ULL, - block_size, i, 0, 0, 0, 0, buf, + block_size, i, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); CU_ASSERT_EQUAL(ret, 0); } @@ -63,7 +62,7 @@ test_writesame16_beyond_eol(void) logging(LOG_VERBOSE, "Test WRITESAME16 1-256 blocks at LBA==-1"); for (i = 1; i <= 256; i++) { ret = writesame16(sd, -1, - block_size, i, 0, 0, 0, 0, buf, + block_size, i, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); CU_ASSERT_EQUAL(ret, 0); } @@ -72,7 +71,7 @@ test_writesame16_beyond_eol(void) logging(LOG_VERBOSE, "Test WRITESAME16 2-256 blocks all but one block beyond the end"); for (i = 2; i <= 256; i++) { ret = writesame16(sd, num_blocks - 1, - block_size, i, 0, 0, 0, 0, buf, + block_size, i, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); CU_ASSERT_EQUAL(ret, 0); } diff --git a/test-tool/test_writesame16_simple.c b/test-tool/test_writesame16_simple.c index e034f0f..65b3c55 100644 --- a/test-tool/test_writesame16_simple.c +++ b/test-tool/test_writesame16_simple.c @@ -31,7 +31,6 @@ void test_writesame16_simple(void) { int i, ret; - unsigned char *buf = alloca(block_size); CHECK_FOR_DATALOSS; CHECK_FOR_SBC; @@ -39,10 +38,10 @@ test_writesame16_simple(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITESAME16 of 1-256 blocks at the start of the LUN"); - memset(buf, 0, block_size); + memset(scratch, 0, block_size); for (i = 1; i <= 256; i++) { ret = writesame16(sd, 0, - block_size, i, 0, 0, 0, 0, buf, + block_size, i, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); if (ret == -2) { logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented."); @@ -55,7 +54,7 @@ test_writesame16_simple(void) logging(LOG_VERBOSE, "Test WRITESAME16 of 1-256 blocks at the end of the LUN"); for (i = 1; i <= 256; i++) { ret = writesame16(sd, num_blocks - i, - block_size, i, 0, 0, 0, 0, buf, + block_size, i, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); } diff --git a/test-tool/test_writesame16_unmap.c b/test-tool/test_writesame16_unmap.c index 49a527f..05adf46 100644 --- a/test-tool/test_writesame16_unmap.c +++ b/test-tool/test_writesame16_unmap.c @@ -31,7 +31,6 @@ test_writesame16_unmap(void) { int ret; unsigned int i; - unsigned char *buf; CHECK_FOR_DATALOSS; CHECK_FOR_THIN_PROVISIONING; @@ -40,22 +39,22 @@ test_writesame16_unmap(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITESAME16 of 1-256 blocks at the start of the LUN"); - buf = calloc(65536, block_size); for (i = 1; i <= 256; i++) { logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i); - memset(buf, 0xff, i * block_size); - WRITE16(sd, 0, i * block_size, block_size, 0, 0, 0, 0, 0, buf, + memset(scratch, 0xff, i * block_size); + WRITE16(sd, 0, i * block_size, block_size, + 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i); - memset(buf, 0, block_size); + memset(scratch, 0, block_size); ret = writesame16(sd, 0, - block_size, i, 0, 1, 0, 0, buf, + block_size, i, 0, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); if (ret == -2) { logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented."); CU_PASS("[SKIPPED] Target does not support WRITESAME16. Skipping test"); - goto finished; + return; } CU_ASSERT_EQUAL(ret, 0); @@ -66,9 +65,9 @@ test_writesame16_unmap(void) "are now zero", i); ret = read16(sd, NULL, 0, i * block_size, block_size, - 0, 0, 0, 0, 0, buf, + 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); - CU_ASSERT(all_zeroes(buf, i * block_size)); + CU_ASSERT(all_zeroes(scratch, i * block_size)); } else { logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read " "and verify zero test"); @@ -79,15 +78,15 @@ test_writesame16_unmap(void) logging(LOG_VERBOSE, "Test WRITESAME16 of 1-256 blocks at the end of the LUN"); for (i = 1; i <= 256; i++) { logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i); - memset(buf, 0xff, i * block_size); + memset(scratch, 0xff, i * block_size); WRITE16(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i); - memset(buf, 0, block_size); + memset(scratch, 0, block_size); ret = writesame16(sd, num_blocks - i, - block_size, i, 0, 1, 0, 0, buf, + block_size, i, 0, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); @@ -98,9 +97,9 @@ test_writesame16_unmap(void) "are now zero", i); ret = read16(sd, NULL, num_blocks - i, i * block_size, block_size, - 0, 0, 0, 0, 0, buf, + 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); - CU_ASSERT(all_zeroes(buf, i * block_size)); + CU_ASSERT(all_zeroes(scratch, i * block_size)); } else { logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read " "and verify zero test"); @@ -109,7 +108,7 @@ test_writesame16_unmap(void) logging(LOG_VERBOSE, "Verify that WRITESAME16 ANCHOR==1 + UNMAP==0 is invalid"); ret = writesame16(sd, 0, - block_size, 1, 1, 0, 0, 0, buf, + block_size, 1, 1, 0, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); CU_ASSERT_EQUAL(ret, 0); @@ -117,14 +116,14 @@ test_writesame16_unmap(void) if (inq_lbp->anc_sup) { logging(LOG_VERBOSE, "Test WRITESAME16 ANCHOR==1 + UNMAP==0"); - memset(buf, 0, block_size); + memset(scratch, 0, block_size); ret = writesame16(sd, 0, - block_size, 1, 1, 1, 0, 0, buf, + block_size, 1, 1, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); } else { logging(LOG_VERBOSE, "Test WRITESAME16 ANCHOR==1 + UNMAP==0 no ANC_SUP so expecting to fail"); ret = writesame16(sd, 0, - block_size, 1, 1, 1, 0, 0, buf, + block_size, 1, 1, 1, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); } @@ -136,7 +135,7 @@ test_writesame16_unmap(void) "BlockLimits VPD is missing."); CU_FAIL("[FAILED] WRITESAME16 works but " "BlockLimits VPD is missing."); - goto finished; + return; } i = 256; @@ -148,15 +147,15 @@ test_writesame16_unmap(void) "lengths", i, i); logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i); - memset(buf, 0xff, i * block_size); + memset(scratch, 0xff, i * block_size); WRITE16(sd, 0, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i); - memset(buf, 0, block_size); + memset(scratch, 0, block_size); ret = writesame16(sd, 0, - block_size, i, 0, 1, 0, 0, buf, + block_size, i, 0, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); @@ -168,9 +167,9 @@ test_writesame16_unmap(void) "are now zero", i); ret = read16(sd, NULL, 0, i * block_size, block_size, - 0, 0, 0, 0, 0, buf, + 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); - CU_ASSERT(all_zeroes(buf, i * block_size)); + CU_ASSERT(all_zeroes(scratch, i * block_size)); } else { logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read " "and verify zero test"); @@ -182,7 +181,7 @@ test_writesame16_unmap(void) logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i); ret = writesame16(sd, 0, - block_size, i, 0, 1, 0, 0, buf, + block_size, i, 0, 1, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); CU_ASSERT_EQUAL(ret, 0); } @@ -197,15 +196,15 @@ test_writesame16_unmap(void) "lengths", i, i); logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i); - memset(buf, 0xff, i * block_size); + memset(scratch, 0xff, i * block_size); WRITE16(sd, 0, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i); - memset(buf, 0, block_size); + memset(scratch, 0, block_size); ret = writesame16(sd, 0, - block_size, i, 0, 1, 0, 0, buf, + block_size, i, 0, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); @@ -217,9 +216,9 @@ test_writesame16_unmap(void) "are now zero", i); ret = read16(sd, NULL, 0, i * block_size, block_size, - 0, 0, 0, 0, 0, buf, + 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); - CU_ASSERT(all_zeroes(buf, i * block_size)); + CU_ASSERT(all_zeroes(scratch, i * block_size)); } else { logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read " "and verify zero test"); @@ -231,11 +230,8 @@ test_writesame16_unmap(void) logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i); ret = writesame16(sd, 0, - block_size, i, 0, 1, 0, 0, buf, + block_size, i, 0, 1, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); CU_ASSERT_EQUAL(ret, 0); } - -finished: - free(buf); } diff --git a/test-tool/test_writesame16_unmap_until_end.c b/test-tool/test_writesame16_unmap_until_end.c index 876b1e6..32b24ba 100644 --- a/test-tool/test_writesame16_unmap_until_end.c +++ b/test-tool/test_writesame16_unmap_until_end.c @@ -32,7 +32,6 @@ test_writesame16_unmap_until_end(void) { int ret; unsigned int i; - unsigned char *buf = alloca(256 * block_size); CHECK_FOR_DATALOSS; CHECK_FOR_THIN_PROVISIONING; @@ -47,18 +46,18 @@ test_writesame16_unmap_until_end(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITESAME16 of 1-256 blocks at the end of the LUN by setting number-of-blocks==0"); - memset(buf, 0xa6, 256 * block_size); + memset(scratch, 0xa6, 256 * block_size); for (i = 1; i <= 256; i++) { logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i); - memset(buf, 0xff, block_size * i); + memset(scratch, 0xff, block_size * i); WRITE16(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i); - memset(buf, 0, block_size); + memset(scratch, 0, block_size); ret = writesame16(sd, num_blocks - i, - block_size, 0, 0, 1, 0, 0, buf, + block_size, 0, 0, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); if (ret == -2) { logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented."); @@ -75,9 +74,9 @@ test_writesame16_unmap_until_end(void) "are now zero", i); ret = read16(sd, NULL, num_blocks - i, i * block_size, block_size, - 0, 0, 0, 0, 0, buf, + 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); - CU_ASSERT(all_zeroes(buf, i * block_size)); + CU_ASSERT(all_zeroes(scratch, i * block_size)); } else { logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read " "and verify zero test"); diff --git a/test-tool/test_writesame16_unmap_vpd.c b/test-tool/test_writesame16_unmap_vpd.c index 60154f6..0f32363 100644 --- a/test-tool/test_writesame16_unmap_vpd.c +++ b/test-tool/test_writesame16_unmap_vpd.c @@ -31,7 +31,6 @@ void test_writesame16_unmap_vpd(void) { int ret; - unsigned char *buf = alloca(block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITESAME16 UNMAP availability is " @@ -43,9 +42,8 @@ test_writesame16_unmap_vpd(void) logging(LOG_VERBOSE, "Check if WRITESAME16 can be used for UNMAP."); logging(LOG_VERBOSE, "Unmap 1 block using WRITESAME16"); - memset(buf, 0, block_size); - ret = writesame16(sd, 0, - block_size, 1, 0, 1, 0, 0, buf, + memset(scratch, 0, block_size); + ret = writesame16(sd, 0, block_size, 1, 0, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); if (ret != 0) { logging(LOG_VERBOSE, "WRITESAME16 UNMAP is not available. " diff --git a/test-tool/test_writesame16_wrprotect.c b/test-tool/test_writesame16_wrprotect.c index 07a86e3..f18e0bb 100644 --- a/test-tool/test_writesame16_wrprotect.c +++ b/test-tool/test_writesame16_wrprotect.c @@ -31,7 +31,6 @@ void test_writesame16_wrprotect(void) { int i, ret; - unsigned char *buf = alloca(block_size); /* * Try out different non-zero values for WRPROTECT. @@ -42,12 +41,12 @@ test_writesame16_wrprotect(void) CHECK_FOR_DATALOSS; CHECK_FOR_SBC; - memset(buf, 0, block_size); + memset(scratch, 0, block_size); if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); for (i = 1; i < 8; i++) { ret = writesame16(sd, 0, - block_size, 1, 0, 0, i, 0, buf, + block_size, 1, 0, 0, i, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); if (ret == -2) { logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented."); diff --git a/test-tool/test_writeverify10_beyond_eol.c b/test-tool/test_writeverify10_beyond_eol.c index 6e1186a..69e11df 100644 --- a/test-tool/test_writeverify10_beyond_eol.c +++ b/test-tool/test_writeverify10_beyond_eol.c @@ -30,7 +30,6 @@ void test_writeverify10_beyond_eol(void) { int i; - unsigned char *buf = alloca(256 * block_size); CHECK_FOR_DATALOSS; @@ -41,13 +40,13 @@ test_writeverify10_beyond_eol(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITEVERIFY10 1-256 blocks one block beyond the end"); - memset(buf, 0xa6, 256 * block_size); + memset(scratch, 0xa6, 256 * block_size); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } WRITEVERIFY10(sd, num_blocks + 1 - i, - i * block_size, block_size, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); } @@ -57,7 +56,7 @@ test_writeverify10_beyond_eol(void) break; } WRITEVERIFY10(sd, 0x80000000, - i * block_size, block_size, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); } @@ -67,7 +66,7 @@ test_writeverify10_beyond_eol(void) break; } WRITEVERIFY10(sd, -1, i * block_size, - block_size, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); } @@ -77,7 +76,7 @@ test_writeverify10_beyond_eol(void) break; } WRITEVERIFY10(sd, num_blocks - 1, - i * block_size, block_size, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); } } diff --git a/test-tool/test_writeverify10_dpo.c b/test-tool/test_writeverify10_dpo.c index 155d057..ec59793 100644 --- a/test-tool/test_writeverify10_dpo.c +++ b/test-tool/test_writeverify10_dpo.c @@ -34,7 +34,6 @@ test_writeverify10_dpo(void) struct scsi_mode_sense *ms; struct scsi_task *rso_task = NULL; struct scsi_report_supported_op_codes_one_command *rsoc; - unsigned char *buf = alloca(block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITEVERIFY10 DPO flag"); @@ -42,7 +41,7 @@ test_writeverify10_dpo(void) CHECK_FOR_SBC; ret = read10(sd, NULL, 0, block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); @@ -67,11 +66,11 @@ test_writeverify10_dpo(void) logging(LOG_VERBOSE, "Test WRITEVERIFY10 with DPO==1"); if (dpofua) { WRITEVERIFY10(sd, 0, block_size, - block_size, 0, 1, 0, 0, buf, + block_size, 0, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); } else { WRITEVERIFY10(sd, 0, block_size, - block_size, 0, 1, 0, 0, buf, + block_size, 0, 1, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); } diff --git a/test-tool/test_writeverify10_flags.c b/test-tool/test_writeverify10_flags.c index 476a979..b5e3009 100644 --- a/test-tool/test_writeverify10_flags.c +++ b/test-tool/test_writeverify10_flags.c @@ -30,8 +30,6 @@ void test_writeverify10_flags(void) { - unsigned char *buf = alloca(block_size); - CHECK_FOR_DATALOSS; logging(LOG_VERBOSE, LOG_BLANK_LINE); @@ -39,7 +37,7 @@ test_writeverify10_flags(void) logging(LOG_VERBOSE, "Test WRITEVERIFY10 with BYTCHK==1"); - memset(buf, 0xa6, block_size); - WRITEVERIFY10(sd, 0, block_size, block_size, 0, 0, 1, 0, buf, + memset(scratch, 0xa6, block_size); + WRITEVERIFY10(sd, 0, block_size, block_size, 0, 0, 1, 0, scratch, EXPECT_STATUS_GOOD); } diff --git a/test-tool/test_writeverify10_simple.c b/test-tool/test_writeverify10_simple.c index adbca05..2d7122d 100644 --- a/test-tool/test_writeverify10_simple.c +++ b/test-tool/test_writeverify10_simple.c @@ -31,19 +31,18 @@ void test_writeverify10_simple(void) { int i; - unsigned char *buf = alloca(256 * block_size); CHECK_FOR_DATALOSS; logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITEVERIFY10 of 1-256 blocks at the start of the LUN"); - memset(buf, 0xa6, 256 * block_size); + memset(scratch, 0xa6, 256 * block_size); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } WRITEVERIFY10(sd, 0, i * block_size, - block_size, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); } @@ -53,7 +52,7 @@ test_writeverify10_simple(void) break; } WRITEVERIFY10(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); } } diff --git a/test-tool/test_writeverify10_wrprotect.c b/test-tool/test_writeverify10_wrprotect.c index bf99def..910b587 100644 --- a/test-tool/test_writeverify10_wrprotect.c +++ b/test-tool/test_writeverify10_wrprotect.c @@ -31,7 +31,6 @@ void test_writeverify10_wrprotect(void) { int i; - unsigned char *buf = alloca(block_size); /* * Try out different non-zero values for WRPROTECT. @@ -42,12 +41,12 @@ test_writeverify10_wrprotect(void) CHECK_FOR_DATALOSS; CHECK_FOR_SBC; - memset(buf, 0xa6, block_size); + memset(scratch, 0xa6, block_size); if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); for (i = 1; i < 8; i++) { WRITEVERIFY10(sd, 0, block_size, block_size, - i, 0, 0, 0, buf, + i, 0, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); } return; diff --git a/test-tool/test_writeverify12_beyond_eol.c b/test-tool/test_writeverify12_beyond_eol.c index aa90e9c..fc52d4d 100644 --- a/test-tool/test_writeverify12_beyond_eol.c +++ b/test-tool/test_writeverify12_beyond_eol.c @@ -30,7 +30,6 @@ void test_writeverify12_beyond_eol(void) { int i; - unsigned char *buf = alloca(256 * block_size); CHECK_FOR_DATALOSS; @@ -41,13 +40,13 @@ test_writeverify12_beyond_eol(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITEVERIFY12 1-256 blocks one block beyond the end"); - memset(buf, 0xa6, 256 * block_size); + memset(scratch, 0xa6, 256 * block_size); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } WRITEVERIFY12(sd, num_blocks + 1 - i, - i * block_size, block_size, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); } @@ -57,7 +56,7 @@ test_writeverify12_beyond_eol(void) break; } WRITEVERIFY12(sd, 0x80000000, - i * block_size, block_size, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); } @@ -67,7 +66,7 @@ test_writeverify12_beyond_eol(void) break; } WRITEVERIFY12(sd, -1, i * block_size, - block_size, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); } @@ -77,7 +76,7 @@ test_writeverify12_beyond_eol(void) break; } WRITEVERIFY12(sd, num_blocks - 1, - i * block_size, block_size, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); } } diff --git a/test-tool/test_writeverify12_dpo.c b/test-tool/test_writeverify12_dpo.c index d7047d3..c84dd60 100644 --- a/test-tool/test_writeverify12_dpo.c +++ b/test-tool/test_writeverify12_dpo.c @@ -34,7 +34,6 @@ test_writeverify12_dpo(void) struct scsi_mode_sense *ms; struct scsi_task *rso_task = NULL; struct scsi_report_supported_op_codes_one_command *rsoc; - unsigned char *buf = alloca(block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITEVERIFY12 DPO flag"); @@ -42,7 +41,7 @@ test_writeverify12_dpo(void) CHECK_FOR_SBC; ret = read10(sd, NULL, 0, block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); @@ -67,11 +66,11 @@ test_writeverify12_dpo(void) logging(LOG_VERBOSE, "Test WRITEVERIFY12 with DPO==1"); if (dpofua) { WRITEVERIFY12(sd, 0, block_size, - block_size, 0, 1, 0, 0, buf, + block_size, 0, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); } else { WRITEVERIFY12(sd, 0, block_size, - block_size, 0, 1, 0, 0, buf, + block_size, 0, 1, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); } diff --git a/test-tool/test_writeverify12_flags.c b/test-tool/test_writeverify12_flags.c index 60b28fc..4269fb6 100644 --- a/test-tool/test_writeverify12_flags.c +++ b/test-tool/test_writeverify12_flags.c @@ -30,8 +30,6 @@ void test_writeverify12_flags(void) { - unsigned char *buf = alloca(block_size); - CHECK_FOR_DATALOSS; logging(LOG_VERBOSE, LOG_BLANK_LINE); @@ -39,7 +37,7 @@ test_writeverify12_flags(void) logging(LOG_VERBOSE, "Test WRITEVERIFY12 with BYTCHK==1"); - memset(buf, 0xa6, block_size); - WRITEVERIFY12(sd, 0, block_size, block_size, 0, 0, 1, 0, buf, + memset(scratch, 0xa6, block_size); + WRITEVERIFY12(sd, 0, block_size, block_size, 0, 0, 1, 0, scratch, EXPECT_STATUS_GOOD); } diff --git a/test-tool/test_writeverify12_simple.c b/test-tool/test_writeverify12_simple.c index 3e4447f..fb32b68 100644 --- a/test-tool/test_writeverify12_simple.c +++ b/test-tool/test_writeverify12_simple.c @@ -31,19 +31,18 @@ void test_writeverify12_simple(void) { int i; - unsigned char *buf = alloca(256 * block_size); CHECK_FOR_DATALOSS; logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITEVERIFY12 of 1-256 blocks at the start of the LUN"); - memset(buf, 0xa6, 256 * block_size); + memset(scratch, 0xa6, 256 * block_size); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } WRITEVERIFY12(sd, 0, i * block_size, - block_size, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); } @@ -53,7 +52,7 @@ test_writeverify12_simple(void) break; } WRITEVERIFY12(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); } } diff --git a/test-tool/test_writeverify12_wrprotect.c b/test-tool/test_writeverify12_wrprotect.c index ce88c1a..ea8362d 100644 --- a/test-tool/test_writeverify12_wrprotect.c +++ b/test-tool/test_writeverify12_wrprotect.c @@ -31,7 +31,6 @@ void test_writeverify12_wrprotect(void) { int i; - unsigned char *buf = alloca(block_size); /* * Try out different non-zero values for WRPROTECT. @@ -42,12 +41,12 @@ test_writeverify12_wrprotect(void) CHECK_FOR_DATALOSS; CHECK_FOR_SBC; - memset(buf, 0xa6, block_size); + memset(scratch, 0xa6, block_size); if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); for (i = 1; i < 8; i++) { WRITEVERIFY12(sd, 0, block_size, block_size, - i, 0, 0, 0, buf, + i, 0, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); } return; diff --git a/test-tool/test_writeverify16_beyond_eol.c b/test-tool/test_writeverify16_beyond_eol.c index 84dd3ce..d56feaf 100644 --- a/test-tool/test_writeverify16_beyond_eol.c +++ b/test-tool/test_writeverify16_beyond_eol.c @@ -30,20 +30,19 @@ void test_writeverify16_beyond_eol(void) { int i; - unsigned char *buf = alloca(256 * block_size); CHECK_FOR_DATALOSS; CHECK_FOR_SBC; logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITEVERIFY16 1-256 blocks one block beyond the end"); - memset(buf, 0xa6, 256 * block_size); + memset(scratch, 0xa6, 256 * block_size); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } WRITEVERIFY16(sd, num_blocks + 1 - i, - i * block_size, block_size, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); } @@ -53,7 +52,7 @@ test_writeverify16_beyond_eol(void) break; } WRITEVERIFY16(sd, 0x8000000000000000ULL, - i * block_size, block_size, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); } @@ -63,7 +62,7 @@ test_writeverify16_beyond_eol(void) break; } WRITEVERIFY16(sd, -1, - i * block_size, block_size, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); } @@ -73,7 +72,7 @@ test_writeverify16_beyond_eol(void) break; } WRITEVERIFY16(sd, num_blocks - 1, - i * block_size, block_size, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB); } } diff --git a/test-tool/test_writeverify16_dpo.c b/test-tool/test_writeverify16_dpo.c index f995149..08a4721 100644 --- a/test-tool/test_writeverify16_dpo.c +++ b/test-tool/test_writeverify16_dpo.c @@ -34,7 +34,6 @@ test_writeverify16_dpo(void) struct scsi_mode_sense *ms; struct scsi_task *rso_task = NULL; struct scsi_report_supported_op_codes_one_command *rsoc; - unsigned char *buf = alloca(block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITEVERIFY16 DPO flag"); @@ -42,7 +41,7 @@ test_writeverify16_dpo(void) CHECK_FOR_SBC; ret = read10(sd, NULL, 0, block_size, - block_size, 0, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); @@ -65,14 +64,14 @@ test_writeverify16_dpo(void) } logging(LOG_VERBOSE, "Test WRITEVERIFY16 with DPO==1"); - memset(buf, 0xa6, block_size); + memset(scratch, 0xa6, block_size); if (dpofua) { WRITEVERIFY16(sd, 0, block_size, - block_size, 0, 1, 0, 0, buf, + block_size, 0, 1, 0, 0, scratch, EXPECT_STATUS_GOOD); } else { WRITEVERIFY16(sd, 0, block_size, - block_size, 0, 1, 0, 0, buf, + block_size, 0, 1, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); } diff --git a/test-tool/test_writeverify16_flags.c b/test-tool/test_writeverify16_flags.c index 7fe01b2..93e6d0f 100644 --- a/test-tool/test_writeverify16_flags.c +++ b/test-tool/test_writeverify16_flags.c @@ -30,8 +30,6 @@ void test_writeverify16_flags(void) { - unsigned char *buf = alloca(block_size); - CHECK_FOR_DATALOSS; logging(LOG_VERBOSE, LOG_BLANK_LINE); @@ -39,7 +37,7 @@ test_writeverify16_flags(void) logging(LOG_VERBOSE, "Test WRITEVERIFY16 with BYTCHK==1"); - memset(buf, 0xa6, block_size); - WRITEVERIFY16(sd, 0, block_size, block_size, 0, 0, 1, 0, buf, + memset(scratch, 0xa6, block_size); + WRITEVERIFY16(sd, 0, block_size, block_size, 0, 0, 1, 0, scratch, EXPECT_STATUS_GOOD); } diff --git a/test-tool/test_writeverify16_simple.c b/test-tool/test_writeverify16_simple.c index 4c879ba..f4acc71 100644 --- a/test-tool/test_writeverify16_simple.c +++ b/test-tool/test_writeverify16_simple.c @@ -31,20 +31,19 @@ void test_writeverify16_simple(void) { int i; - unsigned char *buf = alloca(256 * block_size); CHECK_FOR_DATALOSS; CHECK_FOR_SBC; logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITEVERIFY16 of 1-256 blocks at the start of the LUN"); - memset(buf, 0xa6, 256 * block_size); + memset(scratch, 0xa6, 256 * block_size); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } WRITEVERIFY16(sd, 0, i * block_size, - block_size, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); } @@ -54,7 +53,7 @@ test_writeverify16_simple(void) break; } WRITEVERIFY16(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 0, 0, buf, + i * block_size, block_size, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); } } diff --git a/test-tool/test_writeverify16_wrprotect.c b/test-tool/test_writeverify16_wrprotect.c index 6836b91..1b7a2e6 100644 --- a/test-tool/test_writeverify16_wrprotect.c +++ b/test-tool/test_writeverify16_wrprotect.c @@ -32,7 +32,6 @@ void test_writeverify16_wrprotect(void) { int i; - unsigned char *buf = alloca(block_size); /* * Try out different non-zero values for WRPROTECT. @@ -43,12 +42,12 @@ test_writeverify16_wrprotect(void) CHECK_FOR_DATALOSS; CHECK_FOR_SBC; - memset(buf, 0xa6, block_size); + memset(scratch, 0xa6, block_size); if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); for (i = 1; i < 8; i++) { WRITEVERIFY16(sd, 0, block_size, block_size, - i, 0, 0, 0, buf, + i, 0, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB); } return;