Replace index() with strchr()
This commit is contained in:
+6
-6
@@ -314,20 +314,20 @@ iscsi_parse_full_url(struct iscsi_context *iscsi, const char *url)
|
|||||||
user = getenv("LIBISCSI_CHAP_USERNAME");
|
user = getenv("LIBISCSI_CHAP_USERNAME");
|
||||||
passwd = getenv("LIBISCSI_CHAP_PASSWORD");
|
passwd = getenv("LIBISCSI_CHAP_PASSWORD");
|
||||||
|
|
||||||
tmp = index(portal, '@');
|
tmp = strchr(portal, '@');
|
||||||
if (tmp != NULL) {
|
if (tmp != NULL) {
|
||||||
user = portal;
|
user = portal;
|
||||||
*tmp++ = 0;
|
*tmp++ = 0;
|
||||||
portal = tmp;
|
portal = tmp;
|
||||||
|
|
||||||
tmp = index(user, '%');
|
tmp = strchr(user, '%');
|
||||||
if (tmp != NULL) {
|
if (tmp != NULL) {
|
||||||
*tmp++ = 0;
|
*tmp++ = 0;
|
||||||
passwd = tmp;
|
passwd = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
target = index(portal, '/');
|
target = strchr(portal, '/');
|
||||||
if (target == NULL) {
|
if (target == NULL) {
|
||||||
iscsi_set_error(iscsi, "Invalid URL %s\nCould not parse "
|
iscsi_set_error(iscsi, "Invalid URL %s\nCould not parse "
|
||||||
"'<target-iqn>'\niSCSI URL must be of the "
|
"'<target-iqn>'\niSCSI URL must be of the "
|
||||||
@@ -349,7 +349,7 @@ iscsi_parse_full_url(struct iscsi_context *iscsi, const char *url)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
lun = index(target, '/');
|
lun = strchr(target, '/');
|
||||||
if (lun == NULL) {
|
if (lun == NULL) {
|
||||||
iscsi_set_error(iscsi, "Invalid URL %s\nCould not parse <lun>\n"
|
iscsi_set_error(iscsi, "Invalid URL %s\nCould not parse <lun>\n"
|
||||||
"iSCSI URL must be of the form: %s",
|
"iSCSI URL must be of the form: %s",
|
||||||
@@ -445,13 +445,13 @@ iscsi_parse_portal_url(struct iscsi_context *iscsi, const char *url)
|
|||||||
user = getenv("LIBISCSI_CHAP_USERNAME");
|
user = getenv("LIBISCSI_CHAP_USERNAME");
|
||||||
passwd = getenv("LIBISCSI_CHAP_PASSWORD");
|
passwd = getenv("LIBISCSI_CHAP_PASSWORD");
|
||||||
|
|
||||||
tmp = index(portal, '@');
|
tmp = strchr(portal, '@');
|
||||||
if (tmp != NULL) {
|
if (tmp != NULL) {
|
||||||
user = portal;
|
user = portal;
|
||||||
*tmp++ = 0;
|
*tmp++ = 0;
|
||||||
portal = tmp;
|
portal = tmp;
|
||||||
|
|
||||||
tmp = index(user, '%');
|
tmp = strchr(user, '%');
|
||||||
if (tmp != NULL) {
|
if (tmp != NULL) {
|
||||||
*tmp++ = 0;
|
*tmp++ = 0;
|
||||||
passwd = tmp;
|
passwd = tmp;
|
||||||
|
|||||||
+2
-2
@@ -73,7 +73,7 @@ iscsi_connect_async(struct iscsi_context *iscsi, const char *portal,
|
|||||||
|
|
||||||
str = rindex(host, ':');
|
str = rindex(host, ':');
|
||||||
if (str != NULL) {
|
if (str != NULL) {
|
||||||
if (index(str, ']') == NULL) {
|
if (strchr(str, ']') == NULL) {
|
||||||
if (str != NULL) {
|
if (str != NULL) {
|
||||||
port = atoi(str+1);
|
port = atoi(str+1);
|
||||||
str[0] = 0;
|
str[0] = 0;
|
||||||
@@ -84,7 +84,7 @@ iscsi_connect_async(struct iscsi_context *iscsi, const char *portal,
|
|||||||
/* ipv6 in [...] form ? */
|
/* ipv6 in [...] form ? */
|
||||||
if (host[0] == '[') {
|
if (host[0] == '[') {
|
||||||
host ++;
|
host ++;
|
||||||
str = index(host, ']');
|
str = strchr(host, ']');
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
free(addr);
|
free(addr);
|
||||||
iscsi_set_error(iscsi, "Invalid target:%s "
|
iscsi_set_error(iscsi, "Invalid target:%s "
|
||||||
|
|||||||
Reference in New Issue
Block a user