Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugins/wdc: Fix code scanning alert #2211

Merged
merged 2 commits into from
Mar 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 17 additions & 18 deletions plugins/wdc/wdc-nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -9567,10 +9567,10 @@ static int wdc_fetch_log_file_from_device(struct nvme_dev *dev, __u32 fileId,
__u16 spiDestn, __u64 fileSize, __u8 *dataBuffer)
{
int ret = WDC_STATUS_FAILURE;
__u32 chunckSize = WDC_DE_VU_READ_BUFFER_STANDARD_OFFSET;
__u32 maximumTransferLength = 0;
__u32 buffSize = 0;
__u64 offsetIdx = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not mix whitespace changes with code changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for mixing the changes everytime so just split the changes to commits.

__u32 chunckSize = WDC_DE_VU_READ_BUFFER_STANDARD_OFFSET;
__u32 maximumTransferLength = 0;
__u32 buffSize = 0;
__u64 offsetIdx = 0;

if (!dev || !dataBuffer || !fileSize) {
ret = WDC_STATUS_INVALID_PARAMETER;
Expand Down Expand Up @@ -9618,18 +9618,17 @@ static int wdc_fetch_log_file_from_device(struct nvme_dev *dev, __u32 fileId,

static int wdc_de_get_dump_trace(struct nvme_dev *dev, char *filePath, __u16 binFileNameLen, char *binFileName)
{
int ret = WDC_STATUS_FAILURE;
__u8 *readBuffer = NULL;
__u32 readBufferLen = 0;
__u32 lastPktReadBufferLen = 0;
__u32 maxTransferLen = 0;
__u32 dumptraceSize = 0;
__u32 chunkSize = 0;
__u32 chunks = 0;
__u32 offset = 0;
__u8 loop = 0;
__u16 i = 0;
__u32 maximumTransferLength = 0;
int ret = WDC_STATUS_FAILURE;
__u8 *readBuffer = NULL;
__u32 readBufferLen = 0;
__u32 lastPktReadBufferLen = 0;
__u32 maxTransferLen = 0;
__u32 dumptraceSize = 0;
__u32 chunkSize;
__u32 chunks;
__u32 offset;
__u32 i;
__u32 maximumTransferLength = 0;

if (!dev || !binFileName || !filePath) {
ret = WDC_STATUS_INVALID_PARAMETER;
Expand Down Expand Up @@ -9678,7 +9677,7 @@ static int wdc_de_get_dump_trace(struct nvme_dev *dev, char *filePath, __u16 bin
}

for (i = 0; i < chunks; i++) {
offset = ((i*chunkSize) / 4);
offset = (i * chunkSize) / 4;

/* Last loop call, Assign readBufferLen to read only left over bytes */
if (i == (chunks - 1))
Expand All @@ -9693,7 +9692,7 @@ static int wdc_de_get_dump_trace(struct nvme_dev *dev, char *filePath, __u16 bin
break;
}
}
} while (loop);
} while (0);

if (ret == WDC_STATUS_SUCCESS) {
ret = wdc_WriteToFile(binFileName, (char *)readBuffer, dumptraceSize);
Expand Down