]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
target-core: don't use "const char*" for a buffer that is written to
authorRasmus Villemoes <rasmus.villemoes@prevas.dk>
Tue, 21 Nov 2017 00:12:43 +0000 (01:12 +0100)
committerNicholas Bellinger <nab@linux-iscsi.org>
Fri, 12 Jan 2018 23:07:09 +0000 (15:07 -0800)
iscsi_parse_pr_out_transport_id launders the const away via a call to
strstr(), and then modifies the buffer (writing a nul byte) through
the return value. It's cleaner to be honest and simply declare the
parameter as "char*", fixing up the call chain, and allowing us to
drop the cast in the return statement.

Amusingly, the two current callers found it necessary to cast a
non-const pointer to a const.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/target_core_fabric_lib.c
drivers/target/target_core_internal.h
drivers/target/target_core_pr.c

index 508da345b73fdb3561a434d8ed320469081ded5a..71a80257a05260fd061b680cf13fcc5a2759431b 100644 (file)
@@ -273,7 +273,7 @@ static int iscsi_get_pr_transport_id_len(
 
 static char *iscsi_parse_pr_out_transport_id(
        struct se_portal_group *se_tpg,
-       const char *buf,
+       char *buf,
        u32 *out_tid_len,
        char **port_nexus_ptr)
 {
@@ -356,7 +356,7 @@ static char *iscsi_parse_pr_out_transport_id(
                }
        }
 
-       return (char *)&buf[4];
+       return &buf[4];
 }
 
 int target_get_pr_transport_id_len(struct se_node_acl *nacl,
@@ -405,7 +405,7 @@ int target_get_pr_transport_id(struct se_node_acl *nacl,
 }
 
 const char *target_parse_pr_out_transport_id(struct se_portal_group *tpg,
-               const char *buf, u32 *out_tid_len, char **port_nexus_ptr)
+               char *buf, u32 *out_tid_len, char **port_nexus_ptr)
 {
        u32 offset;
 
index 9384d19a7326c81274e589a58cd0a56b4f8bb98a..6d53d9fcb883b7c1089da6f17db49ef3a0184170 100644 (file)
@@ -102,7 +102,7 @@ int target_get_pr_transport_id(struct se_node_acl *nacl,
                struct t10_pr_registration *pr_reg, int *format_code,
                unsigned char *buf);
 const char *target_parse_pr_out_transport_id(struct se_portal_group *tpg,
-               const char *buf, u32 *out_tid_len, char **port_nexus_ptr);
+               char *buf, u32 *out_tid_len, char **port_nexus_ptr);
 
 /* target_core_hba.c */
 struct se_hba *core_alloc_hba(const char *, u32, u32);
index b024613f921718a40c761ea0f8eb7befe28dd168..01ac306131c1f163c6eb6043651a412e3e71dc76 100644 (file)
@@ -1601,7 +1601,7 @@ core_scsi3_decode_spec_i_port(
                        dest_rtpi = tmp_lun->lun_rtpi;
 
                        i_str = target_parse_pr_out_transport_id(tmp_tpg,
-                                       (const char *)ptr, &tid_len, &iport_ptr);
+                                       ptr, &tid_len, &iport_ptr);
                        if (!i_str)
                                continue;
 
@@ -3287,7 +3287,7 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key,
                goto out;
        }
        initiator_str = target_parse_pr_out_transport_id(dest_se_tpg,
-                       (const char *)&buf[24], &tmp_tid_len, &iport_ptr);
+                       &buf[24], &tmp_tid_len, &iport_ptr);
        if (!initiator_str) {
                pr_err("SPC-3 PR REGISTER_AND_MOVE: Unable to locate"
                        " initiator_str from Transport ID\n");