The variable user in struct iscsi_url is a character array, not a pointer.
Therefore its address will never be NULL.
When libscsi is built using clang instead of gcc, those errors are reported:
iscsi-perf.c:256:17: error:
comparison of array 'iscsi_url->user' not equal to a null
pointer is always true [-Werror,-Wtautological-pointer-compare]
iscsi-dd.c:272:17: error:
comparison of array 'iscsi_url->user' not equal to a null
pointer is always true [-Werror,-Wtautological-pointer-compare]
iscsi-dd.c:331:17: error:
comparison of array 'iscsi_url->user' not equal to a null
pointer is always true [-Werror,-Wtautological-pointer-compare]
ld_iscsi.c:99:18: error:
comparison of array 'iscsi_url->user' not equal to a null
pointer is always true [-Werror,-Wtautological-pointer-compare]
Fix those errors and also similar code patterns in aros/iscsi-ls.c and
test-tool/iscsi-support.c.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
ascq is NULL if there are no ascqs provided for this failure mode.
Do not try to dereference the 0-th element in this array before checking
that the array has at least one element.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
There is no agreement among the T10 committee whether a SCSI target should
report "invalid opcode", "invalid field in CDB" or "invalid field in
parameter list" if the opcode consists of two bytes. Hence accept all three
sense codes for two-byte opcodes. For more information see also Frederick
Knight, RE: INVALID COMMAND OPERATION CODE, T10 Reflector, 16 May 2008
(http://t10.org/ftp/t10/t10r/2008/r0805167.htm).
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
A quote from SPC-4: "When using the MODE SENSE command, a
parameters saveable (PS) bit set to one indicates that the mode
page may be saved by the logical unit in a nonvolatile, vendor
specific location. A PS bit set to zero indicates that the device
server is not able to save the supported parameters. When using
the MODE SELECT command, the PS bit is reserved."
Hence clear the PS bit after having queried a mode page via MODE
SENSE and before changing it via MODE SELECT.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Add 0x2701/0x2702 to the list of valid ASCQ values we accept for devices
that are write protected.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
valgrind does not know that sense will be initialized by the ioctl
so we need to to it explicitely to keep it from warning us.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Create a wrapper for sending scsi_commands so that we can hide the
libiscsi function far away from the "opcode" helpers.
This means we only have a single place later to switch to a different
type of device, such as a SG_IO one.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Switch orwrite helpers to use _command_async instead of calling _orwrite_sync()
to prepare for switching to non-iscsi targets. Use the new check_result API
so that we only need a single helper function for ORWRITE instead of one
helper for each expected result.
Signed-off-by: Ronnie Sahlberg <sahlberg@localhost>
Many/most all SCSI helpers do pretty much the same checking for the SCSI
result and status. Break this out into a separate helper that we can use
to reduce code duplication.
Signed-off-by: Ronnie Sahlberg <sahlberg@localhost>
Although SPC-2 specifies that a reservation conflict should be
reported when TEST UNIT READY is received from another initiator than
the registered initiator, it is an established practice that TEST
UNIT READY is accepted in this case. Hence use the MODE SENSE command
to test the effect of the RESERVE command instead of TEST UNIT READY.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Dell Equallogic sans report an invalid LBA offset in the descriptor when
using 4k LUNs. Check the descriptor for consistency with the request.
Signed-off-by: Peter Lieven <pl@kamp.de>
Rename the macros for managing the linked lists from SLIST_* to ISCSI_LIST_*
to avoid a clash on *BSD which already have other macros SLIST_*
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>