Fix wrong checks for username
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>
This commit is contained in:
@@ -407,7 +407,7 @@ iscsi_context_login(const char *initiatorname, const char *url, int *lun)
|
||||
iscsi_set_session_type(iscsi, ISCSI_SESSION_NORMAL);
|
||||
iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE_CRC32C);
|
||||
|
||||
if (iscsi_url->user != NULL) {
|
||||
if (iscsi_url->user[0] != '\0') {
|
||||
if (iscsi_set_initiator_username_pwd(iscsi, iscsi_url->user, iscsi_url->passwd) != 0) {
|
||||
fprintf(stderr, "Failed to set initiator username and password\n");
|
||||
iscsi_destroy_url(iscsi_url);
|
||||
|
||||
Reference in New Issue
Block a user