From 35dcf8959977eedafb13cbe8e63537c60c8fe214 Mon Sep 17 00:00:00 2001 From: Simon Rowe Date: Fri, 20 Aug 2021 10:18:05 +0000 Subject: [PATCH] examples/iscsi-dd: use stderr for all error text Signed-off-by: Simon Rowe --- examples/iscsi-dd.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/examples/iscsi-dd.c b/examples/iscsi-dd.c index f153a94..b2d41ac 100644 --- a/examples/iscsi-dd.c +++ b/examples/iscsi-dd.c @@ -76,13 +76,13 @@ void write_cb(struct iscsi_context *iscsi, int status, void *command_data, void struct client *client = wt->client; if (status == SCSI_STATUS_CHECK_CONDITION) { - printf("Write10/16 failed with sense key:%d ascq:%04x\n", task->sense.key, task->sense.ascq); + fprintf(stderr, "Write10/16 failed with sense key:%d ascq:%04x\n", task->sense.key, task->sense.ascq); scsi_free_scsi_task(task); exit(10); } if (status != SCSI_STATUS_GOOD) { - printf("Write10/16 failed with %s\n", iscsi_get_error(iscsi)); + fprintf(stderr, "Write10/16 failed with %s\n", iscsi_get_error(iscsi)); if (!client->ignore_errors) { scsi_free_scsi_task(task); exit(10); @@ -117,13 +117,13 @@ void read_cb(struct iscsi_context *iscsi, int status, void *command_data, void * struct scsi_task *task2; if (status == SCSI_STATUS_CHECK_CONDITION) { - printf("Read10/16 failed with sense key:%d ascq:%04x\n", task->sense.key, task->sense.ascq); + fprintf(stderr, "Read10/16 failed with sense key:%d ascq:%04x\n", task->sense.key, task->sense.ascq); scsi_free_scsi_task(task); exit(10); } if (status != SCSI_STATUS_GOOD) { - printf("Read10/16 failed with %s\n", iscsi_get_error(iscsi)); + fprintf(stderr, "Read10/16 failed with %s\n", iscsi_get_error(iscsi)); if (!client->ignore_errors) { scsi_free_scsi_task(task); exit(10); @@ -137,7 +137,7 @@ void read_cb(struct iscsi_context *iscsi, int status, void *command_data, void * if (client->use_16_for_rw) { read16_cdb = scsi_cdb_unmarshall(task, SCSI_OPCODE_READ16); if (read16_cdb == NULL) { - printf("Failed to unmarshall READ16 CDB.\n"); + fprintf(stderr, "Failed to unmarshall READ16 CDB.\n"); exit(10); } task2 = iscsi_write16_task(client->dst.iscsi, client->dst.lun, @@ -147,7 +147,7 @@ void read_cb(struct iscsi_context *iscsi, int status, void *command_data, void * } else { read10_cdb = scsi_cdb_unmarshall(task, SCSI_OPCODE_READ10); if (read10_cdb == NULL) { - printf("Failed to unmarshall READ10 CDB.\n"); + fprintf(stderr, "Failed to unmarshall READ10 CDB.\n"); exit(10); } task2 = iscsi_write10_task(client->dst.iscsi, client->dst.lun, @@ -156,7 +156,7 @@ void read_cb(struct iscsi_context *iscsi, int status, void *command_data, void * write_cb, wt); } if (task2 == NULL) { - printf("failed to send write10/16 command\n"); + fprintf(stderr, "failed to send write10/16 command\n"); scsi_free_scsi_task(task); exit(10); } @@ -190,7 +190,7 @@ void fill_read_queue(struct client *client) read_cb, client); } if (task == NULL) { - printf("failed to send read10/16 command\n"); + fprintf(stderr, "failed to send read10/16 command\n"); exit(10); } client->pos += num_blocks; @@ -287,14 +287,14 @@ void xcopy_cb(struct iscsi_context *iscsi, int status, void *command_data, void struct scsi_task *task = command_data; if (status == SCSI_STATUS_CHECK_CONDITION) { - printf("XCOPY failed with sense key:%d ascq:%04x\n", + fprintf(stderr, "XCOPY failed with sense key:%d ascq:%04x\n", task->sense.key, task->sense.ascq); scsi_free_scsi_task(task); exit(10); } if (status != SCSI_STATUS_GOOD) { - printf("XCOPY failed with %s\n", iscsi_get_error(iscsi)); + fprintf(stderr, "XCOPY failed with %s\n", iscsi_get_error(iscsi)); if (!client->ignore_errors) { scsi_free_scsi_task(task); exit(10); @@ -341,7 +341,7 @@ void fill_xcopy_queue(struct client *client) 28; /* BLK_TO_BLK_SEG_DESCR */ data.data = malloc(data.size); if (data.data == NULL) { - printf("failed to alloc XCOPY buffer\n"); + fprintf(stderr, "failed to alloc XCOPY buffer\n"); exit(10); } @@ -371,7 +371,7 @@ void fill_xcopy_queue(struct client *client) client->src.lun, &data, xcopy_cb, client); if (task == NULL) { - printf("failed to send XCOPY command\n"); + fprintf(stderr, "failed to send XCOPY command\n"); exit(10); } @@ -732,15 +732,15 @@ int main(int argc, char *argv[]) } if (poll(&pfd[0], 2, -1) < 0) { - printf("Poll failed\n"); + fprintf(stderr, "Poll failed\n"); exit(10); } if (iscsi_service(client.src.iscsi, pfd[0].revents) < 0) { - printf("iscsi_service failed with : %s\n", iscsi_get_error(client.src.iscsi)); + fprintf(stderr, "iscsi_service failed with : %s\n", iscsi_get_error(client.src.iscsi)); break; } if (iscsi_service(client.dst.iscsi, pfd[1].revents) < 0) { - printf("iscsi_service failed with : %s\n", iscsi_get_error(client.dst.iscsi)); + fprintf(stderr, "iscsi_service failed with : %s\n", iscsi_get_error(client.dst.iscsi)); break; } }