target: replace strict_strto*() with kstrto*()

The usage of strict_strtoul() and strict_strtoull() is not preferred,
because strict_strtoul() and strict_strtoull() are obsolete. Thus,
kstrtoul() and kstrtoull() should be used.

v2: Fix incorrect return in ft_add_tpg (Fengguang)

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
This commit is contained in:
Jingoo Han 2013-07-19 16:22:19 +09:00 committed by Nicholas Bellinger
parent d4e4ab86bc
commit 57103d7fe1
9 changed files with 64 additions and 52 deletions

View File

@ -265,9 +265,9 @@ static struct se_tpg_np *lio_target_call_addnptotpg(
*port_str = '\0'; /* Terminate string for IP */ *port_str = '\0'; /* Terminate string for IP */
port_str++; /* Skip over ":" */ port_str++; /* Skip over ":" */
ret = strict_strtoul(port_str, 0, &port); ret = kstrtoul(port_str, 0, &port);
if (ret < 0) { if (ret < 0) {
pr_err("strict_strtoul() failed for port_str: %d\n", ret); pr_err("kstrtoul() failed for port_str: %d\n", ret);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
sock_in6 = (struct sockaddr_in6 *)&sockaddr; sock_in6 = (struct sockaddr_in6 *)&sockaddr;
@ -290,9 +290,9 @@ static struct se_tpg_np *lio_target_call_addnptotpg(
*port_str = '\0'; /* Terminate string for IP */ *port_str = '\0'; /* Terminate string for IP */
port_str++; /* Skip over ":" */ port_str++; /* Skip over ":" */
ret = strict_strtoul(port_str, 0, &port); ret = kstrtoul(port_str, 0, &port);
if (ret < 0) { if (ret < 0) {
pr_err("strict_strtoul() failed for port_str: %d\n", ret); pr_err("kstrtoul() failed for port_str: %d\n", ret);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
sock_in = (struct sockaddr_in *)&sockaddr; sock_in = (struct sockaddr_in *)&sockaddr;

View File

@ -428,7 +428,7 @@ static int iscsi_login_zero_tsih_s2(
ISCSI_LOGIN_STATUS_NO_RESOURCES); ISCSI_LOGIN_STATUS_NO_RESOURCES);
return -1; return -1;
} }
rc = strict_strtoul(param->value, 0, &mrdsl); rc = kstrtoul(param->value, 0, &mrdsl);
if (rc < 0) { if (rc < 0) {
iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
ISCSI_LOGIN_STATUS_NO_RESOURCES); ISCSI_LOGIN_STATUS_NO_RESOURCES);

View File

@ -1182,7 +1182,7 @@ static int iscsi_check_acceptor_state(struct iscsi_param *param, char *value,
unsigned long long tmp; unsigned long long tmp;
int rc; int rc;
rc = strict_strtoull(param->value, 0, &tmp); rc = kstrtoull(param->value, 0, &tmp);
if (rc < 0) if (rc < 0)
return -1; return -1;

View File

@ -1756,10 +1756,10 @@ ssize_t core_alua_store_access_type(
unsigned long tmp; unsigned long tmp;
int ret; int ret;
ret = strict_strtoul(page, 0, &tmp); ret = kstrtoul(page, 0, &tmp);
if (ret < 0) { if (ret < 0) {
pr_err("Unable to extract alua_access_type\n"); pr_err("Unable to extract alua_access_type\n");
return -EINVAL; return ret;
} }
if ((tmp != 0) && (tmp != 1) && (tmp != 2) && (tmp != 3)) { if ((tmp != 0) && (tmp != 1) && (tmp != 2) && (tmp != 3)) {
pr_err("Illegal value for alua_access_type:" pr_err("Illegal value for alua_access_type:"
@ -1794,10 +1794,10 @@ ssize_t core_alua_store_nonop_delay_msecs(
unsigned long tmp; unsigned long tmp;
int ret; int ret;
ret = strict_strtoul(page, 0, &tmp); ret = kstrtoul(page, 0, &tmp);
if (ret < 0) { if (ret < 0) {
pr_err("Unable to extract nonop_delay_msecs\n"); pr_err("Unable to extract nonop_delay_msecs\n");
return -EINVAL; return ret;
} }
if (tmp > ALUA_MAX_NONOP_DELAY_MSECS) { if (tmp > ALUA_MAX_NONOP_DELAY_MSECS) {
pr_err("Passed nonop_delay_msecs: %lu, exceeds" pr_err("Passed nonop_delay_msecs: %lu, exceeds"
@ -1825,10 +1825,10 @@ ssize_t core_alua_store_trans_delay_msecs(
unsigned long tmp; unsigned long tmp;
int ret; int ret;
ret = strict_strtoul(page, 0, &tmp); ret = kstrtoul(page, 0, &tmp);
if (ret < 0) { if (ret < 0) {
pr_err("Unable to extract trans_delay_msecs\n"); pr_err("Unable to extract trans_delay_msecs\n");
return -EINVAL; return ret;
} }
if (tmp > ALUA_MAX_TRANS_DELAY_MSECS) { if (tmp > ALUA_MAX_TRANS_DELAY_MSECS) {
pr_err("Passed trans_delay_msecs: %lu, exceeds" pr_err("Passed trans_delay_msecs: %lu, exceeds"
@ -1856,10 +1856,10 @@ ssize_t core_alua_store_implict_trans_secs(
unsigned long tmp; unsigned long tmp;
int ret; int ret;
ret = strict_strtoul(page, 0, &tmp); ret = kstrtoul(page, 0, &tmp);
if (ret < 0) { if (ret < 0) {
pr_err("Unable to extract implict_trans_secs\n"); pr_err("Unable to extract implict_trans_secs\n");
return -EINVAL; return ret;
} }
if (tmp > ALUA_MAX_IMPLICT_TRANS_SECS) { if (tmp > ALUA_MAX_IMPLICT_TRANS_SECS) {
pr_err("Passed implict_trans_secs: %lu, exceeds" pr_err("Passed implict_trans_secs: %lu, exceeds"
@ -1887,10 +1887,10 @@ ssize_t core_alua_store_preferred_bit(
unsigned long tmp; unsigned long tmp;
int ret; int ret;
ret = strict_strtoul(page, 0, &tmp); ret = kstrtoul(page, 0, &tmp);
if (ret < 0) { if (ret < 0) {
pr_err("Unable to extract preferred ALUA value\n"); pr_err("Unable to extract preferred ALUA value\n");
return -EINVAL; return ret;
} }
if ((tmp != 0) && (tmp != 1)) { if ((tmp != 0) && (tmp != 1)) {
pr_err("Illegal value for preferred ALUA: %lu\n", tmp); pr_err("Illegal value for preferred ALUA: %lu\n", tmp);
@ -1922,10 +1922,10 @@ ssize_t core_alua_store_offline_bit(
if (!lun->lun_sep) if (!lun->lun_sep)
return -ENODEV; return -ENODEV;
ret = strict_strtoul(page, 0, &tmp); ret = kstrtoul(page, 0, &tmp);
if (ret < 0) { if (ret < 0) {
pr_err("Unable to extract alua_tg_pt_offline value\n"); pr_err("Unable to extract alua_tg_pt_offline value\n");
return -EINVAL; return ret;
} }
if ((tmp != 0) && (tmp != 1)) { if ((tmp != 0) && (tmp != 1)) {
pr_err("Illegal value for alua_tg_pt_offline: %lu\n", pr_err("Illegal value for alua_tg_pt_offline: %lu\n",
@ -1961,10 +1961,10 @@ ssize_t core_alua_store_secondary_status(
unsigned long tmp; unsigned long tmp;
int ret; int ret;
ret = strict_strtoul(page, 0, &tmp); ret = kstrtoul(page, 0, &tmp);
if (ret < 0) { if (ret < 0) {
pr_err("Unable to extract alua_tg_pt_status\n"); pr_err("Unable to extract alua_tg_pt_status\n");
return -EINVAL; return ret;
} }
if ((tmp != ALUA_STATUS_NONE) && if ((tmp != ALUA_STATUS_NONE) &&
(tmp != ALUA_STATUS_ALTERED_BY_EXPLICT_STPG) && (tmp != ALUA_STATUS_ALTERED_BY_EXPLICT_STPG) &&
@ -1994,10 +1994,10 @@ ssize_t core_alua_store_secondary_write_metadata(
unsigned long tmp; unsigned long tmp;
int ret; int ret;
ret = strict_strtoul(page, 0, &tmp); ret = kstrtoul(page, 0, &tmp);
if (ret < 0) { if (ret < 0) {
pr_err("Unable to extract alua_tg_pt_write_md\n"); pr_err("Unable to extract alua_tg_pt_write_md\n");
return -EINVAL; return ret;
} }
if ((tmp != 0) && (tmp != 1)) { if ((tmp != 0) && (tmp != 1)) {
pr_err("Illegal value for alua_tg_pt_write_md:" pr_err("Illegal value for alua_tg_pt_write_md:"

View File

@ -577,9 +577,9 @@ static ssize_t target_core_dev_store_attr_##_name( \
unsigned long val; \ unsigned long val; \
int ret; \ int ret; \
\ \
ret = strict_strtoul(page, 0, &val); \ ret = kstrtoul(page, 0, &val); \
if (ret < 0) { \ if (ret < 0) { \
pr_err("strict_strtoul() failed with" \ pr_err("kstrtoul() failed with" \
" ret: %d\n", ret); \ " ret: %d\n", ret); \
return -EINVAL; \ return -EINVAL; \
} \ } \
@ -1310,9 +1310,9 @@ static ssize_t target_core_dev_pr_store_attr_res_aptpl_metadata(
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
} }
ret = strict_strtoull(arg_p, 0, &tmp_ll); ret = kstrtoull(arg_p, 0, &tmp_ll);
if (ret < 0) { if (ret < 0) {
pr_err("strict_strtoull() failed for" pr_err("kstrtoull() failed for"
" sa_res_key=\n"); " sa_res_key=\n");
goto out; goto out;
} }
@ -1836,11 +1836,11 @@ static ssize_t target_core_alua_lu_gp_store_attr_lu_gp_id(
unsigned long lu_gp_id; unsigned long lu_gp_id;
int ret; int ret;
ret = strict_strtoul(page, 0, &lu_gp_id); ret = kstrtoul(page, 0, &lu_gp_id);
if (ret < 0) { if (ret < 0) {
pr_err("strict_strtoul() returned %d for" pr_err("kstrtoul() returned %d for"
" lu_gp_id\n", ret); " lu_gp_id\n", ret);
return -EINVAL; return ret;
} }
if (lu_gp_id > 0x0000ffff) { if (lu_gp_id > 0x0000ffff) {
pr_err("ALUA lu_gp_id: %lu exceeds maximum:" pr_err("ALUA lu_gp_id: %lu exceeds maximum:"
@ -2032,11 +2032,11 @@ static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_access_state(
return -EINVAL; return -EINVAL;
} }
ret = strict_strtoul(page, 0, &tmp); ret = kstrtoul(page, 0, &tmp);
if (ret < 0) { if (ret < 0) {
pr_err("Unable to extract new ALUA access state from" pr_err("Unable to extract new ALUA access state from"
" %s\n", page); " %s\n", page);
return -EINVAL; return ret;
} }
new_state = (int)tmp; new_state = (int)tmp;
@ -2079,11 +2079,11 @@ static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_access_status(
return -EINVAL; return -EINVAL;
} }
ret = strict_strtoul(page, 0, &tmp); ret = kstrtoul(page, 0, &tmp);
if (ret < 0) { if (ret < 0) {
pr_err("Unable to extract new ALUA access status" pr_err("Unable to extract new ALUA access status"
" from %s\n", page); " from %s\n", page);
return -EINVAL; return ret;
} }
new_status = (int)tmp; new_status = (int)tmp;
@ -2139,10 +2139,10 @@ static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_write_metadata(
unsigned long tmp; unsigned long tmp;
int ret; int ret;
ret = strict_strtoul(page, 0, &tmp); ret = kstrtoul(page, 0, &tmp);
if (ret < 0) { if (ret < 0) {
pr_err("Unable to extract alua_write_metadata\n"); pr_err("Unable to extract alua_write_metadata\n");
return -EINVAL; return ret;
} }
if ((tmp != 0) && (tmp != 1)) { if ((tmp != 0) && (tmp != 1)) {
@ -2263,11 +2263,11 @@ static ssize_t target_core_alua_tg_pt_gp_store_attr_tg_pt_gp_id(
unsigned long tg_pt_gp_id; unsigned long tg_pt_gp_id;
int ret; int ret;
ret = strict_strtoul(page, 0, &tg_pt_gp_id); ret = kstrtoul(page, 0, &tg_pt_gp_id);
if (ret < 0) { if (ret < 0) {
pr_err("strict_strtoul() returned %d for" pr_err("kstrtoul() returned %d for"
" tg_pt_gp_id\n", ret); " tg_pt_gp_id\n", ret);
return -EINVAL; return ret;
} }
if (tg_pt_gp_id > 0x0000ffff) { if (tg_pt_gp_id > 0x0000ffff) {
pr_err("ALUA tg_pt_gp_id: %lu exceeds maximum:" pr_err("ALUA tg_pt_gp_id: %lu exceeds maximum:"
@ -2676,10 +2676,10 @@ static ssize_t target_core_hba_store_attr_hba_mode(struct se_hba *hba,
if (transport->pmode_enable_hba == NULL) if (transport->pmode_enable_hba == NULL)
return -EINVAL; return -EINVAL;
ret = strict_strtoul(page, 0, &mode_flag); ret = kstrtoul(page, 0, &mode_flag);
if (ret < 0) { if (ret < 0) {
pr_err("Unable to extract hba mode flag: %d\n", ret); pr_err("Unable to extract hba mode flag: %d\n", ret);
return -EINVAL; return ret;
} }
if (hba->dev_count) { if (hba->dev_count) {
@ -2767,11 +2767,11 @@ static struct config_group *target_core_call_addhbatotarget(
str++; /* Skip to start of plugin dependent ID */ str++; /* Skip to start of plugin dependent ID */
} }
ret = strict_strtoul(str, 0, &plugin_dep_id); ret = kstrtoul(str, 0, &plugin_dep_id);
if (ret < 0) { if (ret < 0) {
pr_err("strict_strtoul() returned %d for" pr_err("kstrtoul() returned %d for"
" plugin_dep_id\n", ret); " plugin_dep_id\n", ret);
return ERR_PTR(-EINVAL); return ERR_PTR(ret);
} }
/* /*
* Load up TCM subsystem plugins if they have not already been loaded. * Load up TCM subsystem plugins if they have not already been loaded.

View File

@ -189,9 +189,11 @@ static ssize_t target_fabric_mappedlun_store_write_protect(
struct se_node_acl *se_nacl = lacl->se_lun_nacl; struct se_node_acl *se_nacl = lacl->se_lun_nacl;
struct se_portal_group *se_tpg = se_nacl->se_tpg; struct se_portal_group *se_tpg = se_nacl->se_tpg;
unsigned long op; unsigned long op;
int ret;
if (strict_strtoul(page, 0, &op)) ret = kstrtoul(page, 0, &op);
return -EINVAL; if (ret)
return ret;
if ((op != 1) && (op != 0)) if ((op != 1) && (op != 0))
return -EINVAL; return -EINVAL;
@ -350,7 +352,10 @@ static struct config_group *target_fabric_make_mappedlun(
* Determine the Mapped LUN value. This is what the SCSI Initiator * Determine the Mapped LUN value. This is what the SCSI Initiator
* Port will actually see. * Port will actually see.
*/ */
if (strict_strtoul(buf + 4, 0, &mapped_lun) || mapped_lun > UINT_MAX) { ret = kstrtoul(buf + 4, 0, &mapped_lun);
if (ret)
goto out;
if (mapped_lun > UINT_MAX) {
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
@ -875,7 +880,10 @@ static struct config_group *target_fabric_make_lun(
" \"lun_$LUN_NUMBER\"\n"); " \"lun_$LUN_NUMBER\"\n");
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
if (strict_strtoul(name + 4, 0, &unpacked_lun) || unpacked_lun > UINT_MAX) errno = kstrtoul(name + 4, 0, &unpacked_lun);
if (errno)
return ERR_PTR(errno);
if (unpacked_lun > UINT_MAX)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
lun = core_get_lun_from_tpg(se_tpg, unpacked_lun); lun = core_get_lun_from_tpg(se_tpg, unpacked_lun);

View File

@ -635,10 +635,10 @@ static ssize_t fd_set_configfs_dev_params(struct se_device *dev,
ret = -ENOMEM; ret = -ENOMEM;
break; break;
} }
ret = strict_strtoull(arg_p, 0, &fd_dev->fd_dev_size); ret = kstrtoull(arg_p, 0, &fd_dev->fd_dev_size);
kfree(arg_p); kfree(arg_p);
if (ret < 0) { if (ret < 0) {
pr_err("strict_strtoull() failed for" pr_err("kstrtoull() failed for"
" fd_dev_size=\n"); " fd_dev_size=\n");
goto out; goto out;
} }

View File

@ -536,10 +536,10 @@ static ssize_t iblock_set_configfs_dev_params(struct se_device *dev,
ret = -ENOMEM; ret = -ENOMEM;
break; break;
} }
ret = strict_strtoul(arg_p, 0, &tmp_readonly); ret = kstrtoul(arg_p, 0, &tmp_readonly);
kfree(arg_p); kfree(arg_p);
if (ret < 0) { if (ret < 0) {
pr_err("strict_strtoul() failed for" pr_err("kstrtoul() failed for"
" readonly=\n"); " readonly=\n");
goto out; goto out;
} }

View File

@ -311,7 +311,11 @@ static struct se_portal_group *ft_add_tpg(
*/ */
if (strstr(name, "tpgt_") != name) if (strstr(name, "tpgt_") != name)
return NULL; return NULL;
if (strict_strtoul(name + 5, 10, &index) || index > UINT_MAX)
ret = kstrtoul(name + 5, 10, &index);
if (ret)
return NULL;
if (index > UINT_MAX)
return NULL; return NULL;
lacl = container_of(wwn, struct ft_lport_acl, fc_lport_wwn); lacl = container_of(wwn, struct ft_lport_acl, fc_lport_wwn);