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 <arne.redlich@googlemail.com>
This commit is contained in:
16
lib/init.c
16
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user