TESTS: Fix READ6 test

Commit 45a3752d163a2348918690084405293c62f5eebb skips all tests from
read-at-eol onwards when the LUN is large. Fix this by only skipping the
read-at-eol tests in this scenario.

Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
Fix incorrect second initiator

Use the second initiator name in all files found by
ack "iscsic2 = "
Merge pull request #80 from sitsofe/initiator2

Fix incorrect second initiator
Add more status codes : CONDITIONS_MET/TASK_SET_FULL/ACA_ACTIVE/TASK_ABORTED
Reconnect: recalculate the header digest when we re-queue after a reconnect
Port to CUnit version 2

Linux distributions like openSUSE 12.3 include CUnit version 2.
Apparently libiscsi uses some CUnit version 1 data structures that
have been modified in CUnit version 2. This causes the libiscsi
build to fail against CUnit version 2. Fix this by detecting the
CUnit version during the configure step.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
iscsi_reconnect: Fix a use-after-free

This patch fixes the following Valgrind complaint:

Invalid read of size 4
   at 0x524A858: iscsi_reconnect (connect.c:378)
   by 0x5258794: iscsi_service (socket.c:707)
   by 0x52599C4: event_loop (sync.c:67)
   by 0x525AFD7: iscsi_reserve6_sync (sync.c:1096)
   by 0x40A40A: reserve6 (iscsi-support.c:3291)
   by 0x422C95: test_reserve6_target_warm_reset (test_reserve6_target_warm_reset.c:39)
   by 0x503B05F: ??? (in /usr/lib/libcunit.so.1.0.1)
   by 0x503B375: ??? (in /usr/lib/libcunit.so.1.0.1)
   by 0x503B69F: CU_run_all_tests (in /usr/lib/libcunit.so.1.0.1)
   by 0x403171: main (iscsi-test-cu.c:1258)
 Address 0x6443958 is 3,032 bytes inside a block of size 4,120 free'd
   at 0x4C2B83A: free (vg_replace_malloc.c:468)
   by 0x524A846: iscsi_reconnect (connect.c:374)
   by 0x5258794: iscsi_service (socket.c:707)
   by 0x52599C4: event_loop (sync.c:67)
   by 0x525AFD7: iscsi_reserve6_sync (sync.c:1096)
   by 0x40A40A: reserve6 (iscsi-support.c:3291)
   by 0x422C95: test_reserve6_target_warm_reset (test_reserve6_target_warm_reset.c:39)
   by 0x503B05F: ??? (in /usr/lib/libcunit.so.1.0.1)
   by 0x503B375: ??? (in /usr/lib/libcunit.so.1.0.1)
   by 0x503B69F: CU_run_all_tests (in /usr/lib/libcunit.so.1.0.1)
   by 0x403171: main (iscsi-test-cu.c:1258)

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
test_read6_simple: Avoid triggering a use-after-free

Do not use the 'task' pointer after the memory it points at has been freed.
Detected via valgrind.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
test_writesame16_unmap: Do not leak memory if WRITESAME16 is not supported

Detected by Valgrind.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Don't use variadic macros of the form args...  This is a GCC extension and is not portable.
Always declare variables at the start of a new scope.
Portability fixes. Declare variables at the start of a scope only.
Remove 'inline'. Some compilers do not support it.
Fix win32 so it works again
We don't have __attribute__ on visual studio
Add PowerOnOccured as a sense code we allow and ignore during connect
Get rid of a lot of WIN32 ifdefs by providing a compatibility function instead
typo
We dont need _snprintf_s since we have a compatibility function for windows
Fix segv.