From 90afb96d87a5c0aa7a061b7e55ffe25c148d1bfb Mon Sep 17 00:00:00 2001 From: Tokunori Ikegami Date: Mon, 12 Feb 2024 00:01:56 +0900 Subject: [PATCH 1/2] plugins/wdc: Whitespace changes Delete the loop variable since not changed the value. Also delete the some variables initial values not necessary. Signed-off-by: Tokunori Ikegami --- plugins/wdc/wdc-nvme.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/plugins/wdc/wdc-nvme.c b/plugins/wdc/wdc-nvme.c index 8ea98b8ff2..67d51f5177 100644 --- a/plugins/wdc/wdc-nvme.c +++ b/plugins/wdc/wdc-nvme.c @@ -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; + __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; @@ -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; + __u16 i; + __u32 maximumTransferLength = 0; if (!dev || !binFileName || !filePath) { ret = WDC_STATUS_INVALID_PARAMETER; @@ -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)) @@ -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); From fc584a5242a85efaf75f687728ec68bb8e6f0c6d Mon Sep 17 00:00:00 2001 From: Tokunori Ikegami Date: Mon, 12 Feb 2024 00:06:04 +0900 Subject: [PATCH 2/2] plugins/wdc: Fix narrow index variable type in for loop to __u32 Fix the comparison of narrow type with wide type in loop condition. Signed-off-by: Tokunori Ikegami --- plugins/wdc/wdc-nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/wdc/wdc-nvme.c b/plugins/wdc/wdc-nvme.c index 67d51f5177..7525055045 100644 --- a/plugins/wdc/wdc-nvme.c +++ b/plugins/wdc/wdc-nvme.c @@ -9627,7 +9627,7 @@ static int wdc_de_get_dump_trace(struct nvme_dev *dev, char *filePath, __u16 bin __u32 chunkSize; __u32 chunks; __u32 offset; - __u16 i; + __u32 i; __u32 maximumTransferLength = 0; if (!dev || !binFileName || !filePath) {