From b910efa7c5e9bbd5c343cf3376e459b7513713c6 Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Wed, 31 Oct 2012 14:34:30 +0100 Subject: [PATCH 01/29] iscsi_parse_url: fix spurious compiler warnings gcc-4.6.3 reports these: libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include "-D_U_=__attribute__((unused))" -Wall -W -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-align -Wwrite-strings -g -O2 -MT lib/init.lo -MD -MP -MF lib/.deps/init.Tpo -c lib/init.c -fPIC -DPIC -o lib/.libs/init.o lib/init.c: In function 'iscsi_parse_url': lib/init.c:410:18: warning: 'l' may be used uninitialized in this function [-Wuninitialized] lib/init.c:409:10: warning: 'target' may be used uninitialized in this function [-Wuninitialized] Both warnings appear to be spurious though, as both "target" and "l" are only used if "full" is set, which implies that these are initialized before. Signed-off-by: Arne Redlich --- lib/init.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/init.c b/lib/init.c index 533b654..d7d32d2 100644 --- a/lib/init.c +++ b/lib/init.c @@ -78,7 +78,7 @@ iscsi_create_context(const char *initiator_name) if (getenv("LIBISCSI_DEBUG") != NULL) { iscsi_set_debug(iscsi,atoi(getenv("LIBISCSI_DEBUG"))); } - + if (getenv("LIBISCSI_TCP_USER_TIMEOUT") != NULL) { iscsi_set_tcp_user_timeout(iscsi,atoi(getenv("LIBISCSI_TCP_USER_TIMEOUT"))); } @@ -209,7 +209,7 @@ iscsi_destroy_context(struct iscsi_context *iscsi) if (iscsi->is_loggedin) { pdu->callback(iscsi, SCSI_STATUS_CANCELLED, NULL, pdu->private_data); - } + } } iscsi_free_pdu(iscsi, pdu); } @@ -250,7 +250,7 @@ iscsi_set_error(struct iscsi_context *iscsi, const char *error_string, ...) strncpy(errstr,"could not format error string!",MAX_STRING_SIZE); } va_end(ap); - + strncpy(iscsi->error_string,errstr,MAX_STRING_SIZE); DPRINTF(iscsi,1,"%s",iscsi->error_string); } @@ -308,10 +308,10 @@ iscsi_parse_url(struct iscsi_context *iscsi, const char *url, int full) char *portal; char *user = NULL; char *passwd = NULL; - char *target; + char *target = NULL; char *lun; char *tmp; - int l; + int l = 0; if (strncmp(url, "iscsi://", 8)) { if (full) { @@ -390,7 +390,7 @@ iscsi_parse_url(struct iscsi_context *iscsi, const char *url, int full) tmp=strchr(portal,'/'); if (tmp) *tmp=0; } - + iscsi_url = malloc(sizeof(struct iscsi_url)); if (iscsi_url == NULL) { iscsi_set_error(iscsi, "Out-of-memory: Failed to allocate iscsi_url structure"); @@ -404,12 +404,12 @@ iscsi_parse_url(struct iscsi_context *iscsi, const char *url, int full) strncpy(iscsi_url->user,user,MAX_STRING_SIZE); strncpy(iscsi_url->passwd,passwd,MAX_STRING_SIZE); } - + if (full) { strncpy(iscsi_url->target,target,MAX_STRING_SIZE); iscsi_url->lun = l; } - + return iscsi_url; } From 558ad000383725b70f53704d95c06c4869a57ec3 Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Wed, 31 Oct 2012 14:39:51 +0100 Subject: [PATCH 02/29] iscsi_service_reconnect_if_loggedin: fix compiler warning and make it static Quoth gcc-4.6.3: libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include "-D_U_=__attribute__((unused))" -Wall -W -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-align -Wwrite-strings -g -O2 -MT lib/socket.lo -MD -MP -MF lib/.deps/socket.Tpo -c lib/socket.c -fPIC -DPIC -o lib/.libs/socket.o lib/socket.c:445:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration] Fix this and make it a static function. Also remove trailing whitespace from this file while at it. Signed-off-by: Arne Redlich --- lib/socket.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/lib/socket.c b/lib/socket.c index 68c6a13..a4b1d49 100644 --- a/lib/socket.c +++ b/lib/socket.c @@ -61,7 +61,7 @@ static void set_nonblocking(int fd) int set_tcp_sockopt(int sockfd, int optname, int value) { int level; - + #if defined(__FreeBSD__) || defined(__sun) struct protoent *buf; @@ -71,8 +71,8 @@ int set_tcp_sockopt(int sockfd, int optname, int value) return -1; #else level = SOL_TCP; - #endif - + #endif + return setsockopt(sockfd, level, optname, &value, sizeof(value)); } @@ -156,7 +156,7 @@ iscsi_connect_async(struct iscsi_context *iscsi, const char *portal, "Missing ']' in IPv6 address", portal); return -1; } - *str = 0; + *str = 0; } /* is it a hostname ? */ @@ -205,9 +205,9 @@ iscsi_connect_async(struct iscsi_context *iscsi, const char *portal, iscsi->connect_data = private_data; set_nonblocking(iscsi->fd); - + iscsi_set_tcp_keepalive(iscsi, iscsi->tcp_keepidle, iscsi->tcp_keepcnt, iscsi->tcp_keepintvl); - + if (iscsi->tcp_user_timeout > 0) { set_tcp_user_timeout(iscsi); } @@ -227,9 +227,9 @@ iscsi_connect_async(struct iscsi_context *iscsi, const char *portal, } freeaddrinfo(ai); - + strncpy(iscsi->connected_portal,portal,MAX_STRING_SIZE); - + return 0; } @@ -243,7 +243,7 @@ iscsi_disconnect(struct iscsi_context *iscsi) } close(iscsi->fd); - + if (iscsi->connected_portal[0]) DPRINTF(iscsi,2,"disconnected from portal %s",iscsi->connected_portal); @@ -409,7 +409,7 @@ iscsi_write_to_socket(struct iscsi_context *iscsi) /* stop sending. maxcmdsn is reached */ return 0; } - + total = iscsi->outqueue->outdata.size; total = (total + 3) & 0xfffffffc; @@ -442,7 +442,7 @@ iscsi_write_to_socket(struct iscsi_context *iscsi) return 0; } -int inline +static inline int iscsi_service_reconnect_if_loggedin(struct iscsi_context *iscsi) { if (iscsi->is_loggedin) { @@ -506,7 +506,7 @@ iscsi_service(struct iscsi_context *iscsi, int revents) NULL, iscsi->connect_data); iscsi->socket_status_cb = NULL; } - + return iscsi_service_reconnect_if_loggedin(iscsi); } @@ -585,31 +585,31 @@ iscsi_free_iscsi_inqueue(struct iscsi_in_pdu *inqueue) void iscsi_set_tcp_syncnt(struct iscsi_context *iscsi, int value) { iscsi->tcp_syncnt=value; - DPRINTF(iscsi,2,"TCP_SYNCNT will be set to %d on next socket creation",value); + DPRINTF(iscsi,2,"TCP_SYNCNT will be set to %d on next socket creation",value); } void iscsi_set_tcp_user_timeout(struct iscsi_context *iscsi, int value) { iscsi->tcp_user_timeout=value; - DPRINTF(iscsi,2,"TCP_USER_TIMEOUT will be set to %dms on next socket creation",value); + DPRINTF(iscsi,2,"TCP_USER_TIMEOUT will be set to %dms on next socket creation",value); } void iscsi_set_tcp_keepidle(struct iscsi_context *iscsi, int value) { iscsi->tcp_keepidle=value; - DPRINTF(iscsi,2,"TCP_KEEPIDLE will be set to %d on next socket creation",value); + DPRINTF(iscsi,2,"TCP_KEEPIDLE will be set to %d on next socket creation",value); } void iscsi_set_tcp_keepcnt(struct iscsi_context *iscsi, int value) { iscsi->tcp_keepcnt=value; - DPRINTF(iscsi,2,"TCP_KEEPCNT will be set to %d on next socket creation",value); + DPRINTF(iscsi,2,"TCP_KEEPCNT will be set to %d on next socket creation",value); } void iscsi_set_tcp_keepintvl(struct iscsi_context *iscsi, int value) { iscsi->tcp_keepintvl=value; - DPRINTF(iscsi,2,"TCP_KEEPINTVL will be set to %d on next socket creation",value); + DPRINTF(iscsi,2,"TCP_KEEPINTVL will be set to %d on next socket creation",value); } int iscsi_set_tcp_keepalive(struct iscsi_context *iscsi, int idle, int count, int interval) @@ -646,4 +646,3 @@ int iscsi_set_tcp_keepalive(struct iscsi_context *iscsi, int idle, int count, in return 0; } - From 3af45f58671afa01dbed9ae4ac7f055b6eb1492a Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Wed, 31 Oct 2012 15:19:55 +0100 Subject: [PATCH 03/29] testunitready_simple: fix compiler warnings The compiler complains about an unused label and and unused variable. Signed-off-by: Arne Redlich --- test-tool/0000_testunitready_simple.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/test-tool/0000_testunitready_simple.c b/test-tool/0000_testunitready_simple.c index 029fc44..c699aff 100644 --- a/test-tool/0000_testunitready_simple.c +++ b/test-tool/0000_testunitready_simple.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -21,10 +21,10 @@ #include "iscsi-test.h" int T0000_testunitready_simple(const char *initiator, const char *url, int data_loss _U_, int show_info) -{ +{ struct iscsi_context *iscsi; struct scsi_task *task; - int ret, i, lun; + int ret, lun; printf("0000_testunitready_simple:\n"); printf("===================\n"); @@ -49,20 +49,18 @@ int T0000_testunitready_simple(const char *initiator, const char *url, int data_ printf("[FAILED]\n"); printf("Failed to send TEST UNIT READY command: %s\n", iscsi_get_error(iscsi)); ret++; - goto test2; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("TEST UNIT READY command: failed with sense %s\n", iscsi_get_error(iscsi)); ret++; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test2: - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); From 4d27ecae324555d2e5a5de71aef6e2602fd27640 Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Wed, 31 Oct 2012 15:32:18 +0100 Subject: [PATCH 04/29] test-tool: fix initiatorname and initiatorname2 issues gcc-4.6.3 warned about this one on several occasions: gcc -DHAVE_CONFIG_H -I. -I. -I./include "-D_U_=__attribute__((unused))" -I./test-tool -Wall -W -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-align -Wwrite-strings -ggdb3 -O0 -MT test-tool/bin_iscsi_test-0000_testunitready_simple.o -MD -MP -MF test-tool/.deps/bin_iscsi_test-0000_testunitready_simple.Tpo -c -o test-tool/bin_iscsi_test-0000_testunitready_simple.o `test -f 'test-tool/0000_testunitready_simple.c' || echo './'`test-tool/0000_testunitready_simple.c test-tool/0000_testunitready_simple.c: In function 'T0000_testunitready_simple': test-tool/0000_testunitready_simple.c:23:44: warning: declaration of 'initiator' shadows a global declaration [-Wshadow] test-tool/iscsi-test.h:20:20: warning: shadowed declaration is here [-Wshadow] For now the global initiator is renamed to initiatorname1 (and initiator2 is renamed to initiatorname2, respectively), but ultimately the globals should probably go away. While fixing this it also became apparent that initiator-name-2 was parsed into the "initiator" variable as well. Signed-off-by: Arne Redlich --- test-tool/0420_reserve6_simple.c | 36 +++++++++++++------------- test-tool/0421_reserve6_lun_reset.c | 28 ++++++++++---------- test-tool/0422_reserve6_logout.c | 26 +++++++++---------- test-tool/0423_reserve6_sessionloss.c | 26 +++++++++---------- test-tool/0424_reserve6_target_reset.c | 28 ++++++++++---------- test-tool/iscsi-test.c | 27 ++++++++++--------- test-tool/iscsi-test.h | 13 +++++----- 7 files changed, 91 insertions(+), 93 deletions(-) diff --git a/test-tool/0420_reserve6_simple.c b/test-tool/0420_reserve6_simple.c index b5f55b3..4ca6ee6 100644 --- a/test-tool/0420_reserve6_simple.c +++ b/test-tool/0420_reserve6_simple.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Jon Grimm - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -23,7 +23,7 @@ #include "iscsi-test.h" int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss, int show_info) -{ +{ struct iscsi_context *iscsi, *iscsi2; struct scsi_task *task; int ret, lun; @@ -40,7 +40,7 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss, printf("4. Test Initiator 1 can testunitready if reserved by Initiator 1.\n"); printf("5. Test Initiator 2 can't testunitready if reserved by Initiator 1.\n"); printf("6. Test Initiator 2 can get reservation once Intiator 1 releases reservation.\n"); - + printf("\n"); return 0; } @@ -51,9 +51,9 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss, return -1; } - iscsi2 = iscsi_context_login(initiator2, url, &lun); + iscsi2 = iscsi_context_login(initiatorname2, url, &lun); if (iscsi2 == NULL) { - printf("Failed to login to target\n"); + printf("Failed to login to target\n"); ret = 1; goto out_login1; } @@ -71,8 +71,8 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss, } if (task->status != SCSI_STATUS_GOOD) { if (task->status == SCSI_STATUS_CHECK_CONDITION - && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST - && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { + && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST + && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { printf("[OK]\n"); printf("RESERVE6 Not Supported\n"); goto finished2; @@ -80,7 +80,7 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss, printf("[FAILED]\n"); printf("RESERVE6 failed but ascq was wrong. Should " "have failed with ILLEGAL_REQUEST/" - "INVALID OPERATOR. Sense:%s\n", + "INVALID OPERATOR. Sense:%s\n", iscsi_get_error(iscsi)); ret = -1; goto finished2; @@ -93,14 +93,14 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss, task = iscsi_release6_sync(iscsi, lun); if (task == NULL) { printf("[FAILED]\n"); - printf("Failed to send RELEASE6 command : %s\n", + printf("Failed to send RELEASE6 command : %s\n", iscsi_get_error(iscsi)); ret = -1; goto finished1; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); - printf("RELEASE6 command failed : %s\n", + printf("RELEASE6 command failed : %s\n", iscsi_get_error(iscsi)); ret = -1; goto finished2; @@ -157,7 +157,7 @@ test3: iscsi_get_error(iscsi)); ret = -1; goto finished1; - } + } /* We expect this command to fail for the test to pass. */ if (task->status != SCSI_STATUS_RESERVATION_CONFLICT) { printf("[FAILED]\n"); @@ -196,7 +196,7 @@ test4: task = iscsi_testunitready_sync(iscsi, lun); if (task == NULL) { printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", + printf("Failed to send TEST UNIT READY command: %s\n", iscsi_get_error(iscsi)); ret = -1; goto finished1; @@ -216,7 +216,7 @@ test5: task = iscsi_testunitready_sync(iscsi2, lun); if (task == NULL) { printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", + printf("Failed to send TEST UNIT READY command: %s\n", iscsi_get_error(iscsi2)); ret = -1; goto finished1; @@ -236,14 +236,14 @@ test6: task = iscsi_release6_sync(iscsi, lun); if (task == NULL) { printf("[FAILED]\n"); - printf("Failed to send RELEASE6 command : %s\n", + printf("Failed to send RELEASE6 command : %s\n", iscsi_get_error(iscsi)); ret = -1; goto finished1; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); - printf("RELEASE6 command failed : %s\n", + printf("RELEASE6 command failed : %s\n", iscsi_get_error(iscsi)); ret = -1; goto finished2; diff --git a/test-tool/0421_reserve6_lun_reset.c b/test-tool/0421_reserve6_lun_reset.c index e956d0e..8fa91f6 100644 --- a/test-tool/0421_reserve6_lun_reset.c +++ b/test-tool/0421_reserve6_lun_reset.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -38,7 +38,7 @@ static void mgmt_cb(struct iscsi_context *iscsi _U_, int status _U_, } int T0421_reserve6_lun_reset(const char *initiator, const char *url, int data_loss, int show_info) -{ +{ struct iscsi_context *iscsi, *iscsi2; struct scsi_task *task; int ret, lun; @@ -65,7 +65,7 @@ int T0421_reserve6_lun_reset(const char *initiator, const char *url, int data_lo return -1; } - iscsi2 = iscsi_context_login(initiator2, url, &lun); + iscsi2 = iscsi_context_login(initiatorname2, url, &lun); if (iscsi2 == NULL) { printf("Failed to login to target\n"); return -1; @@ -86,8 +86,8 @@ int T0421_reserve6_lun_reset(const char *initiator, const char *url, int data_lo goto finished; } if (task->status == SCSI_STATUS_CHECK_CONDITION - && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST - && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { + && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST + && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { printf("[SKIPPED]\n"); printf("RESERVE6 Not Supported\n"); ret = -2; @@ -96,9 +96,9 @@ int T0421_reserve6_lun_reset(const char *initiator, const char *url, int data_lo } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); - printf("RESERVE6 failed with sense:%s\n", + printf("RESERVE6 failed with sense:%s\n", iscsi_get_error(iscsi)); - ret = -1; + ret = -1; scsi_free_scsi_task(task); goto test2; } @@ -111,7 +111,7 @@ test2: task = iscsi_testunitready_sync(iscsi, lun); if (task == NULL) { printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", + printf("Failed to send TEST UNIT READY command: %s\n", iscsi_get_error(iscsi)); ret = -1; goto finished; @@ -133,7 +133,7 @@ test3: task = iscsi_testunitready_sync(iscsi2, lun); if (task == NULL) { printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", + printf("Failed to send TEST UNIT READY command: %s\n", iscsi_get_error(iscsi2)); ret = -1; goto finished; @@ -179,7 +179,7 @@ test5: task = iscsi_testunitready_sync(iscsi2, lun); if (task == NULL) { printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", + printf("Failed to send TEST UNIT READY command: %s\n", iscsi_get_error(iscsi2)); ret = -1; goto finished; @@ -189,7 +189,7 @@ test5: && task->sense.ascq == SCSI_SENSE_ASCQ_BUS_RESET) { printf("Got BUS RESET. Retry accessing the LUN\n"); goto test5; - + } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); diff --git a/test-tool/0422_reserve6_logout.c b/test-tool/0422_reserve6_logout.c index e30d597..3daf666 100644 --- a/test-tool/0422_reserve6_logout.c +++ b/test-tool/0422_reserve6_logout.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -23,7 +23,7 @@ #include "iscsi-test.h" int T0422_reserve6_logout(const char *initiator, const char *url, int data_loss, int show_info) -{ +{ struct iscsi_context *iscsi, *iscsi2; struct scsi_task *task; int ret, lun; @@ -48,7 +48,7 @@ int T0422_reserve6_logout(const char *initiator, const char *url, int data_loss, return -1; } - iscsi2 = iscsi_context_login(initiator2, url, &lun); + iscsi2 = iscsi_context_login(initiatorname2, url, &lun); if (iscsi2 == NULL) { printf("Failed to login to target\n"); return -1; @@ -69,8 +69,8 @@ int T0422_reserve6_logout(const char *initiator, const char *url, int data_loss, goto finished; } if (task->status == SCSI_STATUS_CHECK_CONDITION - && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST - && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { + && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST + && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { printf("[SKIPPED]\n"); printf("RESERVE6 Not Supported\n"); ret = -2; @@ -79,9 +79,9 @@ int T0422_reserve6_logout(const char *initiator, const char *url, int data_loss, } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); - printf("RESERVE6 failed with sense:%s\n", + printf("RESERVE6 failed with sense:%s\n", iscsi_get_error(iscsi)); - ret = -1; + ret = -1; scsi_free_scsi_task(task); goto test2; } @@ -94,7 +94,7 @@ test2: task = iscsi_testunitready_sync(iscsi, lun); if (task == NULL) { printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", + printf("Failed to send TEST UNIT READY command: %s\n", iscsi_get_error(iscsi)); ret = -1; goto finished; @@ -116,7 +116,7 @@ test3: task = iscsi_testunitready_sync(iscsi2, lun); if (task == NULL) { printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", + printf("Failed to send TEST UNIT READY command: %s\n", iscsi_get_error(iscsi2)); ret = -1; goto finished; @@ -142,7 +142,7 @@ test5: task = iscsi_testunitready_sync(iscsi2, lun); if (task == NULL) { printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", + printf("Failed to send TEST UNIT READY command: %s\n", iscsi_get_error(iscsi2)); ret = -1; goto finished; diff --git a/test-tool/0423_reserve6_sessionloss.c b/test-tool/0423_reserve6_sessionloss.c index 94e4b78..9d10e28 100644 --- a/test-tool/0423_reserve6_sessionloss.c +++ b/test-tool/0423_reserve6_sessionloss.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -23,7 +23,7 @@ #include "iscsi-test.h" int T0423_reserve6_sessionloss(const char *initiator, const char *url, int data_loss, int show_info) -{ +{ struct iscsi_context *iscsi, *iscsi2; struct scsi_task *task; int ret, lun; @@ -48,7 +48,7 @@ int T0423_reserve6_sessionloss(const char *initiator, const char *url, int data_ return -1; } - iscsi2 = iscsi_context_login(initiator2, url, &lun); + iscsi2 = iscsi_context_login(initiatorname2, url, &lun); if (iscsi2 == NULL) { printf("Failed to login to target\n"); return -1; @@ -69,8 +69,8 @@ int T0423_reserve6_sessionloss(const char *initiator, const char *url, int data_ goto finished; } if (task->status == SCSI_STATUS_CHECK_CONDITION - && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST - && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { + && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST + && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { printf("[SKIPPED]\n"); printf("RESERVE6 Not Supported\n"); ret = -2; @@ -79,9 +79,9 @@ int T0423_reserve6_sessionloss(const char *initiator, const char *url, int data_ } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); - printf("RESERVE6 failed with sense:%s\n", + printf("RESERVE6 failed with sense:%s\n", iscsi_get_error(iscsi)); - ret = -1; + ret = -1; scsi_free_scsi_task(task); goto test2; } @@ -94,7 +94,7 @@ test2: task = iscsi_testunitready_sync(iscsi, lun); if (task == NULL) { printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", + printf("Failed to send TEST UNIT READY command: %s\n", iscsi_get_error(iscsi)); ret = -1; goto finished; @@ -116,7 +116,7 @@ test3: task = iscsi_testunitready_sync(iscsi2, lun); if (task == NULL) { printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", + printf("Failed to send TEST UNIT READY command: %s\n", iscsi_get_error(iscsi2)); ret = -1; goto finished; @@ -141,7 +141,7 @@ test5: task = iscsi_testunitready_sync(iscsi2, lun); if (task == NULL) { printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", + printf("Failed to send TEST UNIT READY command: %s\n", iscsi_get_error(iscsi2)); ret = -1; goto finished; diff --git a/test-tool/0424_reserve6_target_reset.c b/test-tool/0424_reserve6_target_reset.c index b9fd07d..2507737 100644 --- a/test-tool/0424_reserve6_target_reset.c +++ b/test-tool/0424_reserve6_target_reset.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -38,7 +38,7 @@ static void mgmt_cb(struct iscsi_context *iscsi _U_, int status _U_, } int T0424_reserve6_target_reset(const char *initiator, const char *url, int data_loss, int show_info) -{ +{ struct iscsi_context *iscsi, *iscsi2; struct scsi_task *task; int ret, lun; @@ -65,7 +65,7 @@ int T0424_reserve6_target_reset(const char *initiator, const char *url, int data return -1; } - iscsi2 = iscsi_context_login(initiator2, url, &lun); + iscsi2 = iscsi_context_login(initiatorname2, url, &lun); if (iscsi2 == NULL) { printf("Failed to login to target\n"); return -1; @@ -86,8 +86,8 @@ int T0424_reserve6_target_reset(const char *initiator, const char *url, int data goto finished; } if (task->status == SCSI_STATUS_CHECK_CONDITION - && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST - && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { + && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST + && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { printf("[SKIPPED]\n"); printf("RESERVE6 Not Supported\n"); ret = -2; @@ -96,9 +96,9 @@ int T0424_reserve6_target_reset(const char *initiator, const char *url, int data } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); - printf("RESERVE6 failed with sense:%s\n", + printf("RESERVE6 failed with sense:%s\n", iscsi_get_error(iscsi)); - ret = -1; + ret = -1; scsi_free_scsi_task(task); goto test2; } @@ -111,7 +111,7 @@ test2: task = iscsi_testunitready_sync(iscsi, lun); if (task == NULL) { printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", + printf("Failed to send TEST UNIT READY command: %s\n", iscsi_get_error(iscsi)); ret = -1; goto finished; @@ -133,7 +133,7 @@ test3: task = iscsi_testunitready_sync(iscsi2, lun); if (task == NULL) { printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", + printf("Failed to send TEST UNIT READY command: %s\n", iscsi_get_error(iscsi2)); ret = -1; goto finished; @@ -179,7 +179,7 @@ test5: task = iscsi_testunitready_sync(iscsi2, lun); if (task == NULL) { printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", + printf("Failed to send TEST UNIT READY command: %s\n", iscsi_get_error(iscsi2)); ret = -1; goto finished; @@ -189,7 +189,7 @@ test5: && task->sense.ascq == SCSI_SENSE_ASCQ_BUS_RESET) { printf("Got BUS RESET. Retry accessing the LUN\n"); goto test5; - + } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); diff --git a/test-tool/iscsi-test.c b/test-tool/iscsi-test.c index 27e61cf..948bbfc 100644 --- a/test-tool/iscsi-test.c +++ b/test-tool/iscsi-test.c @@ -1,18 +1,18 @@ -/* +/* iscsi-test tool Copyright (C) 2010 by Ronnie Sahlberg - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -34,8 +34,8 @@ #include "iscsi-private.h" #include "iscsi-test.h" -const char *initiator = "iqn.2007-10.com.github:sahlberg:libiscsi:iscsi-test"; -const char *initiator2 = "iqn.2007-10.com.github:sahlberg:libiscsi:iscsi-test-2"; +const char *initiatorname1 = "iqn.2007-10.com.github:sahlberg:libiscsi:iscsi-test"; +const char *initiatorname2 = "iqn.2007-10.com.github:sahlberg:libiscsi:iscsi-test-2"; static int data_loss = 0; static int show_info = 0; @@ -288,7 +288,7 @@ struct iscsi_context *iscsi_context_login(const char *initiatorname, const char iscsi_url = iscsi_parse_full_url(iscsi, url); if (iscsi_url == NULL) { - fprintf(stderr, "Failed to parse URL: %s\n", + fprintf(stderr, "Failed to parse URL: %s\n", iscsi_get_error(iscsi)); iscsi_destroy_context(iscsi); return NULL; @@ -387,8 +387,8 @@ int main(int argc, const char *argv[]) { "help", '?', POPT_ARG_NONE, &show_help, 0, "Show this help message", NULL }, { "usage", 0, POPT_ARG_NONE, &show_usage, 0, "Display brief usage message", NULL }, { "list", 'l', POPT_ARG_NONE, &list_tests, 0, "List all tests", NULL }, - { "initiator-name", 'i', POPT_ARG_STRING, &initiator, 0, "Initiatorname to use", "iqn-name" }, - { "initiator-name-2", 'I', POPT_ARG_STRING, &initiator, 0, "Second initiatorname to use for tests using more two sessions", "iqn-name" }, + { "initiator-name", 'i', POPT_ARG_STRING, &initiatorname1, 0, "Initiatorname to use", "iqn-name" }, + { "initiator-name-2", 'I', POPT_ARG_STRING, &initiatorname2, 0, "Second initiatorname to use for tests using more than one session", "iqn-name" }, { "test", 't', POPT_ARG_STRING, &testname, 0, "Which test to run", "testname" }, { "skip", 's', POPT_ARG_STRING, &skipname, 0, "Which test to skip", "skipname" }, { "info", 0, POPT_ARG_NONE, &show_info, 0, "Show information about the test", "testname" }, @@ -427,7 +427,7 @@ int main(int argc, const char *argv[]) for (test = &tests[0]; test->name; test++) { printf("%s\n", test->name); if (show_info) { - test->test(initiator, url, data_loss, show_info); + test->test(initiatorname1, url, data_loss, show_info); } } exit(0); @@ -438,7 +438,7 @@ int main(int argc, const char *argv[]) fprintf(stderr, "You must specify the URL\n"); print_usage(); free(skipname); - free(testname); + free(testname); exit(10); } @@ -447,7 +447,7 @@ int main(int argc, const char *argv[]) if (testname != NULL && fnmatch(testname, test->name, 0)) { continue; } - + if (skipname != NULL) { char * pchr = skipname; char * pchr2 = NULL; @@ -463,7 +463,7 @@ int main(int argc, const char *argv[]) if (skip) continue; } - res = test->test(initiator, url, data_loss, show_info); + res = test->test(initiatorname1, url, data_loss, show_info); if (res == 0) { printf("TEST %s [OK]\n", test->name); } else if (res == -2) { @@ -482,4 +482,3 @@ int main(int argc, const char *argv[]) return num_failed ? num_failed : num_skipped ? 77 : 0; } - diff --git a/test-tool/iscsi-test.h b/test-tool/iscsi-test.h index d597773..3327280 100644 --- a/test-tool/iscsi-test.h +++ b/test-tool/iscsi-test.h @@ -1,24 +1,24 @@ -/* +/* iscsi-test tool Copyright (C) 2010 by Ronnie Sahlberg - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ -extern const char *initiator; -extern const char *initiator2; +extern const char *initiatorname1; +extern const char *initiatorname2; struct iscsi_context *iscsi_context_login(const char *initiatorname, const char *url, int *lun); @@ -182,4 +182,3 @@ int T1010_datasn_invalid(const char *initiator, const char *url, int data_loss, int T1020_bufferoffset_invalid(const char *initiator, const char *url, int data_loss, int show_info); int T1030_unsolicited_data_overflow(const char *initiator, const char *url, int data_loss, int show_info); int T1031_unsolicited_data_out(const char *initiator, const char *url, int data_loss, int show_info); - From 311a63c61d235a97365fa0679b19567e199a525e Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Wed, 31 Oct 2012 15:50:59 +0100 Subject: [PATCH 05/29] T0401_inquiry_alloclen: remove unused label Signed-off-by: Arne Redlich --- test-tool/0401_inquiry_alloclen.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/test-tool/0401_inquiry_alloclen.c b/test-tool/0401_inquiry_alloclen.c index 31a47c9..7fed080 100644 --- a/test-tool/0401_inquiry_alloclen.c +++ b/test-tool/0401_inquiry_alloclen.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -23,7 +23,7 @@ #include "iscsi-test.h" int T0401_inquiry_alloclen(const char *initiator, const char *url, int data_loss, int show_info) -{ +{ struct iscsi_context *iscsi; struct scsi_task *task; struct scsi_inquiry_standard *inq; @@ -57,22 +57,19 @@ int T0401_inquiry_alloclen(const char *initiator, const char *url, int data_loss printf("[FAILED]\n"); printf("Failed to send INQUIRY command : %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test2; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("INQUIRY command with alloclen:%d failed : %s\n", i, iscsi_get_error(iscsi)); scsi_free_scsi_task(task); ret = -1; - goto test2; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test2: - - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); From 45ce1537f2e6e18ba05c9926e1180d76c97eab0a Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Wed, 31 Oct 2012 15:52:11 +0100 Subject: [PATCH 06/29] T0400_inquiry_basic: fix compiler warnings gcc complains about an unused parameter (mark it as such) and unused labels (remove 'em). Signed-off-by: Arne Redlich --- test-tool/0400_inquiry_basic.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/test-tool/0400_inquiry_basic.c b/test-tool/0400_inquiry_basic.c index e70f1f4..9e8cc71 100644 --- a/test-tool/0400_inquiry_basic.c +++ b/test-tool/0400_inquiry_basic.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -22,8 +22,9 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0400_inquiry_basic(const char *initiator, const char *url, int data_loss, int show_info) -{ +int T0400_inquiry_basic(const char *initiator, const char *url, int data_loss _U_, + int show_info) +{ struct iscsi_context *iscsi; struct scsi_task *task; struct scsi_inquiry_standard *inq; @@ -100,7 +101,6 @@ int T0400_inquiry_basic(const char *initiator, const char *url, int data_loss, i } printf("[OK]\n"); -test2: printf("Check that standard data is >= 36 bytes in size ... "); if (full_size < 36) { printf("[FAILED]\n"); @@ -111,8 +111,6 @@ test2: } printf("[OK]\n"); - -test3: printf("Check device-type is either of DISK, TAPE or CD/DVD ... "); switch (inq->device_type) { case SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS: @@ -193,7 +191,7 @@ test9: if (task->datain.data[i] >= 0x20 && task->datain.data[i] <= 0x7e) { continue; } - + printf("[FAILED]\n"); printf("VENDOR_IDENTIFICATION contains non-ASCII characters\n"); ret = -1; @@ -211,7 +209,7 @@ test10: if (task->datain.data[i] >= 0x20 && task->datain.data[i] <= 0x7e) { continue; } - + printf("[FAILED]\n"); printf("PRODUCT_IDENTIFICATION contains non-ASCII characters\n"); ret = -1; @@ -243,7 +241,7 @@ test12: printf("[FAILED]\n"); printf("AERC is set but this device reports SPC-3 or later\n"); ret = -1; - goto test13; + goto test13; } printf("[OK]\n"); @@ -253,7 +251,7 @@ test13: printf("[FAILED]\n"); printf("TrmTsk is set but this device reports SPC-2 or later\n"); ret = -1; - goto test14; + goto test14; } printf("[OK]\n"); From 34b25f94c13b8c745395e3f79fd0209fa58f5dae Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Wed, 31 Oct 2012 15:53:08 +0100 Subject: [PATCH 07/29] 0122_read6_invalid.c: add missing include Signed-off-by: Arne Redlich --- test-tool/0122_read6_invalid.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test-tool/0122_read6_invalid.c b/test-tool/0122_read6_invalid.c index 9440dc3..ae548b2 100644 --- a/test-tool/0122_read6_invalid.c +++ b/test-tool/0122_read6_invalid.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2010 by Ronnie Sahlberg - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -19,11 +19,12 @@ #include #include #include "iscsi.h" +#include "iscsi-private.h" #include "scsi-lowlevel.h" #include "iscsi-test.h" int T0122_read6_invalid(const char *initiator, const char *url, int data_loss _U_, int show_info) -{ +{ struct iscsi_context *iscsi; struct scsi_task *task; struct iscsi_data data; From d983cdfc2c1b1df50dc62aed258a0c616fc5d15a Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Wed, 31 Oct 2012 15:54:33 +0100 Subject: [PATCH 08/29] T0161_readcapacity16_alloclen: remove unused variable Signed-off-by: Arne Redlich --- test-tool/0161_readcapacity16_alloclen.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/test-tool/0161_readcapacity16_alloclen.c b/test-tool/0161_readcapacity16_alloclen.c index 6f31f98..b6a74cc 100644 --- a/test-tool/0161_readcapacity16_alloclen.c +++ b/test-tool/0161_readcapacity16_alloclen.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2010 by Ronnie Sahlberg - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -24,10 +24,9 @@ #include "iscsi-test.h" int T0161_readcapacity16_alloclen(const char *initiator, const char *url, int data_loss _U_, int show_info) -{ +{ struct iscsi_context *iscsi; struct scsi_task *task; - struct iscsi_data data; int ret, lun; printf("0161_readcapacity16_alloclen:\n"); From 1be5fe1bda1a0789b49c2626736e33ab7f5908ae Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Wed, 31 Oct 2012 15:55:52 +0100 Subject: [PATCH 09/29] T0251_prefetch16_flags: remove unused variable gcc points out that num_blocks is set but never used Signed-off-by: Arne Redlich --- test-tool/0251_prefetch16_flags.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test-tool/0251_prefetch16_flags.c b/test-tool/0251_prefetch16_flags.c index 0766821..f0df610 100644 --- a/test-tool/0251_prefetch16_flags.c +++ b/test-tool/0251_prefetch16_flags.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -21,12 +21,11 @@ #include "iscsi-test.h" int T0251_prefetch16_flags(const char *initiator, const char *url, int data_loss _U_, int show_info) -{ +{ struct iscsi_context *iscsi; struct scsi_task *task; struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint64_t num_blocks; printf("0251_prefetch16_flags:\n"); printf("===================\n"); @@ -64,7 +63,7 @@ int T0251_prefetch16_flags(const char *initiator, const char *url, int data_loss scsi_free_scsi_task(task); goto finished; } - num_blocks = rc16->returned_lba; + scsi_free_scsi_task(task); ret = 0; From e9911469020703e90be3e0084272f41b378492d6 Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Wed, 31 Oct 2012 15:58:31 +0100 Subject: [PATCH 10/29] T0241_prefetch10_flags: remove unused variable Pointed out by gcc: num_blocks is set but unused Signed-off-by: Arne Redlich --- test-tool/0241_prefetch10_flags.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test-tool/0241_prefetch10_flags.c b/test-tool/0241_prefetch10_flags.c index 4cb4770..0b86092 100644 --- a/test-tool/0241_prefetch10_flags.c +++ b/test-tool/0241_prefetch10_flags.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -21,12 +21,11 @@ #include "iscsi-test.h" int T0241_prefetch10_flags(const char *initiator, const char *url, int data_loss _U_, int show_info) -{ +{ struct iscsi_context *iscsi; struct scsi_task *task; struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint64_t num_blocks; printf("0241_prefetch10_flags:\n"); printf("===================\n"); @@ -64,7 +63,7 @@ int T0241_prefetch10_flags(const char *initiator, const char *url, int data_loss scsi_free_scsi_task(task); goto finished; } - num_blocks = rc16->returned_lba; + scsi_free_scsi_task(task); ret = 0; From 6819637ddc39fd68d159706ebea961c7d92de6da Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Wed, 31 Oct 2012 15:59:42 +0100 Subject: [PATCH 11/29] T0401_inquiry_alloclen: fix compiler warnings Remove unused variables and mark unused parameter as such. Signed-off-by: Arne Redlich --- test-tool/0401_inquiry_alloclen.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test-tool/0401_inquiry_alloclen.c b/test-tool/0401_inquiry_alloclen.c index 7fed080..b38f215 100644 --- a/test-tool/0401_inquiry_alloclen.c +++ b/test-tool/0401_inquiry_alloclen.c @@ -22,13 +22,12 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0401_inquiry_alloclen(const char *initiator, const char *url, int data_loss, int show_info) +int T0401_inquiry_alloclen(const char *initiator, const char *url, int data_loss _U_, + int show_info) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_inquiry_standard *inq; int ret, lun, i; - int full_size; printf("0401_inquiry_alloclen:\n"); printf("===================\n"); From ea20edb513a9fcbb63e2364b67e9be0adfb54f1c Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Wed, 31 Oct 2012 16:06:25 +0100 Subject: [PATCH 12/29] T0402_inquiry_evpd: fix compiler warnings Remove unused label and mark unused parameter as such. Signed-off-by: Arne Redlich --- test-tool/0402_inquiry_evpd.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/test-tool/0402_inquiry_evpd.c b/test-tool/0402_inquiry_evpd.c index 6db9370..d33cbf5 100644 --- a/test-tool/0402_inquiry_evpd.c +++ b/test-tool/0402_inquiry_evpd.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -22,8 +22,9 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0402_inquiry_evpd(const char *initiator, const char *url, int data_loss, int show_info) -{ +int T0402_inquiry_evpd(const char *initiator, const char *url, int data_loss _U_, + int show_info) +{ struct iscsi_context *iscsi; struct scsi_task *task; int ret, lun, i; @@ -55,14 +56,14 @@ int T0402_inquiry_evpd(const char *initiator, const char *url, int data_loss, in printf("[FAILED]\n"); printf("Failed to send INQUIRY command : %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test2; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("INQUIRY should have failed with CHECK_CONDITION/ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB %s\n", iscsi_get_error(iscsi)); scsi_free_scsi_task(task); ret = -1; - goto test2; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -71,15 +72,12 @@ int T0402_inquiry_evpd(const char *initiator, const char *url, int data_loss, in printf("INQUIRY should have failed with wrong sense code. It failed with %s but should have failed with ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB\n", iscsi_get_error(iscsi)); scsi_free_scsi_task(task); ret = -1; - goto test2; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test2: - - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); From c195348e4d3f654736ad38fb08f9982a5d04fadb Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Wed, 31 Oct 2012 16:12:21 +0100 Subject: [PATCH 13/29] T0403_inquiry_supported_vpd: fix compiler warnings Remove unused labels and mark unused parameter as such. Signed-off-by: Arne Redlich --- test-tool/0403_inquiry_supported_vpd.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/test-tool/0403_inquiry_supported_vpd.c b/test-tool/0403_inquiry_supported_vpd.c index f28e7da..42eddfb 100644 --- a/test-tool/0403_inquiry_supported_vpd.c +++ b/test-tool/0403_inquiry_supported_vpd.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -22,8 +22,9 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0403_inquiry_supported_vpd(const char *initiator, const char *url, int data_loss, int show_info) -{ +int T0403_inquiry_supported_vpd(const char *initiator, const char *url, + int data_loss _U_, int show_info) +{ struct iscsi_context *iscsi; struct scsi_task *task; struct scsi_inquiry_supported_pages *inq; @@ -51,11 +52,8 @@ int T0403_inquiry_supported_vpd(const char *initiator, const char *url, int data return -1; } - ret = 0; - - printf("Read SUPPORTED VPD data ... "); /* See how big this inquiry data is */ page_code = SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES; @@ -95,7 +93,6 @@ int T0403_inquiry_supported_vpd(const char *initiator, const char *url, int data } printf("[OK]\n"); -test2: printf("Verify we have all mandatory SPC VPD pages:\n"); for (i = 0; i < sizeof(required_spc_pages) / sizeof(enum scsi_inquiry_pagecode); i++) { printf("Verify the target supports page 0x%02x ... ", required_spc_pages[i]); @@ -113,8 +110,6 @@ test2: } } - -test3: scsi_free_scsi_task(task); finished: From 13c253f0dced9153cb25c6d7b2cc9ff0302e3e88 Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Wed, 31 Oct 2012 16:20:55 +0100 Subject: [PATCH 14/29] T0404_inquiry_all_reported_vpd: fix compiler warnings * mark unused parameter as such * wrap parens around a bitop * remove unused labels * fix error messages Signed-off-by: Arne Redlich --- test-tool/0404_inquiry_all_reported_vpd.c | 27 ++++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/test-tool/0404_inquiry_all_reported_vpd.c b/test-tool/0404_inquiry_all_reported_vpd.c index 5397315..f37d6db 100644 --- a/test-tool/0404_inquiry_all_reported_vpd.c +++ b/test-tool/0404_inquiry_all_reported_vpd.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -22,8 +22,9 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0404_inquiry_all_reported_vpd(const char *initiator, const char *url, int data_loss, int show_info) -{ +int T0404_inquiry_all_reported_vpd(const char *initiator, const char *url, + int data_loss _U_, int show_info) +{ struct iscsi_context *iscsi; struct scsi_task *task; struct scsi_inquiry_supported_pages *inq; @@ -91,7 +92,6 @@ int T0404_inquiry_all_reported_vpd(const char *initiator, const char *url, int d } printf("[OK]\n"); -test2: printf("Read each page and verify qualifier, type and page code:\n"); for (i = 0; i < inq->num_pages; i++) { struct scsi_task *pc_task; @@ -116,7 +116,8 @@ test2: printf("Verify page 0x%02x qualifier ... ", inq->pages[i]); if ((pc_task->datain.data[0] & 0xe0) >> 5 != inq->qualifier) { printf("[FAILED]\n"); - printf("Qualifier differs between VPD pages\n", iscsi_get_error(iscsi)); + printf("Qualifier differs between VPD pages: %x != %x\n", + pc_task->datain.data[0] & 0xe0, inq->qualifier); ret = -1; scsi_free_scsi_task(pc_task); continue; @@ -125,9 +126,10 @@ test2: } printf("Verify page 0x%02x device type ... ", inq->pages[i]); - if (pc_task->datain.data[0] & 0x1f != inq->device_type) { + if ((pc_task->datain.data[0] & 0x1f) != inq->device_type) { printf("[FAILED]\n"); - printf("Device Type differs between VPD pages\n", iscsi_get_error(iscsi)); + printf("Device Type differs between VPD pages: %x != %x\n", + pc_task->datain.data[0] & 0x1f, inq->device_type); ret = -1; scsi_free_scsi_task(pc_task); continue; @@ -138,7 +140,8 @@ test2: printf("Verify page 0x%02x page code ... ", inq->pages[i]); if (pc_task->datain.data[1] != inq->pages[i]) { printf("[FAILED]\n"); - printf("Page code is wrong\n", iscsi_get_error(iscsi)); + printf("Page code is wrong: %x != %x\n", + pc_task->datain.data[1], inq->pages[i]); ret = -1; scsi_free_scsi_task(pc_task); continue; @@ -149,8 +152,6 @@ test2: scsi_free_scsi_task(pc_task); } - -test3: scsi_free_scsi_task(task); finished: From 88341c0a732a06adeadcabbeaede6726b5ca8098 Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Wed, 31 Oct 2012 16:25:47 +0100 Subject: [PATCH 15/29] T0410_readtoc_basic: fix compiler warnings Remove unused labels and mark unused parameter as such. Signed-off-by: Arne Redlich --- test-tool/0410_readtoc_basic.c | 36 +++++++++++++--------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/test-tool/0410_readtoc_basic.c b/test-tool/0410_readtoc_basic.c index e7bb4d4..2f84452 100644 --- a/test-tool/0410_readtoc_basic.c +++ b/test-tool/0410_readtoc_basic.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Jon Grimm - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -22,8 +22,9 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0410_readtoc_basic(const char *initiator, const char *url, int data_loss, int show_info) -{ +int T0410_readtoc_basic(const char *initiator, const char *url, int data_loss _U_, + int show_info) +{ struct iscsi_context *iscsi; struct scsi_task *task, *task1; struct scsi_inquiry_standard *inq; @@ -132,13 +133,13 @@ int T0410_readtoc_basic(const char *initiator, const char *url, int data_loss, i scsi_free_scsi_task(task); goto finished; } - /* LBA will return 0, if the medium is blank. */ + /* LBA will return 0, if the medium is blank. */ is_blank = rc10->lba ? 0 : 1; } /* If we get 'medium not present' there is no medium in the drive */ if (task->status == SCSI_STATUS_CHECK_CONDITION - && task->sense.key == SCSI_SENSE_NOT_READY - && (task->sense.ascq == SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT + && task->sense.key == SCSI_SENSE_NOT_READY + && (task->sense.ascq == SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT || task->sense.ascq == SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_OPEN || task->sense.ascq == SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { no_medium = 1; @@ -189,9 +190,9 @@ test1: } if (task->status != SCSI_STATUS_CHECK_CONDITION - || task->sense.key != SCSI_SENSE_NOT_READY + || task->sense.key != SCSI_SENSE_NOT_READY || (task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_OPEN - && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { + && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { printf("[FAILED]\n"); printf("READTOC failed but ascq was wrong. Should " "have failed with MEDIUM_NOT_PRESENT. " @@ -216,8 +217,8 @@ test1: printf("READTOC Should have failed\n"); ret = -1; } else if (task->status != SCSI_STATUS_CHECK_CONDITION - || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST - || task->sense.ascq != SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { + || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST + || task->sense.ascq != SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { printf("[FAILED]\n"); printf("READTOC failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/INVALID OPERATION_CODE. Sense:%s\n", iscsi_get_error(iscsi)); ret = -1; @@ -229,7 +230,6 @@ test1: goto finished; } - if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READTOC command failed : %s\n", iscsi_get_error(iscsi)); @@ -239,9 +239,6 @@ test1: } printf("[OK]\n"); - - -test2: /* If we get here, there is a disk loaded and it contains data */ printf("Verify we got at least 4 bytes of data for track 0 ... "); full_size = scsi_datain_getfullsize(task); @@ -262,8 +259,6 @@ test2: } printf("[OK]\n"); - -test3: printf("Verify we can READTOC format 0000b (TOC) track 1 ... "); task1 = iscsi_readtoc_sync(iscsi, lun, 0, 1, 0, 255); if (task1 == NULL) { @@ -284,8 +279,6 @@ test3: } printf("[OK]\n"); - -test4: printf("Verify we got at least 4 bytes of data for track 1 ... "); full_size = scsi_datain_getfullsize(task1); if (full_size < 4) { @@ -307,7 +300,6 @@ test4: } printf("[OK]\n"); -test5: printf("Verify track 0 and 1 both returned the same data ... "); if (list->num != list1->num || list->first != list1->first || From d402a337e347401680ffedb66660e9222688ed51 Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Wed, 31 Oct 2012 16:32:12 +0100 Subject: [PATCH 16/29] T0420_reserve6_simple: fix compiler warnings Mark unused parameter as such and remove unused labels. Signed-off-by: Arne Redlich --- test-tool/0420_reserve6_simple.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/test-tool/0420_reserve6_simple.c b/test-tool/0420_reserve6_simple.c index 4ca6ee6..e6f2300 100644 --- a/test-tool/0420_reserve6_simple.c +++ b/test-tool/0420_reserve6_simple.c @@ -22,7 +22,8 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss, int show_info) +int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss _U_, + int show_info) { struct iscsi_context *iscsi, *iscsi2; struct scsi_task *task; @@ -108,8 +109,6 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss, scsi_free_scsi_task(task); printf("[OK]\n"); - -test2: printf("Test that reservation works.\n"); printf("Send RESERVE6 from Initiator 1. ... "); task = iscsi_reserve6_sync(iscsi, lun); @@ -148,7 +147,6 @@ test2: scsi_free_scsi_task(task); printf("[OK]\n"); -test3: printf("Send RESERVE6 from Initiator 2. Expect conflict. ... "); task = iscsi_reserve6_sync(iscsi2, lun); if (task == NULL) { @@ -168,7 +166,6 @@ test3: scsi_free_scsi_task(task); printf("[OK]\n"); -test3a: printf("Send RELEASE6 from Initiator 2..Expect NO-OP. ... "); task = iscsi_release6_sync(iscsi2, lun); if (task == NULL) { @@ -211,7 +208,6 @@ test4: scsi_free_scsi_task(task); printf("[OK]\n"); -test5: printf("Send TESTUNITREADY from Initiator 2. Expect conflict. ... "); task = iscsi_testunitready_sync(iscsi2, lun); if (task == NULL) { @@ -230,7 +226,6 @@ test5: scsi_free_scsi_task(task); printf("[OK]\n"); -test6: printf("Test that release actually works\n"); printf("Send RELEASE6 from Initiator 1 ... "); task = iscsi_release6_sync(iscsi, lun); From ab411e4401ee3879f9f7575cfa36f513b649ffd8 Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Wed, 31 Oct 2012 16:34:11 +0100 Subject: [PATCH 17/29] T0423_reserve6_sessionloss: fix compiler warnings Remove unused labels and mark unused parameters as such. Signed-off-by: Arne Redlich --- test-tool/0423_reserve6_sessionloss.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test-tool/0423_reserve6_sessionloss.c b/test-tool/0423_reserve6_sessionloss.c index 9d10e28..c2683c5 100644 --- a/test-tool/0423_reserve6_sessionloss.c +++ b/test-tool/0423_reserve6_sessionloss.c @@ -22,7 +22,8 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0423_reserve6_sessionloss(const char *initiator, const char *url, int data_loss, int show_info) +int T0423_reserve6_sessionloss(const char *initiator, const char *url, + int data_loss _U_, int show_info) { struct iscsi_context *iscsi, *iscsi2; struct scsi_task *task; @@ -131,12 +132,10 @@ test3: scsi_free_scsi_task(task); printf("[OK]\n"); -test4: printf("Drop the session to the first initiator ... "); iscsi_destroy_context(iscsi); printf("[OK]\n"); -test5: printf("Verify we can access the LUN from the second initiator ... "); task = iscsi_testunitready_sync(iscsi2, lun); if (task == NULL) { From ea560255a67811db02bb89f651b35768560c0b81 Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Wed, 31 Oct 2012 16:40:29 +0100 Subject: [PATCH 18/29] T0424_reserve6_target_reset: fix compiler warnings Remove unused labels and mark unused parameter as such. Signed-off-by: Arne Redlich --- test-tool/0424_reserve6_target_reset.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/test-tool/0424_reserve6_target_reset.c b/test-tool/0424_reserve6_target_reset.c index 2507737..ac62ab2 100644 --- a/test-tool/0424_reserve6_target_reset.c +++ b/test-tool/0424_reserve6_target_reset.c @@ -37,7 +37,8 @@ static void mgmt_cb(struct iscsi_context *iscsi _U_, int status _U_, mgmt_task->finished = 1; } -int T0424_reserve6_target_reset(const char *initiator, const char *url, int data_loss, int show_info) +int T0424_reserve6_target_reset(const char *initiator, const char *url, + int data_loss _U_, int show_info) { struct iscsi_context *iscsi, *iscsi2; struct scsi_task *task; @@ -73,9 +74,6 @@ int T0424_reserve6_target_reset(const char *initiator, const char *url, int data ret = 0; - - - printf("Send RESERVE6 from the first initiator ... "); task = iscsi_reserve6_sync(iscsi, lun); if (task == NULL) { @@ -105,7 +103,6 @@ int T0424_reserve6_target_reset(const char *initiator, const char *url, int data scsi_free_scsi_task(task); printf("[OK]\n"); - test2: printf("Verify we can access the LUN from the first initiator ... "); task = iscsi_testunitready_sync(iscsi, lun); @@ -148,7 +145,6 @@ test3: scsi_free_scsi_task(task); printf("[OK]\n"); -test4: printf("Send a Target Cold-Reset ... "); iscsi_task_mgmt_target_cold_reset_async(iscsi, mgmt_cb, &mgmt_task); while (mgmt_task.finished == 0) { From e0555555bb59b0cb38fffa19876c9e15286d0890 Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Wed, 31 Oct 2012 16:46:01 +0100 Subject: [PATCH 19/29] T0430_report_all_supported_ops: fix compiler warnings * remove unused label * mark unused parameter * fix signedness warnings Signed-off-by: Arne Redlich --- test-tool/0430_report_all_supported_ops.c | 38 +++++++++++------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/test-tool/0430_report_all_supported_ops.c b/test-tool/0430_report_all_supported_ops.c index 2ba1340..19cd61a 100644 --- a/test-tool/0430_report_all_supported_ops.c +++ b/test-tool/0430_report_all_supported_ops.c @@ -1,17 +1,17 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg Copyright (C) 2012 by Jon Grimm - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -23,14 +23,16 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0430_report_all_supported_ops(const char *initiator, const char *url, int data_loss, int show_info) -{ +int T0430_report_all_supported_ops(const char *initiator, const char *url, + int data_loss _U_, int show_info) +{ struct iscsi_context *iscsi; struct scsi_task *task; struct scsi_report_supported_op_codes *rsoc; struct scsi_command_descriptor *desc; - int ret, lun, i; + int ret, lun; int full_size, desc_size; + unsigned i; printf("0430_report_all_supported_ops:\n"); printf("===================\n"); @@ -55,7 +57,7 @@ int T0430_report_all_supported_ops(const char *initiator, const char *url, int d task = iscsi_report_supported_opcodes_sync(iscsi, lun, 0, 4); if (task == NULL) { printf("[FAILED]\n"); - printf("Failed to send Report Supported Opcodes command : %s\n", + printf("Failed to send Report Supported Opcodes command : %s\n", iscsi_get_error(iscsi)); ret = -1; goto finished; @@ -64,7 +66,7 @@ int T0430_report_all_supported_ops(const char *initiator, const char *url, int d && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { printf("[SKIPPED]\n"); - printf("REPORT SUPPORTED OPCODES command failed : %s\n", + printf("REPORT SUPPORTED OPCODES command failed : %s\n", iscsi_get_error(iscsi)); scsi_free_scsi_task(task); ret = -2; @@ -72,7 +74,7 @@ int T0430_report_all_supported_ops(const char *initiator, const char *url, int d } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); - printf("REPORT SUPPORTED OPCODES command failed : %s\n", + printf("REPORT SUPPORTED OPCODES command failed : %s\n", iscsi_get_error(iscsi)); scsi_free_scsi_task(task); ret = -1; @@ -101,7 +103,7 @@ int T0430_report_all_supported_ops(const char *initiator, const char *url, int d printf("Supported Commands: %d\n", rsoc->num_descriptors); printf("=======================\n"); - for (i=0; i < rsoc->num_descriptors; i++) { + for (i = 0; i < rsoc->num_descriptors; i++) { printf("op:%x\tsa:%x\tcdb length:%d\n", rsoc->descriptors[i].op_code, rsoc->descriptors[i].service_action, @@ -111,25 +113,23 @@ int T0430_report_all_supported_ops(const char *initiator, const char *url, int d printf("\n[OK]\n"); scsi_free_scsi_task(task); - -test2: /*Report All Supported Operations including timeout info.*/ printf("See if Report Supported Opcodes with Timeouts is supported... "); /* See how big data is */ task = iscsi_report_supported_opcodes_sync(iscsi, lun, 1, 4); if (task == NULL) { printf("[FAILED]\n"); - printf("Failed to send Report Supported Opcodes command : %s\n", + printf("Failed to send Report Supported Opcodes command : %s\n", iscsi_get_error(iscsi)); ret = -1; goto finished; } if (task->status == SCSI_STATUS_CHECK_CONDITION && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST - && (task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE + && (task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE || task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB)) { printf("[SKIPPED]\n"); - printf("REPORT SUPPORTED OPCODES command failed : %s\n", + printf("REPORT SUPPORTED OPCODES command failed : %s\n", iscsi_get_error(iscsi)); scsi_free_scsi_task(task); ret = -2; @@ -137,7 +137,7 @@ test2: } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); - printf("REPORT SUPPORTED OPCODES command failed : %s\n", + printf("REPORT SUPPORTED OPCODES command failed : %s\n", iscsi_get_error(iscsi)); scsi_free_scsi_task(task); ret = -1; @@ -170,7 +170,7 @@ test2: desc_size = sizeof (struct scsi_command_descriptor) + sizeof (struct scsi_op_timeout_descriptor); desc = &rsoc->descriptors[0]; - for (i=0; i < rsoc->num_descriptors; i++) { + for (i = 0; i < rsoc->num_descriptors; i++) { printf("op:%x\tsa:%x\tcdb_length:%d\ttimeout info: length:%d\tcommand specific:%x\tnominal processing%d\trecommended%d\n", desc->op_code, desc->service_action, @@ -179,7 +179,7 @@ test2: desc->to[0].command_specific, desc->to[0].nominal_processing_timeout, desc->to[0].recommended_timeout); - desc = (struct scsi_command_descriptor *)((char *)desc + + desc = (struct scsi_command_descriptor *)((char *)desc + desc_size); } From 17e8b54759d0bfa684eb035dda8e0f356226bcff Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Wed, 31 Oct 2012 16:48:48 +0100 Subject: [PATCH 20/29] T1030_unsolicited_data_overflow: remove unused variable old_first_burst_len is set but never used - remove it. Also replace an if (!ptr) free(ptr) with free(ptr) as the check is redundant. Signed-off-by: Arne Redlich --- test-tool/1030_unsolicited_data_overflow.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/test-tool/1030_unsolicited_data_overflow.c b/test-tool/1030_unsolicited_data_overflow.c index b5dd350..03d346c 100644 --- a/test-tool/1030_unsolicited_data_overflow.c +++ b/test-tool/1030_unsolicited_data_overflow.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -40,14 +40,13 @@ static void test_cb(struct iscsi_context *iscsi _U_, int status, } int T1030_unsolicited_data_overflow(const char *initiator, const char *url, int data_loss, int show_info) -{ +{ struct iscsi_context *iscsi, *iscsi2; struct scsi_task *task; struct scsi_readcapacity16 *rc16; int ret, lun; unsigned char *buf = NULL; struct iscsi_async_state test_state; - uint32_t old_first_burst_len; printf("1030_unsolicited_data_overflow:\n"); printf("===============================\n"); @@ -99,7 +98,7 @@ int T1030_unsolicited_data_overflow(const char *initiator, const char *url, int ret = 0; iscsi->use_immediate_data = ISCSI_IMMEDIATE_DATA_YES; - old_first_burst_len = iscsi->first_burst_length; + /* make first burst REAL big */ iscsi->first_burst_length *= 16; buf = malloc(iscsi->first_burst_length); @@ -141,9 +140,8 @@ test2: printf("[OK]\n"); finished: - if (buf) { - free(buf); - } + + free(buf); iscsi_destroy_context(iscsi); iscsi_destroy_context(iscsi2); return ret; From af33ca36ff33a84427ac40c6614319f44e93cb4d Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Wed, 31 Oct 2012 16:50:38 +0100 Subject: [PATCH 21/29] T1031_unsolicited_data_out: mark unused parameters as such Signed-off-by: Arne Redlich --- test-tool/1031_unsolicited_data_out.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/test-tool/1031_unsolicited_data_out.c b/test-tool/1031_unsolicited_data_out.c index 1ba1b81..e8a787b 100644 --- a/test-tool/1031_unsolicited_data_out.c +++ b/test-tool/1031_unsolicited_data_out.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -27,7 +27,7 @@ uint32_t block_size; static int -my_iscsi_add_data(struct iscsi_context *iscsi, struct iscsi_data *data, +my_iscsi_add_data(struct iscsi_context *iscsi _U_, struct iscsi_data *data, unsigned char *dptr, int dsize, int pdualignment) { int len, aligned; @@ -149,8 +149,9 @@ my_iscsi_allocate_pdu_with_itt_flags(struct iscsi_context *iscsi, enum iscsi_opc return pdu; } -int T1031_unsolicited_data_out(const char *initiator, const char *url, int data_loss, int show_info) -{ +int T1031_unsolicited_data_out(const char *initiator, const char *url, + int data_loss _U_, int show_info) +{ struct iscsi_context *iscsi, *iscsi2; struct scsi_task *task; struct scsi_readcapacity16 *rc16; From 578bdae3afa1ddcb437e7916b39da0a582fcc897 Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Wed, 31 Oct 2012 16:53:26 +0100 Subject: [PATCH 22/29] T0421_reserve6_lun_reset: fix compiler warnings Remove unused label and mark unused parameter as such. Signed-off-by: Arne Redlich --- test-tool/0421_reserve6_lun_reset.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test-tool/0421_reserve6_lun_reset.c b/test-tool/0421_reserve6_lun_reset.c index 8fa91f6..69321ee 100644 --- a/test-tool/0421_reserve6_lun_reset.c +++ b/test-tool/0421_reserve6_lun_reset.c @@ -37,7 +37,8 @@ static void mgmt_cb(struct iscsi_context *iscsi _U_, int status _U_, mgmt_task->finished = 1; } -int T0421_reserve6_lun_reset(const char *initiator, const char *url, int data_loss, int show_info) +int T0421_reserve6_lun_reset(const char *initiator, const char *url, + int data_loss _U_, int show_info) { struct iscsi_context *iscsi, *iscsi2; struct scsi_task *task; @@ -148,7 +149,6 @@ test3: scsi_free_scsi_task(task); printf("[OK]\n"); -test4: printf("Send a LUN Reset to the target ... "); iscsi_task_mgmt_lun_reset_async(iscsi, lun, mgmt_cb, &mgmt_task); while (mgmt_task.finished == 0) { From b5372272b1138831d5551b33357480f71a3c600e Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Wed, 31 Oct 2012 16:54:29 +0100 Subject: [PATCH 23/29] T0422_reserve6_logout: fix compiler warnings Remove unused labels and mark unused parameter as such. Signed-off-by: Arne Redlich --- test-tool/0422_reserve6_logout.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test-tool/0422_reserve6_logout.c b/test-tool/0422_reserve6_logout.c index 3daf666..102ccd4 100644 --- a/test-tool/0422_reserve6_logout.c +++ b/test-tool/0422_reserve6_logout.c @@ -22,7 +22,8 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0422_reserve6_logout(const char *initiator, const char *url, int data_loss, int show_info) +int T0422_reserve6_logout(const char *initiator, const char *url, int data_loss _U_, + int show_info) { struct iscsi_context *iscsi, *iscsi2; struct scsi_task *task; @@ -131,13 +132,11 @@ test3: scsi_free_scsi_task(task); printf("[OK]\n"); -test4: printf("Logout the first initiator ... "); iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); printf("[OK]\n"); -test5: printf("Verify we can access the LUN from the second initiator ... "); task = iscsi_testunitready_sync(iscsi2, lun); if (task == NULL) { From 5cd48f87ffca09a22a6a2ab4a6746c3c1b85b0f1 Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Wed, 31 Oct 2012 17:00:46 +0100 Subject: [PATCH 24/29] T0403_inquiry_supported_vpd: fix signed/unsigned comparison warning Signed-off-by: Arne Redlich --- test-tool/0403_inquiry_supported_vpd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test-tool/0403_inquiry_supported_vpd.c b/test-tool/0403_inquiry_supported_vpd.c index 42eddfb..1660c14 100644 --- a/test-tool/0403_inquiry_supported_vpd.c +++ b/test-tool/0403_inquiry_supported_vpd.c @@ -28,7 +28,8 @@ int T0403_inquiry_supported_vpd(const char *initiator, const char *url, struct iscsi_context *iscsi; struct scsi_task *task; struct scsi_inquiry_supported_pages *inq; - int ret, lun, i, j; + size_t i; + int ret, lun, j; int full_size; int page_code; enum scsi_inquiry_pagecode required_spc_pages[] = { From 081ae59cdf58bc57e699110333bb65aecce0890a Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Wed, 31 Oct 2012 17:05:47 +0100 Subject: [PATCH 25/29] T0105_read10_invalid: suppress signed/unsigned comparison warnings Signed-off-by: Arne Redlich --- test-tool/0105_read10_invalid.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/test-tool/0105_read10_invalid.c b/test-tool/0105_read10_invalid.c index 96724ec..4913892 100644 --- a/test-tool/0105_read10_invalid.c +++ b/test-tool/0105_read10_invalid.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2010 by Ronnie Sahlberg - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -24,7 +24,7 @@ #include "iscsi-test.h" int T0105_read10_invalid(const char *initiator, const char *url, int data_loss _U_, int show_info) -{ +{ struct iscsi_context *iscsi; struct scsi_task *task; struct iscsi_data data; @@ -120,7 +120,8 @@ int T0105_read10_invalid(const char *initiator, const char *url, int data_loss _ scsi_free_scsi_task(task); goto test2; } - if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != block_size) { + if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || + task->residual != (int64_t)block_size) { printf("[FAILED]\n"); printf("Read10 returned incorrect residual overflow.\n"); ret = -1; @@ -166,7 +167,8 @@ test2: scsi_free_scsi_task(task); goto test3; } - if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW || task->residual != block_size) { + if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW || + task->residual != (int64_t)block_size) { printf("[FAILED]\n"); printf("Read10 returned incorrect residual underflow.\n"); ret = -1; @@ -209,7 +211,8 @@ test3: scsi_free_scsi_task(task); goto test4; } - if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != block_size - 200) { + if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || + task->residual != (int64_t)(block_size - 200)) { printf("[FAILED]\n"); printf("Read10 returned incorrect residual overflow.\n"); ret = -1; @@ -251,7 +254,8 @@ test4: scsi_free_scsi_task(task); goto test5; } - if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != block_size) { + if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || + task->residual != (int64_t)block_size) { printf("[FAILED]\n"); printf("Read10 returned incorrect residual overflow.\n"); ret = -1; From 0bf9b6389c3c1b3e39188c99b80d7fd118dc5feb Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Fri, 2 Nov 2012 21:11:30 +0100 Subject: [PATCH 26/29] Annotate iscsi_set_error with printf format attribute Signed-off-by: Arne Redlich --- include/iscsi-private.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/iscsi-private.h b/include/iscsi-private.h index 5c9b15a..5f71613 100644 --- a/include/iscsi-private.h +++ b/include/iscsi-private.h @@ -86,7 +86,7 @@ struct iscsi_context { int fd; int is_connected; - + int tcp_user_timeout; int tcp_keepcnt; int tcp_keepintvl; @@ -272,7 +272,7 @@ int iscsi_process_reject(struct iscsi_context *iscsi, int iscsi_send_target_nop_out(struct iscsi_context *iscsi, uint32_t ttt); void iscsi_set_error(struct iscsi_context *iscsi, const char *error_string, - ...); + ...) __attribute__((format(printf, 2, 3))); unsigned char *iscsi_get_user_in_buffer(struct iscsi_context *iscsi, struct iscsi_in_pdu *in, uint32_t pos, ssize_t *count); unsigned char *scsi_task_get_data_in_buffer(struct scsi_task *task, uint32_t pos, ssize_t *count); @@ -289,4 +289,3 @@ void iscsi_set_noautoreconnect(struct iscsi_context *iscsi, int state); #endif #endif /* __iscsi_private_h__ */ - From d2e68d7a25275f2ca7e0bba35a27b987f80ee6e5 Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Fri, 2 Nov 2012 21:16:45 +0100 Subject: [PATCH 27/29] T0122_read6_invalid: suppress signed/unsigned comparison warnings Signed-off-by: Arne Redlich --- test-tool/0122_read6_invalid.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test-tool/0122_read6_invalid.c b/test-tool/0122_read6_invalid.c index ae548b2..f0ebc1c 100644 --- a/test-tool/0122_read6_invalid.c +++ b/test-tool/0122_read6_invalid.c @@ -119,7 +119,8 @@ int T0122_read6_invalid(const char *initiator, const char *url, int data_loss _U scsi_free_scsi_task(task); goto test2; } - if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != block_size) { + if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || + task->residual != (ssize_t)block_size) { printf("[FAILED]\n"); printf("Read6 returned incorrect residual overflow.\n"); ret = -1; @@ -165,7 +166,8 @@ test2: scsi_free_scsi_task(task); goto test3; } - if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW || task->residual != block_size) { + if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW || + task->residual != (ssize_t)block_size) { printf("[FAILED]\n"); printf("Read6 returned incorrect residual underflow.\n"); ret = -1; @@ -208,7 +210,8 @@ test3: scsi_free_scsi_task(task); goto test4; } - if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != block_size - 200) { + if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || + task->residual != (ssize_t)block_size - 200) { printf("[FAILED]\n"); printf("Read6 returned incorrect residual overflow.\n"); ret = -1; @@ -250,7 +253,8 @@ test4: scsi_free_scsi_task(task); goto test5; } - if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != block_size) { + if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || + task->residual != (ssize_t)block_size) { printf("[FAILED]\n"); printf("Read6 returned incorrect residual overflow.\n"); ret = -1; From 13b1f49fe5fd8fcb52e8adaa4363722aabc9e1a1 Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Fri, 2 Nov 2012 21:23:47 +0100 Subject: [PATCH 28/29] T1031_unsolicited_data_out: fix uninitialised variable warning Signed-off-by: Arne Redlich --- test-tool/1031_unsolicited_data_out.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test-tool/1031_unsolicited_data_out.c b/test-tool/1031_unsolicited_data_out.c index e8a787b..7c823ae 100644 --- a/test-tool/1031_unsolicited_data_out.c +++ b/test-tool/1031_unsolicited_data_out.c @@ -152,7 +152,8 @@ my_iscsi_allocate_pdu_with_itt_flags(struct iscsi_context *iscsi, enum iscsi_opc int T1031_unsolicited_data_out(const char *initiator, const char *url, int data_loss _U_, int show_info) { - struct iscsi_context *iscsi, *iscsi2; + struct iscsi_context *iscsi = NULL; + struct iscsi_context *iscsi2 = NULL; struct scsi_task *task; struct scsi_readcapacity16 *rc16; int i, ret, lun; From f618d0835002db64cd574671c0a9218c358b5a4e Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Fri, 2 Nov 2012 21:28:40 +0100 Subject: [PATCH 29/29] T1030_unsolicited_data_overflow: fix uninitialized variable warning Signed-off-by: Arne Redlich --- test-tool/1030_unsolicited_data_overflow.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test-tool/1030_unsolicited_data_overflow.c b/test-tool/1030_unsolicited_data_overflow.c index 03d346c..3a2b581 100644 --- a/test-tool/1030_unsolicited_data_overflow.c +++ b/test-tool/1030_unsolicited_data_overflow.c @@ -41,7 +41,8 @@ static void test_cb(struct iscsi_context *iscsi _U_, int status, int T1030_unsolicited_data_overflow(const char *initiator, const char *url, int data_loss, int show_info) { - struct iscsi_context *iscsi, *iscsi2; + struct iscsi_context *iscsi = NULL; + struct iscsi_context *iscsi2 = NULL; struct scsi_task *task; struct scsi_readcapacity16 *rc16; int ret, lun; @@ -140,7 +141,6 @@ test2: printf("[OK]\n"); finished: - free(buf); iscsi_destroy_context(iscsi); iscsi_destroy_context(iscsi2);