mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-19 19:51:27 +00:00
The patch below fixes / suppresses all iscsi-scst related endianness warnings
reported by sparse (make C=2 CF=-D__CHECK_ENDIAN__ iscsi). Signed-off-by: Bart Van Assche <bart.vanassche@gmail.com> with some improvements git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@1787 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -2396,7 +2396,7 @@ struct scst_aen {
|
||||
int event_fn; /* AEN fn */
|
||||
|
||||
struct scst_session *sess; /* corresponding session */
|
||||
uint64_t lun; /* corresponding LUN in SCSI form */
|
||||
__be64 lun; /* corresponding LUN in SCSI form */
|
||||
|
||||
union {
|
||||
/* SCSI AEN data */
|
||||
|
||||
@@ -1535,7 +1535,7 @@ static int vdisk_rigid_geo_pg(unsigned char *p, int pcontrol,
|
||||
if (rem != 0)
|
||||
ncyl++;
|
||||
memcpy(&n, p + 2, sizeof(u32));
|
||||
n = n | (cpu_to_be32(ncyl) >> 8);
|
||||
n = n | ((__force u32)cpu_to_be32(ncyl) >> 8);
|
||||
memcpy(p + 2, &n, sizeof(u32));
|
||||
if (1 == pcontrol)
|
||||
memset(p + 2, 0, sizeof(geo_m_pg) - 2);
|
||||
@@ -1956,7 +1956,7 @@ static void vdisk_exec_read_capacity(struct scst_cmd *cmd)
|
||||
nblocks = virt_dev->nblocks;
|
||||
|
||||
if ((cmd->cdb[8] & 1) == 0) {
|
||||
uint64_t lba = be64_to_cpu(get_unaligned((uint64_t *)&cmd->cdb[2]));
|
||||
uint64_t lba = be64_to_cpu(get_unaligned((__be64 *)&cmd->cdb[2]));
|
||||
if (lba != 0) {
|
||||
TRACE_DBG("PMI zero and LBA not zero (cmd %p)", cmd);
|
||||
scst_set_cmd_error(cmd,
|
||||
@@ -2023,7 +2023,7 @@ static void vdisk_exec_read_capacity16(struct scst_cmd *cmd)
|
||||
nblocks = virt_dev->nblocks - 1;
|
||||
|
||||
if ((cmd->cdb[14] & 1) == 0) {
|
||||
uint64_t lba = be64_to_cpu(get_unaligned((uint64_t *)&cmd->cdb[2]));
|
||||
uint64_t lba = be64_to_cpu(get_unaligned((__be64 *)&cmd->cdb[2]));
|
||||
if (lba != 0) {
|
||||
TRACE_DBG("PMI zero and LBA not zero (cmd %p)", cmd);
|
||||
scst_set_cmd_error(cmd,
|
||||
|
||||
@@ -188,8 +188,8 @@ const char *debug_transport_id_to_initiator_name(const uint8_t *transport_id)
|
||||
break;
|
||||
case SCSI_TRANSPORTID_PROTOCOLID_SPI5:
|
||||
scnprintf(name_buf, SIZEOF_NAME_BUF,
|
||||
"%x:%x", be16_to_cpu((uint16_t)transport_id[2]),
|
||||
be16_to_cpu((uint16_t)transport_id[6]));
|
||||
"%x:%x", be16_to_cpu((__force __be16)transport_id[2]),
|
||||
be16_to_cpu((__force __be16)transport_id[6]));
|
||||
break;
|
||||
case SCSI_TRANSPORTID_PROTOCOLID_SRP:
|
||||
scnprintf(name_buf, SIZEOF_NAME_BUF,
|
||||
|
||||
@@ -5198,10 +5198,9 @@ out:
|
||||
EXPORT_SYMBOL(scst_get_cdb_info);
|
||||
|
||||
/* Packs SCST LUN back to SCSI form */
|
||||
uint64_t scst_pack_lun(const uint64_t lun, unsigned int addr_method)
|
||||
__be64 scst_pack_lun(const uint64_t lun, unsigned int addr_method)
|
||||
{
|
||||
|
||||
uint64_t res = 0;
|
||||
uint64_t res;
|
||||
uint16_t *p = (uint16_t *)&res;
|
||||
|
||||
res = lun;
|
||||
@@ -5216,10 +5215,10 @@ uint64_t scst_pack_lun(const uint64_t lun, unsigned int addr_method)
|
||||
}
|
||||
/* Default is to use peripheral device addressing mode */
|
||||
|
||||
*p = cpu_to_be16(*p);
|
||||
*p = (__force u16)cpu_to_be16(*p);
|
||||
|
||||
TRACE_EXIT_HRES((unsigned long)res);
|
||||
return res;
|
||||
return (__force __be64)res;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -5246,16 +5245,16 @@ uint64_t scst_unpack_lun(const uint8_t *lun, int len)
|
||||
if (len > 2) {
|
||||
switch (len) {
|
||||
case 8:
|
||||
if ((*((uint64_t *)lun) &
|
||||
if ((*((__be64 *)lun) &
|
||||
__constant_cpu_to_be64(0x0000FFFFFFFFFFFFLL)) != 0)
|
||||
goto out_err;
|
||||
break;
|
||||
case 4:
|
||||
if (*((uint16_t *)&lun[2]) != 0)
|
||||
if (*((__be16 *)&lun[2]) != 0)
|
||||
goto out_err;
|
||||
break;
|
||||
case 6:
|
||||
if (*((uint32_t *)&lun[2]) != 0)
|
||||
if (*((__be32 *)&lun[2]) != 0)
|
||||
goto out_err;
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -519,7 +519,7 @@ static void scst_pr_abort_reg(struct scst_device *dev,
|
||||
struct scst_cmd *pr_cmd, struct scst_dev_registrant *reg)
|
||||
{
|
||||
struct scst_session *sess;
|
||||
uint64_t packed_lun;
|
||||
__be64 packed_lun;
|
||||
int rc;
|
||||
|
||||
TRACE_ENTRY();
|
||||
|
||||
@@ -427,7 +427,7 @@ void scst_lib_exit(void);
|
||||
int scst_get_full_buf(struct scst_cmd *cmd, uint8_t **buf);
|
||||
void scst_put_full_buf(struct scst_cmd *cmd, uint8_t *buf);
|
||||
|
||||
uint64_t scst_pack_lun(const uint64_t lun, unsigned int addr_method);
|
||||
__be64 scst_pack_lun(const uint64_t lun, unsigned int addr_method);
|
||||
uint64_t scst_unpack_lun(const uint8_t *lun, int len);
|
||||
|
||||
struct scst_mgmt_cmd *scst_alloc_mgmt_cmd(gfp_t gfp_mask);
|
||||
|
||||
Reference in New Issue
Block a user