Commit 44a5b977 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Martin K. Petersen

scsi: advansys: fix uninitialized data access

gcc-7.0.1 now warns about a previously unnoticed access of uninitialized
struct members:

drivers/scsi/advansys.c: In function 'AscMsgOutSDTR':
drivers/scsi/advansys.c:3860:26: error: '*((void *)&sdtr_buf+5)' may be used uninitialized in this function [-Werror=maybe-uninitialized]
         ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]);
                          ^
drivers/scsi/advansys.c:3860:26: error: '*((void *)&sdtr_buf+7)' may be used uninitialized in this function [-Werror=maybe-uninitialized]
drivers/scsi/advansys.c:3860:26: error: '*((void *)&sdtr_buf+5)' may be used uninitialized in this function [-Werror=maybe-uninitialized]
drivers/scsi/advansys.c:3860:26: error: '*((void *)&sdtr_buf+7)' may be used uninitialized in this function [-Werror=maybe-uninitialized]

The code has existed in this exact form at least since v2.6.12, and the
warning seems correct. This uses named initializers to ensure we
initialize all members of the structure.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 83148866
...@@ -6291,18 +6291,17 @@ static uchar AscGetSynPeriodIndex(ASC_DVC_VAR *asc_dvc, uchar syn_time) ...@@ -6291,18 +6291,17 @@ static uchar AscGetSynPeriodIndex(ASC_DVC_VAR *asc_dvc, uchar syn_time)
static uchar static uchar
AscMsgOutSDTR(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar sdtr_offset) AscMsgOutSDTR(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar sdtr_offset)
{ {
EXT_MSG sdtr_buf; PortAddr iop_base = asc_dvc->iop_base;
uchar sdtr_period_index; uchar sdtr_period_index = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
PortAddr iop_base; EXT_MSG sdtr_buf = {
.msg_type = EXTENDED_MESSAGE,
iop_base = asc_dvc->iop_base; .msg_len = MS_SDTR_LEN,
sdtr_buf.msg_type = EXTENDED_MESSAGE; .msg_req = EXTENDED_SDTR,
sdtr_buf.msg_len = MS_SDTR_LEN; .xfer_period = sdtr_period,
sdtr_buf.msg_req = EXTENDED_SDTR; .req_ack_offset = sdtr_offset,
sdtr_buf.xfer_period = sdtr_period; };
sdtr_offset &= ASC_SYN_MAX_OFFSET; sdtr_offset &= ASC_SYN_MAX_OFFSET;
sdtr_buf.req_ack_offset = sdtr_offset;
sdtr_period_index = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
if (sdtr_period_index <= asc_dvc->max_sdtr_index) { if (sdtr_period_index <= asc_dvc->max_sdtr_index) {
AscMemWordCopyPtrToLram(iop_base, ASCV_MSGOUT_BEG, AscMemWordCopyPtrToLram(iop_base, ASCV_MSGOUT_BEG,
(uchar *)&sdtr_buf, (uchar *)&sdtr_buf,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment