scsi: ufs: core: initialize sg_cnt, sg_list
Commit Message
The clang build fails with
drivers/ufs/core/ufs_bsg.c:107:6: error: variable 'sg_cnt' is used
uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
if (dir != DMA_NONE) {
^~~~~~~~~~~~~~~
Similar for sg_list.
This is not an error because ufshcd_advanced_rpmb_req_handler() does a
similar check, but that check can be reduced if sg_list is initialized to NULL.
Initialize sg_cnt to silence its error.
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/ufs/core/ufs_bsg.c | 4 ++--
drivers/ufs/core/ufshcd.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
Comments
> The clang build fails with
> drivers/ufs/core/ufs_bsg.c:107:6: error: variable 'sg_cnt' is used
> uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-
> uninitialized]
> if (dir != DMA_NONE) {
> ^~~~~~~~~~~~~~~
> Similar for sg_list.
>
> This is not an error because ufshcd_advanced_rpmb_req_handler() does a
> similar check, but that check can be reduced if sg_list is initialized to NULL.
> Initialize sg_cnt to silence its error.
>
> Signed-off-by: Tom Rix <trix@redhat.com>
I think that Bean already submitted a fix for that.
Thanks,
Avri
@@ -70,9 +70,9 @@ static int ufs_bsg_exec_advanced_rpmb_req(struct ufs_hba *hba, struct bsg_job *j
struct ufs_rpmb_reply *rpmb_reply = job->reply;
struct bsg_buffer *payload = NULL;
enum dma_data_direction dir;
- struct scatterlist *sg_list;
+ struct scatterlist *sg_list = NULL;
int rpmb_req_type;
- int sg_cnt;
+ int sg_cnt = 0;
int ret;
int data_len;
@@ -7051,7 +7051,7 @@ int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *r
/* Copy EHS, starting with byte32, immediately after the CDB package */
memcpy(lrbp->ucd_req_ptr + 1, req_ehs, sizeof(*req_ehs));
- if (dir != DMA_NONE && sg_list)
+ if (sg_list)
ufshcd_sgl_to_prdt(hba, lrbp, sg_cnt, sg_list);
memset(lrbp->ucd_rsp_ptr, 0, sizeof(struct utp_upiu_rsp));