remove useless type cast
cover remove useless type cast
Currently the pattern in scripts/coccinelle/typecast.cocci is used to remove the useless type cast.
Use the following command to find out the use cases and remove the useless type case:
$ spatch --macro-file scripts/cocci-macro-file.h \
--sp-file ./scripts/coccinelle/typecast.cocci \
--keep-comments --in-place --use-gitgrep --dir .Yao Xingtao (2):
mips/loongson3_virt: remove useless type cast
nvme/ctrl: remove useless type cast
hw/mips/loongson3_virt.c | 4 ++-- hw/nvme/ctrl.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
2.41.0
PATCH 1/2 mips/loongson3_virt: remove useless type cast
The type of kernel_entry, kernel_low and kernel_high is uint64_t, cast the pointer of this type to uint64_t* is useless.
--- hw/mips/loongson3_virt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/mips/loongson3_virt.c +2 -2
@@ -355,8 +355,8 @@ static uint64_t load_kernel(CPUMIPSState *env) kernel_size =load_elf (loaderparams.kernel_filename,NULL , cpu_mips_kseg0_to_phys,NULL , - (uint64_t *)&kernel_entry, - (uint64_t *)&kernel_low, (uint64_t *)&kernel_high, + &kernel_entry, + &kernel_low, &kernel_high,NULL ,0 ,EM_MIPS ,1 ,0 );if (kernel_size <0 ) { error_report("could not load kernel '%s': %s",
Signature · 1 line
2.41.0
Re: [PATCH 1/2] mips/loongson3_virt: remove useless type cast
Quoted 15 lines · Yao Xingtao via
The type of
kernel_entry,kernel_lowandkernel_highisuint64_t, cast the pointer of this type to uint64_t* is useless.Signed-off-by Yao Xingtao <[email protected]>--- hw/mips/loongson3_virt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/mips/loongson3_virt.c +0
-0@@ -355,8 +355,8 @@ static uint64_t load_kernel(CPUMIPSState *env)
hw/mips/loongson3_virt.c static uint64_t load_kernel(CPUMIPSState *env)
Quoted 10 lines
hw/mips/loongson3_virt.c +2
-3kernel_size =load_elf (loaderparams.kernel_filename,NULL , cpu_mips_kseg0_to_phys,NULL , - (uint64_t *)&kernel_entry, - (uint64_t *)&kernel_low, (uint64_t *)&kernel_high, + &kernel_entry, + &kernel_low, &kernel_high,NULL ,0 ,EM_MIPS ,1 ,0 );if (kernel_size <0 ) { error_report("could not load kernel '%s': %s", --
thanks
-- PMM
Re: [PATCH 1/2] mips/loongson3_virt: remove useless type cast
In reply to Yao Xingtao viaQuoted 7 lines · Yao Xingtao
The type of
kernel_entry,kernel_lowandkernel_highisuint64_t, cast the pointer of this type to uint64_t* is useless.Signed-off-by Yao Xingtao <[email protected]>--- hw/mips/loongson3_virt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
and queued, thanks!
Re: [PATCH 1/2] mips/loongson3_virt: remove useless type cast
In reply to Yao Xingtao viaQuoted 7 lines · Yao Xingtao
The type of
kernel_entry,kernel_lowandkernel_highisuint64_t, cast the pointer of this type to uint64_t* is useless.Signed-off-by Yao Xingtao <[email protected]>--- hw/mips/loongson3_virt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Patch queued, thanks.
PATCH 2/2 nvme/ctrl: remove useless type cast
In reply to Yao Xingtao viaThe type of req->cmd is NvmeCmd, cast the pointer of this type to NvmeCmd* is useless.
--- hw/nvme/ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/nvme/ctrl.c +1 -1
@@ -4167,7 +4167,7 @@ static bool nvme_zone_matches_filter(uint32_t zafs, NvmeZone *zl)static uint16_t nvme_zone_mgmt_recv (NvmeCtrl *n,NvmeRequest *req) { -NvmeCmd *cmd = (NvmeCmd *)&req->cmd; +NvmeCmd *cmd = &req->cmd;NvmeNamespace *ns = req->ns;/* cdw12 is zero-based number of dwords to return. Convert to bytes */ uint32_t data_size = (le32_to_cpu (cmd->cdw12) +1 ) <<2 ;
Signature · 1 line
2.41.0
Re: [PATCH 2/2] nvme/ctrl: remove useless type cast
Quoted 23 lines · Yao Xingtao via
The type of
req->cmdis NvmeCmd, cast the pointer of this type to NvmeCmd* is useless.Signed-off-by Yao Xingtao <[email protected]>--- hw/nvme/ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/nvme/ctrl.c +1
-2@@ -4167,7 +4167,7 @@ static bool nvme_zone_matches_filter(uint32_t zafs, NvmeZone *zl)static uint16_t nvme_zone_mgmt_recv (NvmeCtrl *n,NvmeRequest *req) { -NvmeCmd *cmd = (NvmeCmd *)&req->cmd; +NvmeCmd *cmd = &req->cmd;NvmeNamespace *ns = req->ns;/* cdw12 is zero-based number of dwords to return. Convert to bytes */ uint32_t data_size = (le32_to_cpu (cmd->cdw12) +1 ) <<2 ; --
Quoted 1 line
2.41.0
thanks
-- PMM
Re: [PATCH 2/2] nvme/ctrl: remove useless type cast
In reply to Yao Xingtao viaQuoted 24 lines · Yao Xingtao
The type of
req->cmdis NvmeCmd, cast the pointer of this type to NvmeCmd* is useless.Signed-off-by Yao Xingtao <[email protected]>--- hw/nvme/ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/nvme/ctrl.c +1
-1@@ -4167,7 +4167,7 @@ static bool nvme_zone_matches_filter(uint32_t zafs, NvmeZone *zl)static uint16_t nvme_zone_mgmt_recv (NvmeCtrl *n,NvmeRequest *req) { -NvmeCmd *cmd = (NvmeCmd *)&req->cmd; +NvmeCmd *cmd = &req->cmd;NvmeNamespace *ns = req->ns;/* cdw12 is zero-based number of dwords to return. Convert to bytes */ uint32_t data_size = (le32_to_cpu (cmd->cdw12) +1 ) <<2 ;Signature · 1 line
2.41.0
Thanks! Queued on nvme-next!