Remove unnecessary null pointer checks?
Subsystems (270)
PATCH 3/8 drm/amdgpu: One function call less in amdgpu_cgs_acpi_eval_object() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 13:43:44 +0200
The kfree() function was called in one case by the amdgpu_cgs_acpi_eval_object() function during error handling even if the passed variable "obj" contained a null pointer.
* Adjust jump targets according to the Linux coding style convention.
* Delete unnecessary initialisations for the variables "obj" and "params" then.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +9 -9
@@ -903,8 +903,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device,acpi_handle handle;struct acpi_object_list input;struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER ,NULL }; -union acpi_object *params =NULL ; -union acpi_object *obj =NULL ; +union acpi_object *params, *obj;uint8_t name[5 ] = {'\0' };struct cgs_acpi_method_argument *argument =NULL ;uint32_t i, count;
@@ -996,7 +995,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device,if (ACPI_FAILURE (status)) { result = -EIO ; - goto error; + goto free_input; }/* return the output info */
@@ -1006,7 +1005,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device,if ((obj->type !=ACPI_TYPE_PACKAGE ) || (obj->package.count != count)) { result = -EIO ; - goto error; + goto free_obj; } params = obj->package.elements; }else
@@ -1014,13 +1013,13 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device,if (params ==NULL ) { result = -EIO ; - goto error; + goto free_obj; }for (i =0 ; i < count; i++) {if (argument->type != params->type) { result = -EIO ; - goto error; + goto free_obj; }switch (params->type) {case ACPI_TYPE_INTEGER :
@@ -1030,7 +1029,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device,if ((params->string.length != argument->data_length) || (params->string.pointer ==NULL )) { result = -EIO ; - goto error; + goto free_obj; } strncpy(argument->pointer, params->string.pointer,
@@ -1039,7 +1038,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device,case ACPI_TYPE_BUFFER :if (params->buffer.pointer ==NULL ) { result = -EIO ; - goto error; + goto free_obj; } memcpy(argument->pointer, params->buffer.pointer,
@@ -1052,8 +1051,9 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device, params++; } -error: +free_obj:kfree (obj); +free_input:kfree ((void *)input.pointer);return result; }
Signature · 1 line
2.9.1
PATCH 4/8 drm/amdgpu: Delete a variable in amdgpu_cgs_acpi_eval_object()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 14:00:28 +0200
The local variable "func_no" was assigned a value at two places. But it was not read within this function. Thus delete it.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +0 -2
@@ -909,7 +909,6 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device,uint32_t i, count;acpi_status status;int result =0 ; -uint32_t func_no =0xFFFFFFFF ; handle =ACPI_HANDLE (&adev->pdev->dev);if (!handle)
@@ -926,7 +925,6 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device,if (info->pinput_argument =NULL )return -EINVAL ; argument = info->pinput_argument; - func_no = argument->value;for (i =0 ; i < info->input_count; i++) { if (((argument->type = ACPI_TYPE_STRING) || (argument->type = ACPI_TYPE_BUFFER)) &&
Signature · 1 line
2.9.1
PATCH 5/8 drm/amdgpu: Delete an unnecessary variable initialisation in amdgpu_cgs_acpi_eval_object()
From: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 14:54:12 +0200
The variable "argument" will be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +1 -1
@@ -905,7 +905,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device,struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER ,NULL };union acpi_object *params, *obj;uint8_t name[5 ] = {'\0' }; -struct cgs_acpi_method_argument *argument =NULL ; +struct cgs_acpi_method_argument *argument;uint32_t i, count;acpi_status status;int result =0 ;
Signature · 1 line
2.9.1
PATCH 5/8 drm/amdgpu: Delete an unnecessary variable initialisation in amdgpu_cgs_acpi_eval_object()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 14:54:12 +0200
The variable "argument" will be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +1 -1
@@ -905,7 +905,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device,struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER ,NULL };union acpi_object *params, *obj;uint8_t name[5 ] = {'\0' }; -struct cgs_acpi_method_argument *argument =NULL ; +struct cgs_acpi_method_argument *argument;uint32_t i, count;acpi_status status;int result =0 ;
Signature · 1 line
2.9.1
PATCH 6/8 drm/amdgpu: Change assignment for a variable in amdgpu_cgs_acpi_eval_object()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 15:05:45 +0200
Indicate successful function execution only at the end. Thus omit initialisation for the variable "result" at the beginning.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +2 -1
@@ -908,7 +908,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device,struct cgs_acpi_method_argument *argument;uint32_t i, count;acpi_status status; -int result =0 ; +int result; handle =ACPI_HANDLE (&adev->pdev->dev);if (!handle)
@@ -1049,6 +1049,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device, params++; } + result =0 ; free_obj:kfree (obj); free_input:
Signature · 1 line
2.9.1
PATCH 7/8 drm/amd/powerplay: Change assignment for a buffer variable in phm_dispatch_table()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 15:36:36 +0200
The variable "temp_storage" was eventually reassigned with a pointer. Thus omit the explicit initialisation at the beginning.
--- drivers/gpu/drm/amd/powerplay/hwmgr/functiontables.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/powerplay/hwmgr/functiontables.c +3 -2
@@ -60,7 +60,7 @@ int phm_dispatch_table(struct pp_hwmgr *hwmgr, void *input, void *output) { int result = 0; -void *temp_storage =NULL ; +void *temp_storage;if (hwmgr ==NULL || rt_table ==NULL ) {printk (KERN_ERR "[ powerplay ] Invalid Parameter!\n" );
@@ -73,7 +73,8 @@ int phm_dispatch_table(struct pp_hwmgr *hwmgr,printk (KERN_ERR "[ powerplay ] Could not allocate table temporary storage\n" );return -ENOMEM ; } - } + }else + temp_storage =NULL ; result =phm_run_table (hwmgr, rt_table, input, output, temp_storage);kfree (temp_storage);
Signature · 1 line
2.9.1
Re: [PATCH 7/8] drm/amd/powerplay: Change assignment for a buffer variable in phm_dispatch_table()
Am 16.07.2016 17:08, schrieb SF Markus Elfring:
Quoted 25 lines
From: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 15:36:36 +0200The variable "
temp_storage" was eventually reassigned with a pointer. Thus omit the explicit initialisation at the beginning.Signed-off-by Markus Elfring <[email protected]>--- drivers/gpu/drm/amd/powerplay/hwmgr/functiontables.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/powerplay/hwmgr/functiontables.c +1
-1@@ -60,7 +60,7 @@ int phm_dispatch_table(struct pp_hwmgr *hwmgr, void *input, void *output) { int result = 0; -void *temp_storage =NULL ; +void *temp_storage;if (hwmgr ==NULL || rt_table ==NULL ) {printk (KERN_ERR "[ powerplay ] Invalid Parameter!\n" );
drivers/gpu/drm/amd/powerplay/hwmgr/functiontables.c int phm_dispatch_table(struct pp_hwmgr *hwmgr, · line 80
Quoted 9 lines
drivers/gpu/drm/amd/powerplay/hwmgr/functiontables.c +2
-1@@ -73,7 +73,8 @@ int phm_dispatch_table(struct pp_hwmgr *hwmgr,printk (KERN_ERR "[ powerplay ] Could not allocate table temporary storage\n" );return -ENOMEM ; } - } + }else + temp_storage =NULL ; result =phm_run_table (hwmgr, rt_table, input, output, temp_storage);kfree (temp_storage);
the handling of rt_table->storage_size == 0 is so better visible.
IMHO in this case the function could return directly either with -EINVAL; or with 0; -> more direct more obvious.
if (rt_table->storage_size == 0 )
return 0;
re,
wh
PATCH 8/8 drm/amd/powerplay: Delete an unnecessary variable initialisation in phm_dispatch_table()
In reply to SF Markus ElfringFrom 0bf6f3c40786e12d3d42672f1d56296b30e17ac9 Mon Sep 17 00:00:00 2001
From: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 15:50:18 +0200
Subject: [PATCH 8/8] drm/amd/powerplay: Delete an unnecessary variable
initialisation in phm_dispatch_table()
The variable "result" will be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning.
--- drivers/gpu/drm/amd/powerplay/hwmgr/functiontables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/hwmgr/functiontables.c +1 -1
@@ -59,7 +59,7 @@ int phm_dispatch_table(struct pp_hwmgr *hwmgr,struct phm_runtime_table_header *rt_table, void *input, void *output) { - int result = 0; + int result;void *temp_storage;if (hwmgr =NULL || rt_table =NULL ) {
Signature · 1 line
2.9.1
Christian König
maintainerRe: [PATCH 0/8] drm/amdgpu: Fine-tuning for three function implementations
In reply to SF Markus ElfringAm 16.07.2016 um 16:33 schrieb SF Markus Elfring:
Quoted 5 lines
From: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 16:23:21 +0200Further update suggestions were taken into account after patches were applied from static source code analysis.
Small coding style nit pick on patch #7:
Review
Quoted 3 lines
(quoted diff) +2
-1- } + } else + temp_storage = NULL;
When an "if" has "{" and "}" the else should also use them even when it is only one line.
With that fixed the whole series is Reviewed-by: Christian König <[email protected]>, but as Walter Harms pointed out as well there are a couple of other things we could make more as well.
Regards,
Christian.
Quoted 16 lines
Markus Elfring (8):
Delete an unnecessary check beforedrm_gem_object_unreference_unlocked()Delete unnecessary checks before the function call "kfree"
One function call less inamdgpu_cgs_acpi_eval_object()after error detection Delete a variable inamdgpu_cgs_acpi_eval_object()
Delete an unnecessary variable initialisation inamdgpu_cgs_acpi_eval_object()Change assignment for a variable inamdgpu_cgs_acpi_eval_object()Change assignment for a buffer variable inphm_dispatch_table()Delete an unnecessary variable initialisation inphm_dispatch_table()drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 28 ++++++++++------------ drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 4 +--- .../gpu/drm/amd/powerplay/hwmgr/functiontables.c | 12 ++++------ 3 files changed, 19 insertions(+), 25 deletions(-)
Re: [PATCH 0/8] drm/amdgpu: Fine-tuning for three function implementations
Quoted 15 lines · Christian König
Am 16.07.2016 um 16:33 schrieb SF Markus Elfring:
Quoted 6 lines
From: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 16:23:21 +0200Further update suggestions were taken into account after patches were applied from static source code analysis.
Small coding style nit pick on patch #7:
Review
Quoted 4 lines
(quoted diff) +2
-1- } + } else + temp_storage = NULL;
Quoted 6 lines
When an "if" has "{" and "}" the else should also use them even when it is only one line.
With that fixed the whole series is Reviewed-by: Christian König <[email protected]>, but as Walter Harms pointed out as well there are a couple of other things we could make more as well.
Applied the series except patch 2 was which already fixed by an earlier patch.
Thanks!
Alex
Quoted 25 lines
Regards,
Christian.Quoted 14 lines
Markus Elfring (8):
Delete an unnecessary check beforedrm_gem_object_unreference_unlocked()
Delete unnecessary checks before the function call "kfree" One function call less inamdgpu_cgs_acpi_eval_object()after error
detection
Delete a variable inamdgpu_cgs_acpi_eval_object()
Delete an unnecessary variable initialisation inamdgpu_cgs_acpi_eval_object()
Change assignment for a variable inamdgpu_cgs_acpi_eval_object()Change assignment for a buffer variable inphm_dispatch_table()Delete an unnecessary variable initialisation inphm_dispatch_table()Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 28 ++++++++++------------ drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 4 +--- .../gpu/drm/amd/powerplay/hwmgr/functiontables.c | 12 ++++------ 3 files changed, 19 insertions(+), 25 deletions(-)
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/1 ALSA: hda: Delete an unnecessary check before the function call "snd_info_free_entry"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 11:15:28 +0200
The snd_info_free_entry() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- sound/pci/hda/patch_hdmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/hda/patch_hdmi.c +1 -1
@@ -591,7 +591,7 @@ static int eld_proc_new(struct hdmi_spec_per_pin *per_pin, int index)static void eld_proc_free (struct hdmi_spec_per_pin *per_pin) { -if (!per_pin->codec->bus->shutdown && per_pin->proc_entry) { +if (!per_pin->codec->bus->shutdown) {snd_info_free_entry (per_pin->proc_entry); per_pin->proc_entry =NULL ; }
Signature · 1 line
2.4.4
Takashi Iwai
AppliedRe: [PATCH] ALSA: hda: Delete an unnecessary check before the function call "snd_info_free_entry"
At Sun, 28 Jun 2015 11:21:36 +0200,
Quoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 11:15:28 +0200The
snd_info_free_entry()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied, thanks.
Takashi
Quoted 20 lines
--- sound/pci/hda/patch_hdmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)sound/pci/hda/patch_hdmi.c +1
-1@@ -591,7 +591,7 @@ static int eld_proc_new(struct hdmi_spec_per_pin *per_pin, int index)static void eld_proc_free (struct hdmi_spec_per_pin *per_pin) { -if (!per_pin->codec->bus->shutdown && per_pin->proc_entry) { +if (!per_pin->codec->bus->shutdown) {snd_info_free_entry (per_pin->proc_entry); per_pin->proc_entry =NULL ; }Signature · 1 line
2.4.4
PATCH 1/1 video: fbdev: omap2: displays-new: Delete a check before backlight_device_unregister()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 14:30:17 +0200
The backlight_device_unregister() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/video/fbdev/omap2/displays-new/panel-dsi-cm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/video/fbdev/omap2/displays-new/panel-dsi-cm.c +1 -2
@@ -1323,8 +1323,7 @@ static int dsicm_probe(struct platform_device *pdev)return 0 ; err_sysfs_create: -if (bldev !=NULL ) -backlight_device_unregister (bldev); +backlight_device_unregister (bldev); err_bl:destroy_workqueue (ddata->workqueue); err_reg:
Signature · 1 line
2.4.4
PATCH 1/1 USB-mxuport: Delete an unnecessary check before the function call "release_firmware"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 14:59:04 +0200
The release_firmware() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/usb/serial/mxuport.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/serial/mxuport.c +1 -2
@@ -1101,8 +1101,7 @@ static int mxuport_probe(struct usb_serial *serial,*/ usb_set_serial_data (serial, (void *)id->driver_info); out: -if (fw_p) -release_firmware (fw_p); +release_firmware (fw_p);return err; }
Signature · 1 line
2.4.4
Johan Hovold
maintainerRe: [PATCH] USB-mxuport: Delete an unnecessary check before the function call "release_firmware"
Quoted 18 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 14:59:04 +0200The
release_firmware()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/usb/serial/mxuport.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/usb/serial/mxuport.c +0
-0
drivers/usb/serial/mxuport.c static int mxuport_probe(struct usb_serial *serial, · line 1106
Quoted 8 lines
drivers/usb/serial/mxuport.c +1
-2@@ -1101,8 +1101,7 @@ static int mxuport_probe(struct usb_serial *serial,*/ usb_set_serial_data (serial, (void *)id->driver_info); out: -if (fw_p) -release_firmware (fw_p); +release_firmware (fw_p);return err; }
You sent the exact same patch last year and it was rejected then as it does not improve readability:
https://www.marc.info/?l=linux-usb&m=141682024201419&w=3
So I'll drop this one again.
Johan
PATCH 1/1 iommu/arm-smmu: Delete an unnecessary check before the function call "free_io_pgtable_ops"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 15:55:11 +0200
The free_io_pgtable_ops() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/iommu/arm-smmu-v3.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iommu/arm-smmu-v3.c +1 -2
@@ -1389,8 +1389,7 @@ static void arm_smmu_domain_free(struct iommu_domain *domain)struct arm_smmu_domain *smmu_domain =to_smmu_domain (domain);struct arm_smmu_device *smmu = smmu_domain->smmu; -if (smmu_domain->pgtbl_ops) -free_io_pgtable_ops (smmu_domain->pgtbl_ops); +free_io_pgtable_ops (smmu_domain->pgtbl_ops);/* Free the CD and ASID, if we allocated them */ if (smmu_domain->stage =ARM_SMMU_DOMAIN_S1 ) {
Signature · 1 line
2.4.4
PATCH 1/1 iommu/arm-smmu: Delete an unnecessary check before free_io_pgtable_ops()
From: Markus Elfring <[email protected]>
Date: Fri, 6 Nov 2015 18:32:41 +0100
The free_io_pgtable_ops() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/iommu/arm-smmu.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/iommu/arm-smmu.c +1 -3
@@ -945,9 +945,7 @@ static void arm_smmu_destroy_domain_context(struct iommu_domain *domain)free_irq (irq, domain); } -if (smmu_domain->pgtbl_ops) -free_io_pgtable_ops (smmu_domain->pgtbl_ops); - +free_io_pgtable_ops (smmu_domain->pgtbl_ops);__arm_smmu_free_bitmap (smmu->context_map, cfg->cbndx); }
Signature · 1 line
2.6.2
PATCH 1/1 PCI-iproc: Delete unnecessary checks before two function calls
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 16:42:04 +0200
The functions phy_exit() and phy_power_off() test whether their argument is NULL and then return immediately.
Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/pci/host/pcie-iproc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/pci/host/pcie-iproc.c +2 -5
@@ -239,12 +239,9 @@ err_rm_root_bus:pci_remove_root_bus (bus); err_power_off_phy: -if (pcie->phy) -phy_power_off (pcie->phy); +phy_power_off (pcie->phy); err_exit_phy: -if (pcie->phy) -phy_exit (pcie->phy); - +phy_exit (pcie->phy);return ret; }EXPORT_SYMBOL (iproc_pcie_setup);
Signature · 1 line
2.4.4
Ray Jui
maintainerRe: [PATCH] PCI-iproc: Delete unnecessary checks before two function calls
Hi Markus,
Quoted 24 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 16:42:04 +0200The functions
phy_exit()andphy_power_off()test whether their argument is NULL and then return immediately.
Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/pci/host/pcie-iproc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/pci/host/pcie-iproc.c +0
-1@@ -239,12 +239,9 @@ err_rm_root_bus:pci_remove_root_bus (bus); err_power_off_phy: -if (pcie->phy)
drivers/pci/host/pcie-iproc.c err_rm_root_bus: · line 247
Quoted 10 lines
drivers/pci/host/pcie-iproc.c +2
-4-phy_power_off (pcie->phy); +phy_power_off (pcie->phy); err_exit_phy: -if (pcie->phy) -phy_exit (pcie->phy); - +phy_exit (pcie->phy);return ret; }EXPORT_SYMBOL (iproc_pcie_setup);
Thanks for catching this. Could you please help to make similar changes to both phy_init and phy_power_on calls in the driver, to make it consistent?
Thanks,
Ray
Bjorn Helgaas
maintainerRe: [PATCH] PCI-iproc: Delete unnecessary checks before two function calls
In reply to SF Markus ElfringQuoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 16:42:04 +0200The functions
phy_exit()andphy_power_off()test whether their argument is NULL and then return immediately.
Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
I haven't seen a followup to Ray's review, but in the interest of making progress, I updated and applied the patch as appended. I also reviewed other phy_*() calls under drivers/pci, and they all look OK (with no unnecessary tests for NULL).
This is on the pci/host-iproc branch for v4.3.
Quoted 25 lines
--- drivers/pci/host/pcie-iproc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/pci/host/pcie-iproc.c +2
-5@@ -239,12 +239,9 @@ err_rm_root_bus:pci_remove_root_bus (bus); err_power_off_phy: -if (pcie->phy) -phy_power_off (pcie->phy); +phy_power_off (pcie->phy); err_exit_phy: -if (pcie->phy) -phy_exit (pcie->phy); - +phy_exit (pcie->phy);return ret; }EXPORT_SYMBOL (iproc_pcie_setup);Signature · 1 line
2.4.4
commit 55b5e16332eb9ffc1cbaf975585f4521417ab427
Author: Markus Elfring <[email protected]> Date: Sun Jun 28 16:42:04 2015 +0200
PCI: iproc: Delete unnecessary checks before phy calls
The functions phy_exit() and phy_power_off() test whether their argument is NULL and then return immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
drivers/pci/host/pcie-iproc.c +13 -21
@@ -191,19 +191,16 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res)if (!pcie || !pcie->dev || !pcie->base)return -EINVAL ; -if (pcie->phy) { - ret =phy_init (pcie->phy); -if (ret) { -dev_err (pcie->dev,"unable to initialize PCIe PHY\n" ); -return ret; - } - - ret =phy_power_on (pcie->phy); -if (ret) { -dev_err (pcie->dev,"unable to power on PCIe PHY\n" ); - goto err_exit_phy; - } + ret =phy_init (pcie->phy); +if (ret) { +dev_err (pcie->dev,"unable to initialize PCIe PHY\n" ); +return ret; + } + ret =phy_power_on (pcie->phy); +if (ret) { +dev_err (pcie->dev,"unable to power on PCIe PHY\n" ); + goto err_exit_phy; }iproc_pcie_reset (pcie);
@@ -239,12 +236,9 @@ err_rm_root_bus:pci_remove_root_bus (bus); err_power_off_phy: -if (pcie->phy) -phy_power_off (pcie->phy); +phy_power_off (pcie->phy); err_exit_phy: -if (pcie->phy) -phy_exit (pcie->phy); - +phy_exit (pcie->phy);return ret; }EXPORT_SYMBOL (iproc_pcie_setup);
@@ -254,10 +248,8 @@ int iproc_pcie_remove(struct iproc_pcie *pcie)pci_stop_root_bus (pcie->root_bus);pci_remove_root_bus (pcie->root_bus); -if (pcie->phy) { -phy_power_off (pcie->phy); -phy_exit (pcie->phy); - } +phy_power_off (pcie->phy); +phy_exit (pcie->phy);return 0 ; }
Ray Jui
maintainerRe: [PATCH] PCI-iproc: Delete unnecessary checks before two function calls
Hi Bjorn,
Quoted 10 lines · Bjorn Helgaas
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 16:42:04 +0200The functions
phy_exit()andphy_power_off()test whether their argument is NULL and then return immediately.
Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Quoted 9 lines
Quoted 1 line
Signed-off-by Markus Elfring <[email protected]>I haven't seen a followup to Ray's review, but in the interest of making progress, I updated and applied the patch as appended. I also reviewed other phy_*() calls under
drivers/pci, and they all look OK (with no unnecessary tests for NULL).This is on the pci/host-iproc branch for v4.3.
Hmmm....I searched my mailbox but cannot find an email with this patch (while I remember I reviewed and commented on the initial version of this patch). It must have gone into some sub-folder or deleted by me by accident. My bad.
Nevertheless,the current patch looks good to me!
Thanks,
Ray
Quoted 105 lines
Quoted 25 lines
--- drivers/pci/host/pcie-iproc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/pci/host/pcie-iproc.c +2
-5@@ -239,12 +239,9 @@ err_rm_root_bus:pci_remove_root_bus (bus); err_power_off_phy: -if (pcie->phy) -phy_power_off (pcie->phy); +phy_power_off (pcie->phy); err_exit_phy: -if (pcie->phy) -phy_exit (pcie->phy); - +phy_exit (pcie->phy);return ret; }EXPORT_SYMBOL (iproc_pcie_setup);Signature · 1 line
2.4.4commit
55b5e16332eb9ffc1cbaf975585f4521417ab427Author: Markus Elfring <[email protected]> Date: Sun Jun 28 16:42:04 2015 +0200PCI: iproc: Delete unnecessary checks before phy calls
The functions
phy_exit()andphy_power_off()test whether their argument is NULL and then return immediately. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
[bhelgaas: also phy_init() and phy_power_on(), as Ray Jui suggested][bhelgaas: also remove tests in iproc_pcie_remove()]Signed-off-by Markus Elfring <[email protected]>Signed-off-by Bjorn Helgaas <[email protected]>drivers/pci/host/pcie-iproc.c +13
-21@@ -191,19 +191,16 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res)if (!pcie || !pcie->dev || !pcie->base)return -EINVAL ; -if (pcie->phy) { - ret =phy_init (pcie->phy); -if (ret) { -dev_err (pcie->dev,"unable to initialize PCIe PHY\n" ); -return ret; - } - - ret =phy_power_on (pcie->phy); -if (ret) { -dev_err (pcie->dev,"unable to power on PCIe PHY\n" ); - goto err_exit_phy; - } + ret =phy_init (pcie->phy); +if (ret) { +dev_err (pcie->dev,"unable to initialize PCIe PHY\n" ); +return ret; + } + ret =phy_power_on (pcie->phy); +if (ret) { +dev_err (pcie->dev,"unable to power on PCIe PHY\n" ); + goto err_exit_phy; }iproc_pcie_reset (pcie);@@ -239,12 +236,9 @@ err_rm_root_bus:pci_remove_root_bus (bus); err_power_off_phy: -if (pcie->phy) -phy_power_off (pcie->phy); +phy_power_off (pcie->phy); err_exit_phy: -if (pcie->phy) -phy_exit (pcie->phy); - +phy_exit (pcie->phy);return ret; }EXPORT_SYMBOL (iproc_pcie_setup);@@ -254,10 +248,8 @@ int iproc_pcie_remove(struct iproc_pcie *pcie)pci_stop_root_bus (pcie->root_bus);pci_remove_root_bus (pcie->root_bus); -if (pcie->phy) { -phy_power_off (pcie->phy); -phy_exit (pcie->phy); - } +phy_power_off (pcie->phy); +phy_exit (pcie->phy);return 0 ; }
Bjorn Helgaas
maintainerRe: [PATCH] PCI-iproc: Delete unnecessary checks before two function calls
Quoted 23 lines · Ray Jui
Hi Bjorn,
Quoted 10 lines · Bjorn Helgaas
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 16:42:04 +0200The functions
phy_exit()andphy_power_off()test whether their argument is NULL and then return immediately.
Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Quoted 9 lines
Quoted 1 line
Signed-off-by Markus Elfring <[email protected]>I haven't seen a followup to Ray's review, but in the interest of making progress, I updated and applied the patch as appended. I also reviewed other phy_*() calls under
drivers/pci, and they all look OK (with no unnecessary tests for NULL).This is on the pci/host-iproc branch for v4.3.
Quoted 6 lines
Hmmm....I searched my mailbox but cannot find an email with this patch (while I remember I reviewed and commented on the initial version of this patch). It must have gone into some sub-folder or deleted by me by accident. My bad.
Nevertheless,the current patch looks good to me!
Thanks for checking it out! Can I add your Reviewed-by to the patch below?
Quoted 79 lines
Quoted 79 lines
commit
55b5e16332eb9ffc1cbaf975585f4521417ab427Author: Markus Elfring <[email protected]> Date: Sun Jun 28 16:42:04 2015 +0200PCI: iproc: Delete unnecessary checks before phy calls
The functions
phy_exit()andphy_power_off()test whether their argument is NULL and then return immediately. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
[bhelgaas: also phy_init() and phy_power_on(), as Ray Jui suggested][bhelgaas: also remove tests in iproc_pcie_remove()]Signed-off-by Markus Elfring <[email protected]>Signed-off-by Bjorn Helgaas <[email protected]>drivers/pci/host/pcie-iproc.c +13
-21@@ -191,19 +191,16 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res)if (!pcie || !pcie->dev || !pcie->base)return -EINVAL ; -if (pcie->phy) { - ret =phy_init (pcie->phy); -if (ret) { -dev_err (pcie->dev,"unable to initialize PCIe PHY\n" ); -return ret; - } - - ret =phy_power_on (pcie->phy); -if (ret) { -dev_err (pcie->dev,"unable to power on PCIe PHY\n" ); - goto err_exit_phy; - } + ret =phy_init (pcie->phy); +if (ret) { +dev_err (pcie->dev,"unable to initialize PCIe PHY\n" ); +return ret; + } + ret =phy_power_on (pcie->phy); +if (ret) { +dev_err (pcie->dev,"unable to power on PCIe PHY\n" ); + goto err_exit_phy; }iproc_pcie_reset (pcie);@@ -239,12 +236,9 @@ err_rm_root_bus:pci_remove_root_bus (bus); err_power_off_phy: -if (pcie->phy) -phy_power_off (pcie->phy); +phy_power_off (pcie->phy); err_exit_phy: -if (pcie->phy) -phy_exit (pcie->phy); - +phy_exit (pcie->phy);return ret; }EXPORT_SYMBOL (iproc_pcie_setup);@@ -254,10 +248,8 @@ int iproc_pcie_remove(struct iproc_pcie *pcie)pci_stop_root_bus (pcie->root_bus);pci_remove_root_bus (pcie->root_bus); -if (pcie->phy) { -phy_power_off (pcie->phy); -phy_exit (pcie->phy); - } +phy_power_off (pcie->phy); +phy_exit (pcie->phy);return 0 ; }
Re: [PATCH] PCI-iproc: Delete unnecessary checks before two function calls
Quoted 24 lines · Bjorn Helgaas
Quoted 23 lines · Ray Jui
Hi Bjorn,
Quoted 19 lines · Bjorn Helgaas
Quoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 16:42:04 +0200The functions
phy_exit()andphy_power_off()test whether their argument is NULL and then return immediately.
Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>I haven't seen a followup to Ray's review, but in the interest of making progress, I updated and applied the patch as appended. I also reviewed other phy_*() calls under
drivers/pci, and they all look OK (with no unnecessary tests for NULL).This is on the pci/host-iproc branch for v4.3.
Quoted 9 lines
Quoted 6 lines
Hmmm....I searched my mailbox but cannot find an email with this patch (while I remember I reviewed and commented on the initial version of this patch). It must have gone into some sub-folder or deleted by me by accident. My bad.
Nevertheless,the current patch looks good to me!
Thanks for checking it out! Can I add your Reviewed-by to the patch below?
Sure thanks!
Ray
cover vfio: powerpc/spapr: Deletion of an unnecessary check
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Another update suggestion was taken into account after a patch was applied from static source code analysis.
Markus Elfring (2):
Delete an unnecessary check before the function call "kfree" One function call less in tce_iommu_attach_group() after kzalloc() failure
drivers/vfio/vfio_iommu_spapr_tce.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
2.4.4
PATCH 1/2 vfio: powerpc/spapr: Delete an unnecessary check before the function call "kfree"
From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 17:43:48 +0200
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/vfio/vfio_iommu_spapr_tce.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vfio/vfio_iommu_spapr_tce.c +1 -1
@@ -1215,7 +1215,7 @@ static int tce_iommu_attach_group(void *iommu_data, } unlock_exit: -if (ret && tcegrp) +if (ret)kfree (tcegrp);mutex_unlock (&container->lock);
Signature · 1 line
2.4.4
PATCH 2/2 vfio: powerpc/spapr: One function call less in tce_iommu_attach_group() after kzalloc() failure
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 17:58:42 +0200
The kfree() function was called even if a previous memory allocation try failed.
This implementation detail could be improved by the introduction of another jump label.
--- drivers/vfio/vfio_iommu_spapr_tce.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/vfio/vfio_iommu_spapr_tce.c +2 -2
@@ -1200,7 +1200,7 @@ static int tce_iommu_attach_group(void *iommu_data, tcegrp =kzalloc (sizeof (*tcegrp),GFP_KERNEL );if (!tcegrp) { ret = -ENOMEM ; - goto unlock_exit; + goto unlock_container; } if (!table_group->ops || !table_group->ops->take_ownership ||
@@ -1217,7 +1217,7 @@ static int tce_iommu_attach_group(void *iommu_data, unlock_exit:if (ret)kfree (tcegrp); - +unlock_container:mutex_unlock (&container->lock);return ret;
Signature · 1 line
2.4.4
Re: [PATCH 2/2] vfio: powerpc/spapr: One function call less in tce_iommu_attach_group() after kzalloc() failure
Quoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 17:58:42 +0200The
kfree()function was called even if a previous memory allocation try failed.
tcegrp will be NULL and kfree() can handle this just fine (is not it the whole point of this patchset - remove the check and just call kfree() even if the pointer is NULL?). And if you wanted another label, than the existing one should have been renamed to "free_exit" or "free_unlock_exit" and new one would be "unlock_exit".
Quoted 31 lines
This implementation detail could be improved by the introduction of another jump label.
Signed-off-by Markus Elfring <[email protected]>--- drivers/vfio/vfio_iommu_spapr_tce.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/vfio/vfio_iommu_spapr_tce.c +2
-2@@ -1200,7 +1200,7 @@ static int tce_iommu_attach_group(void *iommu_data, tcegrp =kzalloc (sizeof (*tcegrp),GFP_KERNEL );if (!tcegrp) { ret = -ENOMEM ; - goto unlock_exit; + goto unlock_container; } if (!table_group->ops || !table_group->ops->take_ownership ||@@ -1217,7 +1217,7 @@ static int tce_iommu_attach_group(void *iommu_data, unlock_exit:if (ret)kfree (tcegrp); - +unlock_container:mutex_unlock (&container->lock);return ret;
Signature · 1 line
Alexey
Re: vfio: powerpc/spapr: One function call less in tce_iommu_attach_group() after kzalloc() failure
Quoted 1 line
tcegrp will be NULL and
kfree()can handle this just fine
The affected function did not show this API knowledge, did it?
Quoted 2 lines
(is not it the whole point of this patchset
- remove the check and just callkfree()even if the pointer is NULL?).
Partly, yes.
Quoted 1 line
And if you wanted another label,
I suggest this to improve corresponding exception handling.
Quoted 2 lines
than the existing one should have been renamed to "
free_exit" or "free_unlock_exit" and new one would be "unlock_exit".
I chose a smaller change at this place.
I am not familiar enough with other called functions there at the moment. Are the remaining goto statements also update candidates?
Regards,
Markus
Re: vfio: powerpc/spapr: One function call less in tce_iommu_attach_group() after kzalloc() failure
Quoted 3 lines · SF Markus Elfring
Quoted 1 line
tcegrp will be NULL and
kfree()can handle this just fineThe affected function did not show this API knowledge, did it?
but you fixed this in 1/2 :)
Quoted 10 lines
Quoted 4 lines
(is not it the whole point of this patchset
- remove the check and just callkfree()even if the pointer is NULL?).Partly, yes.
Quoted 1 line
And if you wanted another label,
Quoted 7 lines
I suggest this to improve corresponding exception handling.
Quoted 2 lines
than the existing one should have been renamed to "
free_exit" or "free_unlock_exit" and new one would be "unlock_exit".I chose a smaller change at this place.
I'd just drop this patch.
Quoted 2 lines
I am not familiar enough with other called functions there at the moment. Are the remaining goto statements also update candidates?
Signature · 1 line
Alexey
Re: vfio: powerpc/spapr: One function call less in tce_iommu_attach_group() after kzalloc() failure
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
than the existing one should have been renamed to "
free_exit" or "free_unlock_exit" and new one would be "unlock_exit".I chose a smaller change at this place.
I'd just drop this patch.
How do you think about to improve the affected jump labels a bit more there?
Regards,
Markus
Re: vfio: powerpc/spapr: One function call less in tce_iommu_attach_group() after kzalloc() failure
Quoted 9 lines · SF Markus Elfring
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
than the existing one should have been renamed to "
free_exit" or "free_unlock_exit" and new one would be "unlock_exit".I chose a smaller change at this place.
I'd just drop this patch.
How do you think about to improve the affected jump labels a bit more there?
This branch is very unlikely to work ever so I cannot think of any improvement here.
Signature · 1 line
Alexey
PATCH 1/1 net-Liquidio: Delete unnecessary checks before the function call "vfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 29 Jun 2015 12:22:24 +0200
The vfree() function performs also input parameter validation. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/net/ethernet/cavium/liquidio/octeon_device.c | 11 +++-------- drivers/net/ethernet/cavium/liquidio/octeon_droq.c | 4 +--- drivers/net/ethernet/cavium/liquidio/request_manager.c | 3 +-- 3 files changed, 5 insertions(+), 13 deletions(-)
drivers/net/ethernet/cavium/liquidio/octeon_device.c +3 -8
@@ -650,14 +650,12 @@ void octeon_free_device_mem(struct octeon_device *oct)for (i =0 ; i <MAX_OCTEON_OUTPUT_QUEUES ; i++) {/* could check mask as well */ -if (oct->droq[i]) -vfree (oct->droq[i]); +vfree (oct->droq[i]); }for (i =0 ; i <MAX_OCTEON_INSTR_QUEUES ; i++) {/* could check mask as well */ -if (oct->instr_queue[i]) -vfree (oct->instr_queue[i]); +vfree (oct->instr_queue[i]); } i = oct->octeon_id;
@@ -1078,10 +1076,7 @@ octeon_unregister_dispatch_fn(struct octeon_device *oct, u16 opcode, oct->dispatch.count--;spin_unlock_bh (&oct->dispatch.lock); - -if (dfree) -vfree (dfree); - +vfree (dfree);return retval; }
drivers/net/ethernet/cavium/liquidio/octeon_droq.c +1 -3
@@ -216,9 +216,7 @@ int octeon_delete_droq(struct octeon_device *oct, u32 q_no)dev_dbg (&oct->pci_dev->dev,"%s[%d]\n" , __func__, q_no);octeon_droq_destroy_ring_buffers (oct, droq); - -if (droq->recv_buf_list) -vfree (droq->recv_buf_list); +vfree (droq->recv_buf_list);if (droq->info_base_addr) cnnic_free_aligned_dma(oct->pci_dev, droq->info_list,
drivers/net/ethernet/cavium/liquidio/request_manager.c +1 -2
@@ -175,8 +175,7 @@ int octeon_delete_instr_queue(struct octeon_device *oct, u32 iq_no)desc_size CFG_GET_IQ_INSTR_TYPE (CHIP_FIELD (oct ,cn6xxx ,conf )); -if (iq->request_list) -vfree (iq->request_list); +vfree (iq->request_list);if (iq->base_addr) { q_size = iq->max_count * desc_size;
Signature · 1 line
2.4.5
Re: [PATCH] net-Liquidio: Delete unnecessary checks before the function call "vfree"
From: SF Markus Elfring <[email protected]>
Date: Mon, 29 Jun 2015 12:48:16 +0200
Quoted 9 lines
From: Markus Elfring <[email protected]>
Date: Mon, 29 Jun 2015 12:22:24 +0200The
vfree()function performs also input parameter validation. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied.
PATCH 1/1 net-ipv6: Delete an unnecessary check before the function call "free_percpu"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 2 Jul 2015 16:30:24 +0200
The free_percpu() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- net/ipv6/route.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
net/ipv6/route.c +1 -4
@@ -369,10 +369,7 @@ static void ip6_dst_destroy(struct dst_entry *dst)struct inet6_dev *idev;dst_destroy_metrics_generic (dst); - -if (rt->rt6i_pcpu) -free_percpu (rt->rt6i_pcpu); - +free_percpu (rt->rt6i_pcpu);rt6_uncached_list_del (rt); idev = rt->rt6i_idev;
Signature · 1 line
2.4.5
Re: [PATCH] net-ipv6: Delete an unnecessary check before the function call "free_percpu"
From: SF Markus Elfring <[email protected]>
Date: Thu, 02 Jul 2015 16:43:43 +0200
Quoted 9 lines
From: Markus Elfring <[email protected]>
Date: Thu, 2 Jul 2015 16:30:24 +0200The
free_percpu()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied.
PATCH 1/1 net-RDS: Delete an unnecessary check before the function call "module_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 2 Jul 2015 17:58:21 +0200
The module_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- net/rds/transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/rds/transport.c +1 -1
@@ -73,7 +73,7 @@ EXPORT_SYMBOL_GPL(rds_trans_unregister);void rds_trans_put (struct rds_transport *trans) { -if (trans && trans->t_owner) +if (trans)module_put (trans->t_owner); }
Signature · 1 line
2.4.5
Re: [PATCH] net-RDS: Delete an unnecessary check before the function call "module_put"
From: SF Markus Elfring <[email protected]>
Date: Thu, 02 Jul 2015 18:08:19 +0200
Quoted 9 lines
From: Markus Elfring <[email protected]>
Date: Thu, 2 Jul 2015 17:58:21 +0200The
module_put()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied.
PATCH 1/1 netlink: Delete an unnecessary check before the function call "module_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 2 Jul 2015 18:38:12 +0200
The module_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- net/netlink/af_netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netlink/af_netlink.c +1 -1
@@ -158,7 +158,7 @@ static int __netlink_remove_tap(struct netlink_tap *nt) out:spin_unlock (&netlink_tap_lock); -if (found && nt->module) +if (found)module_put (nt->module);return found ?0 : -ENODEV ;
Signature · 1 line
2.4.5
Re: [PATCH] netlink: Delete an unnecessary check before the function call "module_put"
From: SF Markus Elfring <[email protected]>
Date: Thu, 02 Jul 2015 18:45:53 +0200
Quoted 9 lines
From: Markus Elfring <[email protected]>
Date: Thu, 2 Jul 2015 18:38:12 +0200The
module_put()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied.
cover tools/testing/nvdimm: Deletion of two unnecessary checks
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Another update suggestion was taken into account after a patch was applied from static source code analysis.
Markus Elfring (2):
Delete an unnecessary check before the function call "vfree" Improve error detection in __test_alloc()
tools/testing/nvdimm/test/nfit.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
Signature · 1 line
2.4.5
PATCH 1/2 tools/testing/nvdimm: Delete an unnecessary check before the function call "vfree"
From: Markus Elfring <[email protected]>
Date: Thu, 2 Jul 2015 19:24:27 +0200
The vfree() function performs also input parameter validation. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- tools/testing/nvdimm/test/nfit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/nvdimm/test/nfit.c +1 -1
@@ -270,7 +270,7 @@ static void *__test_alloc(struct nfit_test *t, size_t size, dma_addr_t *dma, err:if (buf && !is_vmalloc_addr (buf))dma_free_coherent (dev, size, buf, *dma); -else if (buf) +else vfree (buf);kfree (res);kfree (nfit_res);
Signature · 1 line
2.4.5
PATCH 2/2 tools/testing/nvdimm: Improve error detection in __test_alloc()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 2 Jul 2015 20:45:53 +0200
Three checks were combined at the beginning of the __test_alloc() function. This implementation detail can become safer according to the Linux coding style convention.
* Return directly if a null pointer was passed for the variable "buf". Delete an unnecessary check then.
* Allocate memory for the data structure "nfit_test_resource" only if a previous allocation succeeded.
* Rename a jump label.
--- tools/testing/nvdimm/test/nfit.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
tools/testing/nvdimm/test/nfit.c +13 -8
@@ -244,16 +244,21 @@ static void *__test_alloc(struct nfit_test *t, size_t size, dma_addr_t *dma, void *buf) {struct device *dev = &t->pdev.dev; -struct resource *res =kzalloc (sizeof (*res) *2 ,GFP_KERNEL ); -struct nfit_test_resource *nfit_res =kzalloc (sizeof (*nfit_res), -GFP_KERNEL ); +struct resource *res; +struct nfit_test_resource *nfit_res =NULL ;int rc; -if (!res || !buf || !nfit_res) - goto err; +if (!buf) +return NULL ; + res =kzalloc (sizeof (*res) *2 ,GFP_KERNEL ); +if (!res) + goto free_memory; + nfit_res =kzalloc (sizeof (*nfit_res),GFP_KERNEL ); +if (!nfit_res) + goto free_memory; rc =devm_add_action (dev, release_nfit_res, nfit_res);if (rc) - goto err; + goto free_memory;INIT_LIST_HEAD (&nfit_res->list);memset (buf,0 , size); nfit_res->dev = dev;
@@ -267,8 +272,8 @@ static void *__test_alloc(struct nfit_test *t, size_t size, dma_addr_t *dma,spin_unlock (&nfit_test_lock);return nfit_res->buf; - err: -if (buf && !is_vmalloc_addr (buf)) +free_memory: +if (!is_vmalloc_addr (buf))dma_free_coherent (dev, size, buf, *dma);else vfree (buf);
Signature · 1 line
2.4.5
PATCH 1/1 kernel-sched: Delete an unnecessary check before unregister_sysctl_table()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 4 Jul 2015 09:06:32 +0200
The unregister_sysctl_table() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- kernel/sched/core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/sched/core.c +1 -2
@@ -5298,8 +5298,7 @@ static void register_sched_domain_sysctl(void)/* may be called multiple times per register */ static void unregister_sched_domain_sysctl (void ) { -if (sd_sysctl_header) -unregister_sysctl_table (sd_sysctl_header); +unregister_sysctl_table (sd_sysctl_header); sd_sysctl_header =NULL ;if (sd_ctl_dir[0 ].child)sd_free_ctl_entry (&sd_ctl_dir[0 ].child);
Signature · 1 line
2.4.5
tip-bot for Markus Elfring
merge bot[tip:sched/core] sched, sysctl: Delete an unnecessary check before unregister_sysctl_table()
sched, sysctl: Delete an unnecessary check before unregister_sysctl_table()
Commit-ID: 781b0203423c228b100aaaf169c77b2b556f8a49 Gitweb: http://git.kernel.org/tip/781b0203423c228b100aaaf169c77b2b556f8a49 Author: Markus Elfring <[email protected]> AuthorDate: Sat, 4 Jul 2015 09:06:32 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 3 Aug 2015 12:21:21 +0200
sched, sysctl: Delete an unnecessary check before unregister_sysctl_table()
The unregister_sysctl_table() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- kernel/sched/core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/sched/core.c +1 -2
@@ -5311,8 +5311,7 @@ static void register_sched_domain_sysctl(void)/* may be called multiple times per register */ static void unregister_sched_domain_sysctl (void ) { -if (sd_sysctl_header) -unregister_sysctl_table (sd_sysctl_header); +unregister_sysctl_table (sd_sysctl_header); sd_sysctl_header =NULL ;if (sd_ctl_dir[0 ].child)sd_free_ctl_entry (&sd_ctl_dir[0 ].child);
PATCH 1/1 GPU-DRM: Delete an unnecessary check before drm_property_unreference_blob()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 5 Jul 2015 21:55:10 +0200
The drm_property_unreference_blob() function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/drm_crtc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/drm_crtc.c +1 -3
@@ -4469,9 +4469,7 @@ static int drm_property_replace_global_blob(struct drm_device *dev, goto err_created; } -if (old_blob) -drm_property_unreference_blob (old_blob); - +drm_property_unreference_blob (old_blob); *replace = new_blob;return 0 ;
Signature · 1 line
2.4.5
Re: [PATCH] GPU-DRM: Delete an unnecessary check before drm_property_unreference_blob()
Quoted 11 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 5 Jul 2015 21:55:10 +0200The
drm_property_unreference_blob()function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Quoted 28 lines
--- drivers/gpu/drm/drm_crtc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/gpu/drm/drm_crtc.c +1
-3@@ -4469,9 +4469,7 @@ static int drm_property_replace_global_blob(structdrm_device *dev, goto err_created; } -if (old_blob) -drm_property_unreference_blob (old_blob); - +drm_property_unreference_blob (old_blob); *replace = new_blob;return 0;--
2.4.5_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Best regards Junwang Zhao Microprocessor Research and Develop Center Department of Computer Science &Technology Peking University Beijing, 100871, PRC
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Daniel Vetter
AppliedRe: [PATCH] GPU-DRM: Delete an unnecessary check before drm_property_unreference_blob()
Quoted 10 lines · John Hunter
Quoted 7 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 5 Jul 2015 21:55:10 +0200The
drm_property_unreference_blob()function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.
Quoted 6 lines
Quoted 4 lines
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>Reviewed-by Zhao Junwang <[email protected]>
Applied to topic/drm-misc, thanks.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
PATCH 1/1 GPU-DRM: Delete unnecessary checks before drm_property_unreference_blob()
From: Markus Elfring <[email protected]>
Date: Fri, 6 Nov 2015 12:03:46 +0100
The drm_property_unreference_blob() function tests whether its argument is NULL and then returns immediately.
Thus the tests around the calls are not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/drm_atomic.c | 9 +++------ drivers/gpu/drm/drm_atomic_helper.c | 5 ++--- 2 files changed, 5 insertions(+), 9 deletions(-)
drivers/gpu/drm/drm_atomic.c +3 -6
@@ -316,8 +316,7 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state,if (mode &&memcmp (&state->mode, mode,sizeof (*mode)) ==0 )return 0 ; -if (state->mode_blob) -drm_property_unreference_blob (state->mode_blob); +drm_property_unreference_blob (state->mode_blob); state->mode_blob =NULL ;if (mode) {
@@ -363,8 +362,7 @@ int drm_atomic_set_mode_prop_for_crtc(struct drm_crtc_state *state,if (blob == state->mode_blob)return 0 ; -if (state->mode_blob) -drm_property_unreference_blob (state->mode_blob); +drm_property_unreference_blob (state->mode_blob); state->mode_blob =NULL ;if (blob) {
@@ -419,8 +417,7 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc,struct drm_property_blob *mode =drm_property_lookup_blob (dev, val); ret =drm_atomic_set_mode_prop_for_crtc (state, mode); -if (mode) -drm_property_unreference_blob (mode); +drm_property_unreference_blob (mode);return ret; }else if (crtc->funcs->atomic_set_property)
drivers/gpu/drm/drm_atomic_helper.c +2 -3
@@ -2173,7 +2173,7 @@ EXPORT_SYMBOL(drm_atomic_helper_connector_dpms);*/ void drm_atomic_helper_crtc_reset (struct drm_crtc *crtc) { -if (crtc->state && crtc->state->mode_blob) +if (crtc->state)drm_property_unreference_blob (crtc->state->mode_blob);kfree (crtc->state); crtc->state =kzalloc (sizeof (*crtc->state),GFP_KERNEL );
@@ -2241,8 +2241,7 @@ EXPORT_SYMBOL(drm_atomic_helper_crtc_duplicate_state);void __drm_atomic_helper_crtc_destroy_state (struct drm_crtc *crtc,struct drm_crtc_state *state) { -if (state->mode_blob) -drm_property_unreference_blob (state->mode_blob); +drm_property_unreference_blob (state->mode_blob); }EXPORT_SYMBOL (__drm_atomic_helper_crtc_destroy_state);
Signature · 1 line
2.6.2
Daniel Vetter
AppliedRe: [PATCH] GPU-DRM: Delete unnecessary checks before drm_property_unreference_blob()
Quoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 6 Nov 2015 12:03:46 +0100The
drm_property_unreference_blob()function tests whether its argument is NULL and then returns immediately.
Thus the tests around the calls are not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied to drm-misc, thanks.
-Daniel
Quoted 64 lines
--- drivers/gpu/drm/drm_atomic.c | 9 +++------ drivers/gpu/drm/drm_atomic_helper.c | 5 ++--- 2 files changed, 5 insertions(+), 9 deletions(-)drivers/gpu/drm/drm_atomic.c +3
-6@@ -316,8 +316,7 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state,if (mode &&memcmp (&state->mode, mode,sizeof (*mode)) =0 )return 0 ; -if (state->mode_blob) -drm_property_unreference_blob (state->mode_blob); +drm_property_unreference_blob (state->mode_blob); state->mode_blob =NULL ;if (mode) {@@ -363,8 +362,7 @@ int drm_atomic_set_mode_prop_for_crtc(struct drm_crtc_state *state,if (blob = state->mode_blob)return 0 ; -if (state->mode_blob) -drm_property_unreference_blob (state->mode_blob); +drm_property_unreference_blob (state->mode_blob); state->mode_blob =NULL ;if (blob) {@@ -419,8 +417,7 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc, struct drm_property_blob *mode > drm_property_lookup_blob(dev, val); ret =drm_atomic_set_mode_prop_for_crtc (state, mode); -if (mode) -drm_property_unreference_blob (mode); +drm_property_unreference_blob (mode);return ret; }else if (crtc->funcs->atomic_set_property)drivers/gpu/drm/drm_atomic_helper.c +2
-3@@ -2173,7 +2173,7 @@ EXPORT_SYMBOL(drm_atomic_helper_connector_dpms);*/ void drm_atomic_helper_crtc_reset (struct drm_crtc *crtc) { -if (crtc->state && crtc->state->mode_blob) +if (crtc->state)drm_property_unreference_blob (crtc->state->mode_blob);kfree (crtc->state); crtc->state =kzalloc (sizeof (*crtc->state),GFP_KERNEL );@@ -2241,8 +2241,7 @@ EXPORT_SYMBOL(drm_atomic_helper_crtc_duplicate_state);void __drm_atomic_helper_crtc_destroy_state (struct drm_crtc *crtc,struct drm_crtc_state *state) { -if (state->mode_blob) -drm_property_unreference_blob (state->mode_blob); +drm_property_unreference_blob (state->mode_blob); }EXPORT_SYMBOL (__drm_atomic_helper_crtc_destroy_state);Signature · 1 line
2.6.2
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
PATCH 1/1 drm/atomic: Delete an unnecessary check before drm_property_unreference_blob()
From: Markus Elfring <[email protected]>
Date: Wed, 20 Jul 2016 17:54:32 +0200
The drm_property_unreference_blob() function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/drm_atomic.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/drm_atomic.c +1 -2
@@ -404,8 +404,7 @@ drm_atomic_replace_property_blob(struct drm_property_blob **blob,if (old_blob == new_blob)return ; -if (old_blob) -drm_property_unreference_blob (old_blob); +drm_property_unreference_blob (old_blob);if (new_blob)drm_property_reference_blob (new_blob); *blob = new_blob;
Signature · 1 line
2.9.2
Re: [PATCH] drm/atomic: Delete an unnecessary check before drm_property_unreference_blob()
Quoted 19 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 20 Jul 2016 17:54:32 +0200The
drm_property_unreference_blob()function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/gpu/drm/drm_atomic.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpu/drm/drm_atomic.c +0
-0
drivers/gpu/drm/drm_atomic.c drm_atomic_replace_property_blob(struct drm_property_blob **blob, · line 409
Quoted 8 lines
drivers/gpu/drm/drm_atomic.c +1
-2@@ -404,8 +404,7 @@ drm_atomic_replace_property_blob(struct drm_property_blob **blob,if (old_blob = new_blob)return ; -if (old_blob) -drm_property_unreference_blob (old_blob); +drm_property_unreference_blob (old_blob);if (new_blob)drm_property_reference_blob (new_blob);
I wonder whether it'd be worthwhile to add the same check to drm_property_reference_blob to make things symmetric.
Musings aside, I've applied this to drm-misc.
Sean
Quoted 8 lines
drivers/gpu/drm/drm_atomic.c +0
-1*blob = new_blob; --2.9.2
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/1 GPU-DRM-IMX: Delete an unnecessary check before drm_fbdev_cma_restore_mode()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 5 Jul 2015 22:45:23 +0200
The drm_fbdev_cma_restore_mode() function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/imx/imx-drm-core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/imx/imx-drm-core.c +1 -2
@@ -63,8 +63,7 @@ static void imx_drm_driver_lastclose(struct drm_device *drm)#if IS_ENABLED (CONFIG_DRM_IMX_FB_HELPER )struct imx_drm_device *imxdrm = drm->dev_private; -if (imxdrm->fbhelper) -drm_fbdev_cma_restore_mode (imxdrm->fbhelper); +drm_fbdev_cma_restore_mode (imxdrm->fbhelper);#endif }
Signature · 1 line
2.4.5
Re: [PATCH] GPU-DRM-IMX: Delete an unnecessary check before drm_fbdev_cma_restore_mode()
Am Sonntag, den 05.07.2015, 22:50 +0200 schrieb SF Markus Elfring:
Quoted 19 lines
From: Markus Elfring <[email protected]>
Date: Sun, 5 Jul 2015 22:45:23 +0200The
drm_fbdev_cma_restore_mode()function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/gpu/drm/imx/imx-drm-core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpu/drm/imx/imx-drm-core.c +0
-0
drivers/gpu/drm/imx/imx-drm-core.c static void imx_drm_driver_lastclose(struct drm_device *drm) · line 69
Quoted 9 lines
drivers/gpu/drm/imx/imx-drm-core.c +1
-2@@ -63,8 +63,7 @@ static void imx_drm_driver_lastclose(struct drm_device *drm)#if IS_ENABLED (CONFIG_DRM_IMX_FB_HELPER )struct imx_drm_device *imxdrm = drm->dev_private; -if (imxdrm->fbhelper) -drm_fbdev_cma_restore_mode (imxdrm->fbhelper); +drm_fbdev_cma_restore_mode (imxdrm->fbhelper);#endif }
Applied, sorry I missed this before.
regards
Philipp
PATCH 1/1 ALSA: hda: Delete an unnecessary check before the function call "kobject_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 8 Jul 2015 21:26:02 +0200
The kobject_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- sound/hda/hdac_sysfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
sound/hda/hdac_sysfs.c +1 -2
@@ -321,8 +321,7 @@ static void widget_tree_free(struct hdac_device *codec)free_widget_node (*p, &widget_node_group);kfree (tree->nodes); } -if (tree->root) -kobject_put (tree->root); +kobject_put (tree->root);kfree (tree); codec->widgets =NULL ; }
Signature · 1 line
2.4.5
Takashi Iwai
AppliedRe: [PATCH] ALSA: hda: Delete an unnecessary check before the function call "kobject_put"
Quoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 8 Jul 2015 21:26:02 +0200The
kobject_put()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied, thanks.
Takashi
Quoted 21 lines
--- sound/hda/hdac_sysfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)sound/hda/hdac_sysfs.c +1
-2@@ -321,8 +321,7 @@ static void widget_tree_free(struct hdac_device *codec)free_widget_node (*p, &widget_node_group);kfree (tree->nodes); } -if (tree->root) -kobject_put (tree->root); +kobject_put (tree->root);kfree (tree); codec->widgets =NULL ; }Signature · 1 line
2.4.5
PATCH 1/1 i2c-HID: Delete unnecessary checks before the function call "gpiod_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 8 Jul 2015 22:12:25 +0200
The gpiod_put() function performs also input parameter validation by forwarding its single input pointer to the gpiod_free() function. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/hid/i2c-hid/i2c-hid.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/hid/i2c-hid/i2c-hid.c +2 -6
@@ -1048,9 +1048,7 @@ err_pm:pm_runtime_disable (&client->dev); err: -if (ihid->desc) -gpiod_put (ihid->desc); - +gpiod_put (ihid->desc);i2c_hid_free_buffers (ihid);kfree (ihid);return ret;
@@ -1074,9 +1072,7 @@ static int i2c_hid_remove(struct i2c_client *client)if (ihid->bufsize)i2c_hid_free_buffers (ihid); -if (ihid->desc) -gpiod_put (ihid->desc); - +gpiod_put (ihid->desc);kfree (ihid);acpi_dev_remove_driver_gpios (ACPI_COMPANION (&client->dev));
Signature · 1 line
2.4.5
Re: [PATCH] i2c-HID: Delete unnecessary checks before the function call "gpiod_put"
This one deserves some extra review because it introduces a call to:
WARN_ON(extra_checks);
in gpiod_free(). That may or may not matter...
regards,
dan carpenter
Re: [PATCH] i2c-HID: Delete unnecessary checks before the function call "gpiod_put"
In reply to SF Markus ElfringQuoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 8 Jul 2015 22:12:25 +0200The
gpiod_put()function performs also input parameter validation by forwarding its single input pointer to thegpiod_free()function. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
As Dan correctly pointed out, this is not as straightforward as it might seem on a firsr sight, because there is a WARN_ON() that might start triggering in case of !ihid->desc.
Adding Benjamin. I am not applying this without his Ack.
Signature · 2 lines
Jiri Kosina SUSE Labs
Re: [PATCH] i2c-HID: Delete unnecessary checks before the function call "gpiod_put"
Quoted 11 lines · Jiri Kosina
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 8 Jul 2015 22:12:25 +0200The
gpiod_put()function performs also input parameter validation by forwarding its single input pointer to thegpiod_free()function. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Quoted 8 lines
Quoted 1 line
Signed-off-by Markus Elfring <[email protected]>As Dan correctly pointed out, this is not as straightforward as it might seem on a firsr sight, because there is a
WARN_ON()that might start triggering in case of !ihid->desc.Adding Benjamin. I am not applying this without his Ack.
I think the gpiod case is the exception rather than the common rule (most i2c-hid device we saw until recently were using irqs, not gpios). So if I understand correctly, removing the check on ihid->desc would raise a warning for most devices. This is IMO not a good thing, so I would say NACK.
Mika might have a different opinion though.
Cheers,
Benjamin
Re: i2c-HID: Delete unnecessary checks before the function call "gpiod_put"
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
The
gpiod_put()function performs also input parameter validation by forwarding its single input pointer to thegpiod_free()function. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Quoted 8 lines
Quoted 1 line
Signed-off-by Markus Elfring <[email protected]>As Dan correctly pointed out, this is not as straightforward as it might seem on a firsr sight, because there is a
WARN_ON()that might start triggering in case of !ihid->desc.Adding Benjamin. I am not applying this without his Ack.
Quoted 7 lines
I think the gpiod case is the exception rather than the common rule (most i2c-hid device we saw until recently were using irqs, not gpios). So if I understand correctly, removing the check on
ihid->descwould raise a warning for most devices. This is IMO not a good thing, so I would say NACK.Mika might have a different opinion though.
The proposed update candidates are contained in the source file "drivers/hid/i2c-hid/i2c-hid.c" from Linux next-20150708.
* i2c_hid_remove() function:
Can it be tolerated here that the pointer "ihid->desc" might be eventually null?
* i2c_hid_probe() function:
Is this implementation structured in such a way that a pointer for valid data will be usually passed for "ihid->desc" if the statements after the jump label "err" will be reached?
Regards,
Markus
Re: i2c-HID: Delete unnecessary checks before the function call "gpiod_put"
Quoted 26 lines · SF Markus Elfring
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
The
gpiod_put()function performs also input parameter validation by forwarding its single input pointer to thegpiod_free()function. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Quoted 8 lines
Quoted 1 line
Signed-off-by Markus Elfring <[email protected]>As Dan correctly pointed out, this is not as straightforward as it might seem on a firsr sight, because there is a
WARN_ON()that might start triggering in case of !ihid->desc.Adding Benjamin. I am not applying this without his Ack.
Quoted 7 lines
I think the gpiod case is the exception rather than the common rule (most i2c-hid device we saw until recently were using irqs, not gpios). So if I understand correctly, removing the check on
ihid->descwould raise a warning for most devices. This is IMO not a good thing, so I would say NACK.Mika might have a different opinion though.
The proposed update candidates are contained in the source file "
drivers/hid/i2c-hid/i2c-hid.c" from Linux next-20150708.
Quoted 8 lines
*
i2c_hid_remove()function:
Can it be tolerated here that the pointer "ihid->desc" might be eventually null?*
i2c_hid_probe()function:
Is this implementation structured in such a way that a pointer for valid data will be usually passed for "ihid->desc" if the statements after the jump label "err" will be reached?
Again, in both case it is completely normal to have "ihid->desc = NULL" given that this field is only retrieved in case of an ACPI device which does not declares an IRQ but a GPIO. Most ACPI devices I saw are using a simple IRQ, and the OF instantiations of the driver will definitively have ihid->desc null. So I do not want to have a warning for most of i2c-hid devices out there (because I will have to explain that this is completely normal again and again).
Cheers,
Benjamin
Re: i2c-HID: Delete unnecessary checks before the function call "gpiod_put"
Quoted 12 lines
Quoted 11 lines
The proposed update candidates are contained in the source file "
drivers/hid/i2c-hid/i2c-hid.c" from Linux next-20150708.*
i2c_hid_remove()function:
Can it be tolerated here that the pointer "ihid->desc" might be eventually null?*
i2c_hid_probe()function:
Is this implementation structured in such a way that a pointer for valid data will be usually passed for "ihid->desc" if the statements after the jump label "err" will be reached?
Quoted 7 lines
Again, in both case it is completely normal to have "
ihid->desc= NULL" given that this field is only retrieved in case of an ACPI device which does not declares an IRQ but a GPIO. Most ACPI devices I saw are using a simple IRQ, and the OF instantiations of the driver will definitively haveihid->descnull. So I do not want to have a warning for most of i2c-hid devices out there (because I will have to explain that this is completely normal again and again).
Would it make sense to annotate checks before such function calls as "unlikely" then?
Regards,
Markus
Re: i2c-HID: Delete unnecessary checks before the function call "gpiod_put"
Quoted 20 lines · SF Markus Elfring
Quoted 12 lines
Quoted 11 lines
The proposed update candidates are contained in the source file "
drivers/hid/i2c-hid/i2c-hid.c" from Linux next-20150708.*
i2c_hid_remove()function:
Can it be tolerated here that the pointer "ihid->desc" might be eventually null?*
i2c_hid_probe()function:
Is this implementation structured in such a way that a pointer for valid data will be usually passed for "ihid->desc" if the statements after the jump label "err" will be reached?Quoted 7 lines
Again, in both case it is completely normal to have "
ihid->desc= NULL" given that this field is only retrieved in case of an ACPI device which does not declares an IRQ but a GPIO. Most ACPI devices I saw are using a simple IRQ, and the OF instantiations of the driver will definitively haveihid->descnull. So I do not want to have a warning for most of i2c-hid devices out there (because I will have to explain that this is completely normal again and again).
Quoted 3 lines
Would it make sense to annotate checks before such function calls as "unlikely" then?
I don't see the benefits of this right now. These calls are not time critical and it's not because today they are few devices with GPIOs rather than IRQs that it will be the case all the time. You can always submit a patch preventing coccinelle to raise this warning, but maybe a simple comment in the code would be enough.
Cheers,
Benjamin
PATCH 1/1 cdrom: Delete an unnecessary check before unregister_sysctl_table()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 9 Jul 2015 09:52:24 +0200
The unregister_sysctl_table() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/cdrom/cdrom.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/cdrom/cdrom.c +1 -2
@@ -3698,8 +3698,7 @@ static void cdrom_sysctl_register(void)static void cdrom_sysctl_unregister (void ) { -if (cdrom_sysctl_header) -unregister_sysctl_table (cdrom_sysctl_header); +unregister_sysctl_table (cdrom_sysctl_header); }#else /* CONFIG_SYSCTL */
Signature · 1 line
2.4.5
Re: [PATCH] cdrom: Delete an unnecessary check before unregister_sysctl_table()
Quoted 19 lines
From: Markus Elfring <[email protected]>
Date: Thu, 9 Jul 2015 09:52:24 +0200The
unregister_sysctl_table()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/cdrom/cdrom.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/cdrom/cdrom.c +0
-0
drivers/cdrom/cdrom.c static void cdrom_sysctl_register(void) · line 3704
Quoted 9 lines
drivers/cdrom/cdrom.c +1
-2@@ -3698,8 +3698,7 @@ static void cdrom_sysctl_register(void)static void cdrom_sysctl_unregister (void ) { -if (cdrom_sysctl_header) -unregister_sysctl_table (cdrom_sysctl_header); +unregister_sysctl_table (cdrom_sysctl_header); }#else /* CONFIG_SYSCTL */
How do you think about to integrate this update suggestion into another source code repository?
Regards,
Markus
PATCH 1/1 irda: Delete an unnecessary check before the function call "irlmp_unregister_service"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 3 Nov 2015 18:18:37 +0100
The irlmp_unregister_service() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- net/irda/af_irda.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/irda/af_irda.c +1 -2
@@ -2123,8 +2123,7 @@ static int irda_setsockopt(struct socket *sock, int level, int optname, }/* Unregister any old registration */ -if (self->skey) -irlmp_unregister_service (self->skey); +irlmp_unregister_service (self->skey); self->skey =irlmp_register_service ((__u16 ) opt);break ;
Signature · 1 line
2.6.2
Re: [PATCH] irda: Delete an unnecessary check before the function call "irlmp_unregister_service"
From: SF Markus Elfring <[email protected]>
Date: Tue, 3 Nov 2015 18:30:58 +0100
Quoted 9 lines
From: Markus Elfring <[email protected]>
Date: Tue, 3 Nov 2015 18:18:37 +0100The
irlmp_unregister_service()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied.
cover batman-adv: Deletion of a few unnecessary checks
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 3 Nov 2015 21:34:29 +0100
Further update suggestions were taken into account after a patch was applied from static source code analysis.
Markus Elfring (3):
Delete an unnecessary check before the function call "batadv_softif_vlan_free_ref" Split a condition check
Less function calls in batadv_is_ap_isolated() after error detection
net/batman-adv/translation-table.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-)
Signature · 1 line
2.6.2
PATCH 1/3 batman-adv: Delete an unnecessary check before the function call "batadv_softif_vlan_free_ref"
From: Markus Elfring <[email protected]>
Date: Tue, 3 Nov 2015 19:20:34 +0100
The batadv_softif_vlan_free_ref() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- net/batman-adv/translation-table.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/batman-adv/translation-table.c +1 -2
@@ -3336,8 +3336,7 @@ bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst, ret = true; out: -if (vlan) -batadv_softif_vlan_free_ref (vlan); +batadv_softif_vlan_free_ref (vlan);if (tt_global_entry)batadv_tt_global_entry_free_ref (tt_global_entry);if (tt_local_entry)
Signature · 1 line
2.6.2
Marek Lindner
AppliedRe: [B.A.T.M.A.N.] [PATCH 1/3] batman-adv: Delete an unnecessary check before the function call "batadv_softif_vlan_free_ref"
Quoted 7 lines · On Tuesday, November 03, 2015 21:52:58 SF Markus Elfring wrote:
From: Markus Elfring <[email protected]>
Date: Tue, 3 Nov 2015 19:20:34 +0100The
batadv_softif_vlan_free_ref()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
Quoted 6 lines
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- net/batman-adv/translation-table.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Applied in revision bbcbe0f.
Thanks,
Marek
Marek Lindner
AppliedRe: [B.A.T.M.A.N.] [PATCH 1/3] batman-adv: Delete an unnecessary check before the function call "batadv_softif_vlan_free_ref"
In reply to SF Markus ElfringQuoted 7 lines · On Tuesday, November 03, 2015 21:52:58 SF Markus Elfring wrote:
From: Markus Elfring <[email protected]>
Date: Tue, 3 Nov 2015 19:20:34 +0100The
batadv_softif_vlan_free_ref()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
Quoted 6 lines
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- net/batman-adv/translation-table.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Applied in revision bbcbe0f.
Thanks,
Marek
PATCH 2/3 batman-adv: Split a condition check
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 3 Nov 2015 20:41:02 +0100
Let us split a check for a condition at the beginning of the batadv_is_ap_isolated() function so that a direct return can be performed in this function if the variable "vlan" contained a null pointer.
--- net/batman-adv/translation-table.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/batman-adv/translation-table.c +4 -1
@@ -3319,7 +3319,10 @@ bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst,bool ret = false; vlan =batadv_softif_vlan_get (bat_priv, vid); -if (!vlan || !atomic_read (&vlan->ap_isolation)) +if (!vlan) +return false; + +if (!atomic_read (&vlan->ap_isolation)) goto out; tt_local_entry =batadv_tt_local_hash_find (bat_priv, dst, vid);
Signature · 1 line
2.6.2
Marek Lindner
AppliedRe: [B.A.T.M.A.N.] [PATCH 2/3] batman-adv: Split a condition check
Quoted 11 lines · On Tuesday, November 03, 2015 21:54:35 SF Markus Elfring wrote:
From: Markus Elfring <[email protected]>
Date: Tue, 3 Nov 2015 20:41:02 +0100Let us split a check for a condition at the beginning of the
batadv_is_ap_isolated()function so that a direct return can be performed in this function if the variable "vlan" contained a null pointer.Signed-off-by Markus Elfring <[email protected]>--- net/batman-adv/translation-table.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Applied in revision b1199c6.
Thanks,
Marek
Marek Lindner
AppliedRe: [B.A.T.M.A.N.] [PATCH 2/3] batman-adv: Split a condition check
In reply to SF Markus ElfringQuoted 11 lines · On Tuesday, November 03, 2015 21:54:35 SF Markus Elfring wrote:
From: Markus Elfring <[email protected]>
Date: Tue, 3 Nov 2015 20:41:02 +0100Let us split a check for a condition at the beginning of the
batadv_is_ap_isolated()function so that a direct return can be performed in this function if the variable "vlan" contained a null pointer.Signed-off-by Markus Elfring <[email protected]>--- net/batman-adv/translation-table.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Applied in revision b1199c6.
Thanks,
Marek
PATCH 3/3 batman-adv: Less function calls in batadv_is_ap_isolated() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 3 Nov 2015 21:10:51 +0100
The variables "tt_local_entry" and "tt_global_entry" were eventually checked again despite of a corresponding null pointer test before.
Let us avoid this double check by reordering a function call sequence and the better selection of jump targets.
--- net/batman-adv/translation-table.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
net/batman-adv/translation-table.c +9 -12
@@ -3323,27 +3323,24 @@ bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst,return false;if (!atomic_read (&vlan->ap_isolation)) - goto out; + goto vlan_free; tt_local_entry =batadv_tt_local_hash_find (bat_priv, dst, vid);if (!tt_local_entry) - goto out; + goto vlan_free; tt_global_entry =batadv_tt_global_hash_find (bat_priv, src, vid);if (!tt_global_entry) - goto out; + goto local_entry_free; -if (!_batadv_is_ap_isolated (tt_local_entry, tt_global_entry)) - goto out; - - ret = true; +if (_batadv_is_ap_isolated (tt_local_entry, tt_global_entry)) + ret = true; -out: +batadv_tt_global_entry_free_ref (tt_global_entry); +local_entry_free: +batadv_tt_local_entry_free_ref (tt_local_entry); +vlan_free:batadv_softif_vlan_free_ref (vlan); -if (tt_global_entry) -batadv_tt_global_entry_free_ref (tt_global_entry); -if (tt_local_entry) -batadv_tt_local_entry_free_ref (tt_local_entry);return ret; }
Signature · 1 line
2.6.2
Re: [B.A.T.M.A.N.] [PATCH 3/3] batman-adv: Less function calls in batadv_is_ap_isolated() after error detection
Quoted 42 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 3 Nov 2015 21:10:51 +0100The variables "
tt_local_entry" and "tt_global_entry" were eventually checked again despite of a corresponding null pointer test before.
Let us avoid this double check by reordering a function call sequence and the better selection of jump targets.Signed-off-by Markus Elfring <[email protected]>--- net/batman-adv/translation-table.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)net/batman-adv/translation-table.c +5
-8@@ -3323,27 +3323,24 @@ bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst,return false;if (!atomic_read (&vlan->ap_isolation)) - goto out; + goto vlan_free; tt_local_entry =batadv_tt_local_hash_find (bat_priv, dst, vid);if (!tt_local_entry) - goto out; + goto vlan_free; tt_global_entry =batadv_tt_global_hash_find (bat_priv, src, vid);if (!tt_global_entry) - goto out; + goto local_entry_free; -if (!_batadv_is_ap_isolated (tt_local_entry, tt_global_entry)) - goto out; - - ret = true; +if (_batadv_is_ap_isolated (tt_local_entry, tt_global_entry)) + ret = true; -out:
net/batman-adv/translation-table.c bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst, · line 3344
Quoted 10 lines
net/batman-adv/translation-table.c +4
-4+batadv_tt_global_entry_free_ref (tt_global_entry); +local_entry_free: +batadv_tt_local_entry_free_ref (tt_local_entry); +vlan_free:batadv_softif_vlan_free_ref (vlan); -if (tt_global_entry) -batadv_tt_global_entry_free_ref (tt_global_entry); -if (tt_local_entry) -batadv_tt_local_entry_free_ref (tt_local_entry);return ret;
Markus,
if you really want to make this codestyle change, I'd suggest you to go through the whole batman-adv code and apply the same change where needed. It does not make sense to change the codestyle in one spot only.
On top of that, by going through the batman-adv code you might agree that the current style is actually not a bad idea.
Cheers,
Signature · 1 line
Antonio Quartulli
Re: [B.A.T.M.A.N.] [PATCH 3/3] batman-adv: Less function calls in batadv_is_ap_isolated() after error detection
Quoted 6 lines
Quoted 6 lines
net/batman-adv/translation-table.c +4
-1-out: +batadv_tt_global_entry_free_ref (tt_global_entry); +local_entry_free: +batadv_tt_local_entry_free_ref (tt_local_entry); +vlan_free:batadv_softif_vlan_free_ref (vlan);
Quoted 8 lines
net/batman-adv/translation-table.c bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst, · line 3344
Quoted 5 lines
net/batman-adv/translation-table.c +0
-4-if (tt_global_entry) -batadv_tt_global_entry_free_ref (tt_global_entry); -if (tt_local_entry) -batadv_tt_local_entry_free_ref (tt_local_entry);return ret;if you really want to make this codestyle change, I'd suggest you to go through the whole batman-adv code and apply the same change where needed.
Thanks for your interest in similar source code changes.
I would prefer general acceptance for this specific update suggestion before I might invest further software development efforts for the affected network module.
Quoted 1 line
It does not make sense to change the codestyle in one spot only.
I agree in the way that I would be nice if more places can still be improved.
Quoted 2 lines
On top of that, by going through the batman-adv code you might agree that the current style is actually not a bad idea.
I got the impression that the current Linux coding style convention disagrees around the affected jump label selection to some degree, doesn't it?
Regards,
Markus
Sven Eckelmann
maintainerRe: [B.A.T.M.A.N.] [PATCH 3/3] batman-adv: Less function calls in batadv_is_ap_isolated() after error detection
Quoted 6 lines · On Friday 20 November 2015 11:56:39 SF Markus Elfring wrote:
Quoted 2 lines
On top of that, by going through the batman-adv code you might agree that the current style is actually not a bad idea.
I got the impression that the current Linux coding style convention disagrees around the affected jump label selection to some degree, doesn't it?
Yes, see "Chapter 7: Centralized exiting of functions". But your patch doesn't seem to apply anymore. Can you please resent it or mark it correctly in patchwork [1].
There was also another suggestion in the past:
* https://patchwork.open-mesh.org/patch/4081/ [2]
I have prepared a overview of functions and their goto's [3] to make it easier to spot interesting places.
Kind regards,
Sven
[1] https://patchwork.open-mesh.org/patch/4724/
You can find an updated version at
https://git.open-mesh.org/batman-adv.git/patch/1b79cb12821da928b4cf2d116469dfdcbe66d8cd
[2] Update version:
https://git.open-mesh.org/batman-adv.git/commit/28578c9dd0e592f1c69c44ab7723021b1e8c5b28
[3] https://git.open-mesh.org/batman-adv.git/blob/783c827d01b3644ac09a0f32fe4a9dfa8d6debd3:/TODO
PATCH 1/1 batman-adv: Less function calls in batadv_is_ap_isolated() after error detection
From: Markus Elfring <[email protected]>
Date: Fri, 11 Mar 2016 13:10:20 +0100
The variables "tt_local_entry" and "tt_global_entry" were eventually checked again despite of a corresponding null pointer test before.
* Avoid this double check by reordering a function call sequence and the better selection of jump targets.
* Omit the initialisation for these variables at the beginning then.
--- net/batman-adv/translation-table.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)
net/batman-adv/translation-table.c +11 -14
@@ -3403,8 +3403,8 @@ void batadv_tt_local_commit_changes(struct batadv_priv *bat_priv)bool batadv_is_ap_isolated (struct batadv_priv *bat_priv,u8 *src,u8 *dst,unsigned short vid) { -struct batadv_tt_local_entry *tt_local_entry =NULL ; -struct batadv_tt_global_entry *tt_global_entry =NULL ; +struct batadv_tt_local_entry *tt_local_entry; +struct batadv_tt_global_entry *tt_global_entry;struct batadv_softif_vlan *vlan;bool ret = false;
@@ -3413,27 +3413,24 @@ bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst,return false;if (!atomic_read (&vlan->ap_isolation)) - goto out; + goto vlan_put; tt_local_entry =batadv_tt_local_hash_find (bat_priv, dst, vid);if (!tt_local_entry) - goto out; + goto vlan_put; tt_global_entry =batadv_tt_global_hash_find (bat_priv, src, vid);if (!tt_global_entry) - goto out; - -if (!_batadv_is_ap_isolated (tt_local_entry, tt_global_entry)) - goto out; + goto local_entry_put; - ret = true; +if (_batadv_is_ap_isolated (tt_local_entry, tt_global_entry)) + ret = true; -out: +batadv_tt_global_entry_put (tt_global_entry); +local_entry_put: +batadv_tt_local_entry_put (tt_local_entry); +vlan_put:batadv_softif_vlan_put (vlan); -if (tt_global_entry) -batadv_tt_global_entry_put (tt_global_entry); -if (tt_local_entry) -batadv_tt_local_entry_put (tt_local_entry);return ret; }
Signature · 1 line
2.7.2
David Miller
maintainerRe: [PATCH] batman-adv: Less function calls in batadv_is_ap_isolated() after error detection
From: SF Markus Elfring <[email protected]>
Date: Fri, 11 Mar 2016 13:40:56 +0100
Quoted 6 lines
From: Markus Elfring <[email protected]>
Date: Fri, 11 Mar 2016 13:10:20 +0100The variables "
tt_local_entry" and "tt_global_entry" were eventually checked again despite of a corresponding null pointer test before.
Quoted 6 lines
* Avoid this double check by reordering a function call sequence and the better selection of jump targets.
* Omit the initialisation for these variables at the beginning then.
Signed-off-by Markus Elfring <[email protected]>
I am assuming Antonio will take this in via his tree.
Re: [PATCH] batman-adv: Less function calls in batadv_is_ap_isolated() after error detection
Quoted 9 lines · David Miller
From: SF Markus Elfring <[email protected]>
Date: Fri, 11 Mar 2016 13:40:56 +0100Quoted 6 lines
From: Markus Elfring <[email protected]>
Date: Fri, 11 Mar 2016 13:10:20 +0100The variables "
tt_local_entry" and "tt_global_entry" were eventually checked again despite of a corresponding null pointer test before.
Quoted 9 lines
Quoted 6 lines
* Avoid this double check by reordering a function call sequence and the better selection of jump targets.
* Omit the initialisation for these variables at the beginning then.
Signed-off-by Markus Elfring <[email protected]>I am assuming Antonio will take this in via his tree.
Yeah, it will go through our tree. Still under review right now.
Cheers,
Signature · 1 line
Antonio Quartulli
Re: [B.A.T.M.A.N.] [PATCH] batman-adv: Less function calls in batadv_is_ap_isolated() after error detection
In reply to SF Markus ElfringQuoted 6 lines · On Friday 11 March 2016 13:40:56 SF Markus Elfring wrote:
From: Markus Elfring <[email protected]>
Date: Fri, 11 Mar 2016 13:10:20 +0100The variables "
tt_local_entry" and "tt_global_entry" were eventually checked again despite of a corresponding null pointer test before.
Quoted 7 lines
* Avoid this double check by reordering a function call sequence and the better selection of jump targets.
* Omit the initialisation for these variables at the beginning then.
Signed-off-by Markus Elfring <[email protected]>---
See
* https://www.kernel.org/doc/Documentation/SubmittingPatches
Chapter 7: Centralized exiting of functions
* https://plus.google.com/106378716002406849458/posts/dnanfhQ4mHQ
* http://article.gmane.org/gmane.linux.documentation/28552
Kind regards,
Sven
Re: [B.A.T.M.A.N.] batman-adv: Less function calls in batadv_is_ap_isolated() after error detection
In reply to SF Markus ElfringQuoted 9 lines · On Freitag, 11. März 2016 13:40:56 CEST SF Markus Elfring wrote:
From: Markus Elfring <[email protected]>
Date: Fri, 11 Mar 2016 13:10:20 +0100The variables "
tt_local_entry" and "tt_global_entry" were eventually checked again despite of a corresponding null pointer test before.* Avoid this double check by reordering a function call sequence and the better selection of jump targets.
Quoted 7 lines
* Omit the initialisation for these variables at the beginning then.
Signed-off-by Markus Elfring <[email protected]>Reviewed-by Sven Eckelmann <[email protected]>--- net/batman-adv/translation-table.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)
Applied in 58d8ef2dd0c9f7274f0473a1b1d1ffdacdd914f6 [1].
Kind regards,
Sven
[1] https://git.open-mesh.org/batman-adv.git/commit/58d8ef2dd0c9f7274f0473a1b1d1ffdacdd914f6
Re: [B.A.T.M.A.N.] [PATCH 3/3] batman-adv: Less function calls in batadv_is_ap_isolated() after error detection
In reply to SF Markus ElfringQuoted 42 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 3 Nov 2015 21:10:51 +0100The variables "
tt_local_entry" and "tt_global_entry" were eventually checked again despite of a corresponding null pointer test before.
Let us avoid this double check by reordering a function call sequence and the better selection of jump targets.Signed-off-by Markus Elfring <[email protected]>--- net/batman-adv/translation-table.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)net/batman-adv/translation-table.c +5
-8@@ -3323,27 +3323,24 @@ bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst,return false;if (!atomic_read (&vlan->ap_isolation)) - goto out; + goto vlan_free; tt_local_entry =batadv_tt_local_hash_find (bat_priv, dst, vid);if (!tt_local_entry) - goto out; + goto vlan_free; tt_global_entry =batadv_tt_global_hash_find (bat_priv, src, vid);if (!tt_global_entry) - goto out; + goto local_entry_free; -if (!_batadv_is_ap_isolated (tt_local_entry, tt_global_entry)) - goto out; - - ret = true; +if (_batadv_is_ap_isolated (tt_local_entry, tt_global_entry)) + ret = true; -out:
net/batman-adv/translation-table.c bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst, · line 3344
Quoted 10 lines
net/batman-adv/translation-table.c +4
-4+batadv_tt_global_entry_free_ref (tt_global_entry); +local_entry_free: +batadv_tt_local_entry_free_ref (tt_local_entry); +vlan_free:batadv_softif_vlan_free_ref (vlan); -if (tt_global_entry) -batadv_tt_global_entry_free_ref (tt_global_entry); -if (tt_local_entry) -batadv_tt_local_entry_free_ref (tt_local_entry);return ret;
Markus,
if you really want to make this codestyle change, I'd suggest you to go through the whole batman-adv code and apply the same change where needed. It does not make sense to change the codestyle in one spot only.
On top of that, by going through the batman-adv code you might agree that the current style is actually not a bad idea.
Cheers,
Signature · 1 line
Antonio Quartulli
PATCH 1/1 fs-ext4: Delete unnecessary checks before the function call "iput"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 4 Nov 2015 18:48:38 +0100
The iput() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- fs/ext4/resize.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
fs/ext4/resize.c +5 -6
@@ -1942,10 +1942,10 @@ retry: err =ext4_convert_meta_bg (sb, resize_inode);if (err) goto out; -if (resize_inode) { -iput (resize_inode); - resize_inode =NULL ; - } + +iput (resize_inode); + resize_inode =NULL ; +if (n_blocks_count_retry) { n_blocks_count = n_blocks_count_retry; n_blocks_count_retry =0 ;
@@ -2011,8 +2011,7 @@ retry: out:if (flex_gd)free_flex_gd (flex_gd); -if (resize_inode !=NULL ) -iput (resize_inode); +iput (resize_inode);ext4_msg (sb,KERN_INFO ,"resized filesystem to %llu" , n_blocks_count);return err; }
Signature · 1 line
2.6.2
PATCH 1/1 UBIFS: Delete unnecessary checks before the function call "iput"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 4 Nov 2015 20:00:42 +0100
The iput() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- fs/ubifs/recovery.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
fs/ubifs/recovery.c +2 -4
@@ -1331,8 +1331,7 @@ void ubifs_destroy_size_tree(struct ubifs_info *c)struct size_entry *e, *n;rbtree_postorder_for_each_entry_safe (e, n, &c->size_tree, rb) { -if (e->inode) -iput (e->inode); +iput (e->inode);kfree (e); }
@@ -1533,8 +1532,7 @@ int ubifs_recover_size(struct ubifs_info *c) err =fix_size_in_place (c, e);if (err)return err; -if (e->inode) -iput (e->inode); +iput (e->inode); } }
Signature · 1 line
2.6.2
Richard Weinberger
AppliedRe: [PATCH] UBIFS: Delete unnecessary checks before the function call "iput"
Quoted 28 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 4 Nov 2015 20:00:42 +0100The
iput()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- fs/ubifs/recovery.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)fs/ubifs/recovery.c +1
-2@@ -1331,8 +1331,7 @@ void ubifs_destroy_size_tree(struct ubifs_info *c)struct size_entry *e, *n;rbtree_postorder_for_each_entry_safe (e, n, &c->size_tree, rb) { -if (e->inode) -iput (e->inode); +iput (e->inode);kfree (e); }
fs/ubifs/recovery.c int ubifs_recover_size(struct ubifs_info *c) · line 1537
Quoted 8 lines
fs/ubifs/recovery.c +1
-2@@ -1533,8 +1532,7 @@ int ubifs_recover_size(struct ubifs_info *c) err =fix_size_in_place (c, e);if (err)return err; -if (e->inode) -iput (e->inode); +iput (e->inode); } }
Applied!
Signature · 2 lines
Thanks, //richard
PATCH 1/1 sysfs: Delete an unnecessary check before the function call "kernfs_get"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 4 Nov 2015 20:44:50 +0100
The kernfs_get() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- fs/sysfs/group.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/sysfs/group.c +1 -2
@@ -388,8 +388,7 @@ int __compat_only_sysfs_link_entry_to_kobj(struct kobject *kobj,*/ spin_lock (&sysfs_symlink_target_lock); target = target_kobj->sd; -if (target) -kernfs_get (target); +kernfs_get (target);spin_unlock (&sysfs_symlink_target_lock);if (!target)return -ENOENT ;
Signature · 1 line
2.6.2
PATCH 1/1 staging/rdma/hfi1: Delete unnecessary checks before two function calls
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 5 Nov 2015 08:41:00 +0100
The functions "sc_return_credits" and "vfree" perform also input parameter validation. Thus the tests around their calls are not needed.
This issue was detected by using the Coccinelle software.
--- drivers/staging/rdma/hfi1/file_ops.c | 2 +- drivers/staging/rdma/hfi1/user_sdma.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/staging/rdma/hfi1/file_ops.c +1 -1
@@ -313,7 +313,7 @@ static ssize_t hfi1_file_write(struct file *fp, const char __user *data,case HFI1_CMD_SDMA_STATUS_UPD :break ;case HFI1_CMD_CREDIT_UPD : -if (uctxt && uctxt->sc) +if (uctxt)sc_return_credits (uctxt->sc);break ;case HFI1_CMD_TID_UPDATE :
drivers/staging/rdma/hfi1/user_sdma.c +1 -2
@@ -473,8 +473,7 @@ int hfi1_user_sdma_free_queues(struct hfi1_filedata *fd) fd->pq =NULL ; }if (fd->cq) { -if (fd->cq->comps) -vfree (fd->cq->comps); +vfree (fd->cq->comps);kfree (fd->cq); fd->cq =NULL ; }
Signature · 1 line
2.6.2
Re: [PATCH] staging/rdma/hfi1: Delete unnecessary checks before two function calls
drivers/staging/rdma/hfi1/file_ops.c static ssize_t hfi1_file_write(struct file *fp, const char __user *data, · line 317
Quoted 11 lines · SF Markus Elfring
drivers/staging/rdma/hfi1/file_ops.c +1
-1@@ -313,7 +313,7 @@ static ssize_t hfi1_file_write(struct file *fp, const char __user *data,case HFI1_CMD_SDMA_STATUS_UPD :break ;case HFI1_CMD_CREDIT_UPD : -if (uctxt && uctxt->sc) +if (uctxt)sc_return_credits (uctxt->sc);
Relying on hidden sanity checks makes the code harder to read.
regards,
dan carpenter
cover staging: lustre: Deletion of some unnecessary checks
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 5 Nov 2015 13:03:33 +0100
Further update suggestions were taken into account after a patch was applied from static source code analysis.
Markus Elfring (3):
Delete unnecessary checks before two function calls
Delete an unnecessary variable initialisation in class_register_type() Less function calls in class_register_type() after error detection
drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 10 +++----- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 5 ++-- drivers/staging/lustre/lustre/lov/lov_obd.c | 4 +-- drivers/staging/lustre/lustre/obdclass/genops.c | 34 ++++++++++++++----------- 4 files changed, 25 insertions(+), 28 deletions(-)
Signature · 1 line
2.6.2
PATCH 1/3 staging: lustre: Delete unnecessary checks before two function calls
From: Markus Elfring <[email protected]>
Date: Thu, 5 Nov 2015 10:18:45 +0100
The functions kobject_put() and kset_unregister() test whether their argument is NULL and then return immediately.
Thus the tests around their calls are not needed.
This issue was detected by using the Coccinelle software.
--- drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 10 +++------- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 5 ++--- drivers/staging/lustre/lustre/lov/lov_obd.c | 4 +--- drivers/staging/lustre/lustre/obdclass/genops.c | 6 ++---- 4 files changed, 8 insertions(+), 17 deletions(-)
drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +3 -7
@@ -1062,13 +1062,9 @@ static int ldlm_cleanup(void)if (ldlm_state->ldlm_cb_service !=NULL )ptlrpc_unregister_service (ldlm_state->ldlm_cb_service); -if (ldlm_ns_kset) -kset_unregister (ldlm_ns_kset); -if (ldlm_svc_kset) -kset_unregister (ldlm_svc_kset); -if (ldlm_kobj) -kobject_put (ldlm_kobj); - +kset_unregister (ldlm_ns_kset); +kset_unregister (ldlm_svc_kset); +kobject_put (ldlm_kobj);ldlm_debugfs_cleanup ();kfree (ldlm_state);
drivers/staging/lustre/lustre/lmv/lmv_obd.c +2 -3
@@ -240,7 +240,7 @@ static int lmv_connect(const struct lu_env *env,if (data->ocd_connect_flags &OBD_CONNECT_REAL ) rc =lmv_check_connect (obd); -if (rc && lmv->lmv_tgts_kobj) +if (rc)kobject_put (lmv->lmv_tgts_kobj);return rc;
@@ -646,8 +646,7 @@ static int lmv_disconnect(struct obd_export *exp)lmv_disconnect_mdc (obd, lmv->tgts[i]); } -if (lmv->lmv_tgts_kobj) -kobject_put (lmv->lmv_tgts_kobj); +kobject_put (lmv->lmv_tgts_kobj); out_local:/*
drivers/staging/lustre/lustre/lov/lov_obd.c +1 -3
@@ -109,9 +109,7 @@ static void lov_putref(struct obd_device *obd)__lov_del_obd (obd, tgt); } -if (lov->lov_tgts_kobj) -kobject_put (lov->lov_tgts_kobj); - +kobject_put (lov->lov_tgts_kobj); }else {mutex_unlock (&lov->lov_lock); }
drivers/staging/lustre/lustre/obdclass/genops.c +2 -4
@@ -216,8 +216,7 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,return 0 ; failed: -if (type->typ_kobj) -kobject_put (type->typ_kobj); +kobject_put (type->typ_kobj);kfree (type->typ_name);kfree (type->typ_md_ops);kfree (type->typ_dt_ops);
@@ -244,8 +243,7 @@ int class_unregister_type(const char *name)return -EBUSY ; } -if (type->typ_kobj) -kobject_put (type->typ_kobj); +kobject_put (type->typ_kobj);if (!IS_ERR_OR_NULL (type->typ_debugfs_entry))ldebugfs_remove (&type->typ_debugfs_entry);
Signature · 1 line
2.6.2
Re: [PATCH 1/3] staging: lustre: Delete unnecessary checks before two function calls
I don't like these patches because relying on hidden sanity checks makes the code harder to read.
I am CC'd on all these patches because of kernel-janitors and normally I ignore them but this is drivers/staging so I am invested in this code. Feel free to send them to other subsystems though.
regards,
dan carpenter
PATCH 2/3 staging: lustre: Delete an unnecessary variable initialisation in class_register_type()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 5 Nov 2015 10:55:16 +0100
The variable "rc" will be eventually set to an error return code in the class_register_type() function.
Thus let us omit the explicit initialisation at the beginning.
--- drivers/staging/lustre/lustre/obdclass/genops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/obdclass/genops.c +1 -1
@@ -155,7 +155,7 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, struct lu_device_type *ldt) {struct obd_type *type; -int rc =0 ; +int rc;/* sanity check */ LASSERT (strnlen (name,CLASS_MAX_NAME ) <CLASS_MAX_NAME );
Signature · 1 line
2.6.2
Re: [PATCH 2/3] staging: lustre: Delete an unnecessary variable initialisation in class_register_type()
Looks good.
regards,
dan carpenter
PATCH 3/3 staging: lustre: Less function calls in class_register_type() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 5 Nov 2015 12:48:58 +0100
The functions "kfree" and "kobject_put" were called in a few cases by the function "class_register_type" during error handling even if the passed variable contained a null pointer.
This implementation detail could be improved by the adjustment of jump targets.
--- drivers/staging/lustre/lustre/obdclass/genops.c | 26 +++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
drivers/staging/lustre/lustre/obdclass/genops.c +16 -10
@@ -171,13 +171,16 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,return rc; type->typ_dt_ops =kzalloc (sizeof (*type->typ_dt_ops),GFP_NOFS ); +if (!type->typ_dt_ops) + goto free_type; + type->typ_md_ops =kzalloc (sizeof (*type->typ_md_ops),GFP_NOFS ); - type->typ_name =kzalloc (strlen (name) +1 ,GFP_NOFS ); +if (!type->typ_md_ops) + goto free_dt_ops; -if (!type->typ_dt_ops || - !type->typ_md_ops || - !type->typ_name) - goto failed; + type->typ_name =kzalloc (strlen (name) +1 ,GFP_NOFS ); +if (!type->typ_name) + goto free_md_ops; *(type->typ_dt_ops) = *dt_ops;/* md_ops is optional */
@@ -193,20 +196,20 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, rc = type->typ_debugfs_entry ?PTR_ERR (type->typ_debugfs_entry) : -ENOMEM ; type->typ_debugfs_entry =NULL ; - goto failed; + goto free_name; } type->typ_kobj =kobject_create_and_add (type->typ_name, lustre_kobj);if (!type->typ_kobj) { rc = -ENOMEM ; - goto failed; + goto free_name; }if (ldt !=NULL ) { type->typ_lu = ldt; rc =lu_device_type_init (ldt);if (rc !=0 ) - goto failed; + goto put_object; }spin_lock (&obd_types_lock);
@@ -214,12 +217,15 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,spin_unlock (&obd_types_lock);return 0 ; - - failed: +put_object:kobject_put (type->typ_kobj); +free_name:kfree (type->typ_name); +free_md_ops:kfree (type->typ_md_ops); +free_dt_ops:kfree (type->typ_dt_ops); +free_type:kfree (type);return rc; }
Signature · 1 line
2.6.2
Greg Kroah-Hartman
maintainerRe: [PATCH 3/3] staging: lustre: Less function calls in class_register_type() after error detection
Quoted 7 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 5 Nov 2015 12:48:58 +0100The functions "kfree" and "
kobject_put" were called in a few cases by the function "class_register_type" during error handling even if the passed variable contained a null pointer.
Quoted 7 lines
This implementation detail could be improved by the adjustment of jump targets.
Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/lustre/lustre/obdclass/genops.c | 26 +++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
Does not apply to my staging-next branch :(
Re: [PATCH 3/3] staging: lustre: Less function calls in class_register_type() after error detection
Am 25.11.2015 um 17:39 schrieb Greg Kroah-Hartman:
Quoted 11 lines · SF Markus Elfring
Quoted 10 lines
From: Markus Elfring <[email protected]>
Date: Thu, 5 Nov 2015 12:48:58 +0100The functions "kfree" and "
kobject_put" were called in a few cases by the function "class_register_type" during error handling even if the passed variable contained a null pointer.This implementation detail could be improved by the adjustment of jump targets.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/lustre/lustre/obdclass/genops.c | 26 +++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)Does not apply to my staging-next branch :(
I get also a result like the following together with the software "Linux next-20151126". ;-)
elfring@Sonne:~/Projekte/Linux/next-patched> LANG=C git apply ~/Projekte/Bau/Linux/scripts/Coccinelle/deletions1/next/20151102/Flicken/0003-staging-lustre-Less-function-calls-in-class_register.patch
error: patch failed: drivers/staging/lustre/lustre/obdclass/genops.c:214
error: drivers/staging/lustre/lustre/obdclass/genops.c: patch does not apply
Do you try this update suggestion out without integrating the corresponding previous update suggestion "Delete unnecessary checks before two function calls" where I proposed to remove extra checks before a few calls of the function "kobject_put" (which seems to matter for the patch hunk in the shown error message)?
https://lkml.org/lkml/2015/11/5/276
https://www.mail-archive.com/[email protected]/msg1013635.html
Would you like to reject the first update step from this patch series so that I need to adapt my approach to your software design decision?
Regards,
Markus
Greg Kroah-Hartman
maintainerRe: [PATCH 3/3] staging: lustre: Less function calls in class_register_type() after error detection
Quoted 26 lines · SF Markus Elfring
Am 25.11.2015 um 17:39 schrieb Greg Kroah-Hartman:
Quoted 11 lines · SF Markus Elfring
Quoted 10 lines
From: Markus Elfring <[email protected]>
Date: Thu, 5 Nov 2015 12:48:58 +0100The functions "kfree" and "
kobject_put" were called in a few cases by the function "class_register_type" during error handling even if the passed variable contained a null pointer.This implementation detail could be improved by the adjustment of jump targets.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/lustre/lustre/obdclass/genops.c | 26 +++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)Does not apply to my staging-next branch :(
I get also a result like the following together with the software "Linux next-20151126". ;-)
elfring@Sonne:~/Projekte/Linux/next-patched> LANG=C git apply
~/Projekte/Bau/Linux/scripts/Coccinelle/deletions1/next/20151102/Flicken/0003-staging-lustre-Less-function-calls-in-class_register.patch
error: patch failed:drivers/staging/lustre/lustre/obdclass/genops.c:214
error:drivers/staging/lustre/lustre/obdclass/genops.c: patch does not apply
Quoted 6 lines
Do you try this update suggestion out without integrating the corresponding previous update suggestion "Delete unnecessary checks before two function calls" where I proposed to remove extra checks before a few calls of the function "
kobject_put" (which seems to matter for the patch hunk in the shown error message)?
https://lkml.org/lkml/2015/11/5/276
https://www.mail-archive.com/[email protected]/msg1013635.html
I guess so, I don't remember, I don't see any patches from you earlier in my "todo" mbox.
Quoted 2 lines
Would you like to reject the first update step from this patch series so that I need to adapt my approach to your software design decision?
I have no idea what you are talking about. I have no recolection of previous patches or conversations about your patches.
greg k-h
Re: [PATCH 3/3] staging: lustre: Less function calls in class_register_type() after error detection
Quoted 9 lines
Quoted 6 lines
Do you try this update suggestion out without integrating the corresponding previous update suggestion "Delete unnecessary checks before two function calls" where I proposed to remove extra checks before a few calls of the function "
kobject_put" (which seems to matter for the patch hunk in the shown error message)?
https://lkml.org/lkml/2015/11/5/276
https://www.mail-archive.com/[email protected]/msg1013635.htmlI guess so, I don't remember, I don't see any patches from you earlier in my "todo" mbox.
I am still waiting for further constructive feedback on a bunch of my update suggestions which are derived from static source code analysis.
It can be the usual challenge to get a bit more attention for them. Other software improvements will result in bigger effects than the source code fine-tuning I propose, won't it?
I would like to acknowledge that changes like the following from this patch series can still be applied together for the software "Linux next-20151126".
* 0001-staging-lustre-Delete-unnecessary-checks-before-two.patch
* 0003-staging-lustre-Less-function-calls-in-class_register.patch
Quoted 5 lines
Quoted 2 lines
Would you like to reject the first update step from this patch series so that I need to adapt my approach to your software design decision?
I have no idea what you are talking about. I have no recolection of previous patches or conversations about your patches.
* Dan Carpenter expressed his software design concerns around hidden sanity checks a few times.
How do you think about to give the proposed changes another chance?
* Positive feedback is occasionally increasing by specific subsystem supporters and maintainers.
How will our collaboration evolve further?
Do you want that I resend any mails/patches from my "waiting queue"?
Regards,
Markus
Re: [PATCH 3/3] staging: lustre: Less function calls in class_register_type() after error detection
These patches are often correct in the same way a stopped clock is correct twice a day, but I reject the motivation/approach/patch description. Just because there is a sanity check does not mean we should use it (ie, do an insane thing). It hurts readability to hide the NULL check.
On the other hand, half the time the NULL checks are superflous because the pointer is never NULL. The other half of the time the NULL checks are there because the code uses one err style error handling. Also the error handling code should mirror the allocation code so I feel like it should be:
if (some_feature) foo = allocate(); ret = frob(); if (ret) goto free_foo;
free_foo:
if (some_feature) // <--- as opposed to if (foo) {
free(foo);So anyway I often don't like the original code, but the new code is even worse and I have never heard a good motivation for these patches besides that they were generated using a cool tool. It's not a good reason. Other maintainers are accepting these patches so you are free to send them there.
regards,
dan carpenter
PATCH 1/1 staging: most: Delete an unnecessary check before the function call "module_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 5 Nov 2015 14:34:43 +0100
The module_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/staging/most/mostcore/core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/most/mostcore/core.c +1 -2
@@ -1587,8 +1587,7 @@ out:return 0 ; error: -if (iface->mod) -module_put (iface->mod); +module_put (iface->mod); modref--;mutex_unlock (&c->start_mutex);return ret;
Signature · 1 line
2.6.2
Re: [PATCH] staging: most: Delete an unnecessary check before the function call "module_put"
Relying on hidden sanity checks makes the code harder to read. A human being cannot remember which functions have sanity checks and which do not. These sorts of patches are easy to generate automatically but they make the code worse. There are so many *better* things to do instead of focusing on making the code bad.
Please stop sending these patches for drivers/staging. You are welcome to send them for other subsystems which I don't care about.
regards,
dan carpenter
Re: staging: most: Delete an unnecessary check before the function call "module_put"
Quoted 1 line
Please stop sending these patches for
drivers/staging.
Will further contributors take another look at similar update suggestions?
Quoted 1 line
You are welcome to send them for other subsystems
Thanks for this suggestion.
Quoted 1 line
which I don't care about.
I am curious if other software developers will give more positive feedback on the proposed source code fine-tuning because of collateral evolution.
Regards,
Markus
PATCH 1/1 ACPICA: Delete unnecessary checks before the function call "acpi_ut_strupr"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 5 Nov 2015 16:12:32 +0100
The acpi_ut_strupr() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/acpi/acpica/dbcmds.c | 9 ++------- drivers/acpi/acpica/dbinput.c | 5 +---- 2 files changed, 3 insertions(+), 11 deletions(-)
drivers/acpi/acpica/dbcmds.c +2 -7
@@ -1131,13 +1131,8 @@ void acpi_db_trace(char *enable_arg, char *method_arg, char *once_arg)u32 debug_layer =0 ;u32 flags =0 ; -if (enable_arg) { -acpi_ut_strupr (enable_arg); - } - -if (once_arg) { -acpi_ut_strupr (once_arg); - } +acpi_ut_strupr (enable_arg); +acpi_ut_strupr (once_arg);if (method_arg) {if (acpi_db_trace_method_name) {
drivers/acpi/acpica/dbinput.c +1 -4
@@ -622,10 +622,7 @@ static u32 acpi_db_get_line(char *input_buffer) }/* Uppercase the actual command */ - -if (acpi_gbl_db_args[0 ]) { -acpi_ut_strupr (acpi_gbl_db_args[0 ]); - } +acpi_ut_strupr (acpi_gbl_db_args[0 ]); count = i;if (count) {
Signature · 1 line
2.6.2
RE: [PATCH] ACPICA: Delete unnecessary checks before the function call "acpi_ut_strupr"
Agreed, we will implement your suggestions in the ACPICA code (which is in a different format than the Linux version).
Quoted 62 lines
-----Original Message-----
From: SF Markus Elfring [mailto:elfring(a)users.sourceforge.net]
Sent: Thursday, November 05, 2015 7:23 AM
To: Len Brown; Zheng, Lv; Wysocki, Rafael J; Moore, Robert; linux- acpi(a)vger.kernel.org; devel(a)acpica.org
Cc: LKML; kernel-janitors(a)vger.kernel.org; Julia Lawall
Subject: [PATCH] ACPICA: Delete unnecessary checks before the function call "acpi_ut_strupr"From: Markus Elfring <elfring(a)users.sourceforge.net>
Date: Thu, 5 Nov 2015 16:12:32 +0100The
acpi_ut_strupr()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <elfring(a)users.sourceforge.net>--- drivers/acpi/acpica/dbcmds.c | 9 ++------- drivers/acpi/acpica/dbinput.c | 5 +---- 2 files changed, 3 insertions(+), 11 deletions(-)drivers/acpi/acpica/dbcmds.c +2
-7@@ -1131,13 +1131,8 @@ void acpi_db_trace(char *enable_arg, char *method_arg, char *once_arg)u32 debug_layer =0 ;u32 flags =0 ; -if (enable_arg) { -acpi_ut_strupr (enable_arg); - } - -if (once_arg) { -acpi_ut_strupr (once_arg); - } +acpi_ut_strupr (enable_arg); +acpi_ut_strupr (once_arg);if (method_arg) {drivers/acpi/acpica/dbcmds.c +0
-0if (acpi_db_trace_method_name) {drivers/acpi/acpica/dbinput.c +1
-5@@ -622,10 +622,7 @@ static u32 acpi_db_get_line(char *input_buffer) }/* Uppercase the actual command */ - -if (acpi_gbl_db_args[0 ]) { -acpi_ut_strupr (acpi_gbl_db_args[0 ]); - } +acpi_ut_strupr (acpi_gbl_db_args[0 ]); count = i;if (count) { --2.6.2
PATCH 1/1 pinctrl: Delete unnecessary checks before the function call "pinctrl_unregister"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 5 Nov 2015 17:10:22 +0100
The pinctrl_unregister() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c | 3 +-- drivers/pinctrl/pinctrl-single.c | 5 +---- 2 files changed, 2 insertions(+), 6 deletions(-)
drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c +1 -2
@@ -638,8 +638,7 @@ static int cygnus_gpio_register_pinconf(struct cygnus_gpio *chip)static void cygnus_gpio_unregister_pinconf (struct cygnus_gpio *chip) { -if (chip->pctl) -pinctrl_unregister (chip->pctl); +pinctrl_unregister (chip->pctl); }struct cygnus_gpio_data {
drivers/pinctrl/pinctrl-single.c +1 -4
@@ -1484,10 +1484,7 @@ static void pcs_irq_free(struct pcs_device *pcs)static void pcs_free_resources (struct pcs_device *pcs) {pcs_irq_free (pcs); - -if (pcs->pctl) -pinctrl_unregister (pcs->pctl); - +pinctrl_unregister (pcs->pctl);pcs_free_funcs (pcs);pcs_free_pingroups (pcs); }
Signature · 1 line
2.6.2
Re: [PATCH] pinctrl: Delete unnecessary checks before the function call "pinctrl_unregister"
Quoted 35 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 5 Nov 2015 17:10:22 +0100The
pinctrl_unregister()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c | 3 +-- drivers/pinctrl/pinctrl-single.c | 5 +---- 2 files changed, 2 insertions(+), 6 deletions(-)drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c +1
-2@@ -638,8 +638,7 @@ static int cygnus_gpio_register_pinconf(struct cygnus_gpio *chip)static void cygnus_gpio_unregister_pinconf (struct cygnus_gpio *chip) { -if (chip->pctl) -pinctrl_unregister (chip->pctl); +pinctrl_unregister (chip->pctl); }struct cygnus_gpio_data {drivers/pinctrl/pinctrl-single.c +0
-0@@ -1484,10 +1484,7 @@ static void pcs_irq_free(struct pcs_device *pcs)static void pcs_free_resources (struct pcs_device *pcs)
drivers/pinctrl/pinctrl-single.c static void pcs_irq_free(struct pcs_device *pcs) · line 1490
Quoted 10 lines
drivers/pinctrl/pinctrl-single.c +1
-4{pcs_irq_free (pcs); - -if (pcs->pctl) -pinctrl_unregister (pcs->pctl); - +pinctrl_unregister (pcs->pctl);pcs_free_funcs (pcs);pcs_free_pingroups (pcs); }
The change looks good to me, thanks!
+ Pramod since he's working on changes on the pinctrl-cygnus-gpio driver.
Ray
Re: [PATCH] pinctrl: Delete unnecessary checks before the function call "pinctrl_unregister"
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 5 Nov 2015 17:10:22 +0100The
pinctrl_unregister()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Patch applied with Ray's Review tag.
Yours,
Linus Walleij
PATCH 1/1 IPC-mqueue: Delete unnecessary checks before two function calls
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 5 Nov 2015 17:55:25 +0100
The functions iput() and unregister_sysctl_table() test whether their argument is NULL and then return immediately.
Thus the tests around their calls are not needed.
This issue was detected by using the Coccinelle software.
--- ipc/mqueue.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
ipc/mqueue.c +2 -4
@@ -885,8 +885,7 @@ SYSCALL_DEFINE1(mq_unlink, const char __user *, u_name) out_unlock:mutex_unlock (&d_inode (mnt->mnt_root)->i_mutex); -if (inode) -iput (inode); +iput (inode);mnt_drop_write (mnt); out_name:putname (name);
@@ -1460,8 +1459,7 @@ static int __init init_mqueue_fs(void) out_filesystem:unregister_filesystem (&mqueue_fs_type); out_sysctl: -if (mq_sysctl_table) -unregister_sysctl_table (mq_sysctl_table); +unregister_sysctl_table (mq_sysctl_table);kmem_cache_destroy (mqueue_inode_cachep);return error; }
Signature · 1 line
2.6.2
Re: [PATCH] IPC-mqueue: Delete unnecessary checks before two function calls
Quoted 30 lines
From: Markus Elfring <[email protected]>
Date: Thu, 5 Nov 2015 17:55:25 +0100The functions
iput()andunregister_sysctl_table()test whether their argument is NULL and then return immediately.
Thus the tests around their calls are not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- ipc/mqueue.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)ipc/mqueue.c +1
-2@@ -885,8 +885,7 @@ SYSCALL_DEFINE1(mq_unlink, const char __user *, u_name) out_unlock:mutex_unlock (&d_inode (mnt->mnt_root)->i_mutex); -if (inode) -iput (inode); +iput (inode);mnt_drop_write (mnt); out_name:putname (name);
ipc/mqueue.c static int __init init_mqueue_fs(void) · line 1465
Quoted 9 lines
ipc/mqueue.c +1
-2@@ -1460,8 +1459,7 @@ static int __init init_mqueue_fs(void) out_filesystem:unregister_filesystem (&mqueue_fs_type); out_sysctl: -if (mq_sysctl_table) -unregister_sysctl_table (mq_sysctl_table); +unregister_sysctl_table (mq_sysctl_table);kmem_cache_destroy (mqueue_inode_cachep);return error; }
How do you think about to integrate this update suggestion into another source code repository?
Regards,
Markus
cover c8sectpfe: Deletion of a few unnecessary checks
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 5 Nov 2015 19:39:32 +0100
Another update suggestion was taken into account after a patch was applied from static source code analysis.
Markus Elfring (2):
Delete unnecessary checks before two function calls Combine three checks into a single if block
drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
Signature · 1 line
2.6.2
PATCH 1/2 c8sectpfe: Delete unnecessary checks before two function calls
From: Markus Elfring <[email protected]>
Date: Thu, 5 Nov 2015 18:55:19 +0100
The functions i2c_put_adapter() and module_put() test whether their argument is NULL and then return immediately.
Thus the tests around their calls are not needed.
This issue was detected by using the Coccinelle software.
--- drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c +2 -3
@@ -214,12 +214,11 @@ void c8sectpfe_tuner_unregister_frontend(struct c8sectpfe *c8sectpfe,dvb_frontend_detach (tsin->frontend); } -if (tsin && tsin->i2c_adapter) +if (tsin)i2c_put_adapter (tsin->i2c_adapter);if (tsin && tsin->i2c_client) { -if (tsin->i2c_client->dev.driver->owner) -module_put (tsin->i2c_client->dev.driver->owner); +module_put (tsin->i2c_client->dev.driver->owner);i2c_unregister_device (tsin->i2c_client); } }
Signature · 1 line
2.6.2
PATCH 2/2 c8sectpfe: Combine three checks into a single if block
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 5 Nov 2015 19:23:50 +0100
The variable "tsin" was checked three times in a loop iteration of the c8sectpfe_tuner_unregister_frontend() function.
This implementation detail could be improved by the combination of the involved statements into a single if block so that this variable will be checked only once there.
--- drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c +9 -8
@@ -209,17 +209,18 @@ void c8sectpfe_tuner_unregister_frontend(struct c8sectpfe *c8sectpfe, tsin = fei->channel_data[n]; -if (tsin && tsin->frontend) { -dvb_unregister_frontend (tsin->frontend); -dvb_frontend_detach (tsin->frontend); - } +if (tsin) { +if (tsin->frontend) { +dvb_unregister_frontend (tsin->frontend); +dvb_frontend_detach (tsin->frontend); + } -if (tsin)i2c_put_adapter (tsin->i2c_adapter); -if (tsin && tsin->i2c_client) { -module_put (tsin->i2c_client->dev.driver->owner); -i2c_unregister_device (tsin->i2c_client); +if (tsin->i2c_client) { +module_put (tsin->i2c_client->dev.driver->owner); +i2c_unregister_device (tsin->i2c_client); + } } }
Signature · 1 line
2.6.2
Re: [PATCH 2/2] [media] c8sectpfe: Combine three checks into a single if block
Am 05.11.2015 19:50, schrieb SF Markus Elfring:
Quoted 19 lines
From: Markus Elfring <[email protected]>
Date: Thu, 5 Nov 2015 19:23:50 +0100The variable "tsin" was checked three times in a loop iteration of the
c8sectpfe_tuner_unregister_frontend()function.
This implementation detail could be improved by the combination of the involved statements into a single if block so that this variable will be checked only once there.Signed-off-by Markus Elfring <[email protected]>--- drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c +0
-0
drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c void c8sectpfe_tuner_unregister_frontend(struct c8sectpfe *c8sectpfe, · line 210
Quoted 2 lines
drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c +0
-0@@ -209,17 +209,18 @@ void c8sectpfe_tuner_unregister_frontend(struct c8sectpfe *c8sectpfe, tsin = fei->channel_data[n];
if you do "if (!tsin) continue ;"
you can save one indent level
re,
wh
Quoted 24 lines
drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c +9
-8-if (tsin && tsin->frontend) { -dvb_unregister_frontend (tsin->frontend); -dvb_frontend_detach (tsin->frontend); - } +if (tsin) { +if (tsin->frontend) { +dvb_unregister_frontend (tsin->frontend); +dvb_frontend_detach (tsin->frontend); + } -if (tsin)i2c_put_adapter (tsin->i2c_adapter); -if (tsin && tsin->i2c_client) { -module_put (tsin->i2c_client->dev.driver->owner); -i2c_unregister_device (tsin->i2c_client); +if (tsin->i2c_client) { +module_put (tsin->i2c_client->dev.driver->owner); +i2c_unregister_device (tsin->i2c_client); + } } }
Re: [PATCH 0/2] [media] c8sectpfe: Deletion of a few unnecessary checks
In reply to SF Markus ElfringHi Markus,
Quoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 5 Nov 2015 19:39:32 +0100Another update suggestion was taken into account after a patch was applied from static source code analysis.
Quoted 7 lines
Markus Elfring (2):
Delete unnecessary checks before two function calls Combine three checks into a single if blockdrivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
For the series:
Thanks!
Maxime
PATCH 1/1 CPPC-CPUFreq: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 5 Nov 2015 21:10:29 +0100
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/cpufreq/cppc_cpufreq.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/cpufreq/cppc_cpufreq.c +1 -2
@@ -166,8 +166,7 @@ static int __init cppc_cpufreq_init(void) out:for_each_possible_cpu (i) -if (all_cpu_data[i]) -kfree (all_cpu_data[i]); +kfree (all_cpu_data[i]);kfree (all_cpu_data);return -ENODEV ;
Signature · 1 line
2.6.2
Re: [PATCH] CPPC-CPUFreq: Delete an unnecessary check before the function call "kfree"
Quoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 5 Nov 2015 21:10:29 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
Quoted 6 lines
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/cpufreq/cppc_cpufreq.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Signature · 1 line
viresh
Rafael J. Wysocki
AppliedRe: [PATCH] CPPC-CPUFreq: Delete an unnecessary check before the function call "kfree"
Quoted 7 lines · Viresh Kumar
Quoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 5 Nov 2015 21:10:29 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
Quoted 8 lines
Quoted 6 lines
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/cpufreq/cppc_cpufreq.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)Acked-by Viresh Kumar <[email protected]>
Applied, thanks!
Rafael
PATCH 1/1 hpet: Delete an unnecessary check before unregister_sysctl_table()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 5 Nov 2015 21:32:42 +0100
The unregister_sysctl_table() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/char/hpet.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/char/hpet.c +1 -2
@@ -1069,8 +1069,7 @@ static int __init hpet_init(void) result =acpi_bus_register_driver (&hpet_acpi_driver);if (result <0 ) { -if (sysctl_header) -unregister_sysctl_table (sysctl_header); +unregister_sysctl_table (sysctl_header);misc_deregister (&hpet_misc);return result; }
Signature · 1 line
2.6.2
Re: [PATCH] hpet: Delete an unnecessary check before unregister_sysctl_table()
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 5 Nov 2015 21:32:42 +0100The
unregister_sysctl_table()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Quoted 18 lines
--- drivers/char/hpet.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/char/hpet.c +1
-2@@ -1069,8 +1069,7 @@ static int __init hpet_init(void) result =acpi_bus_register_driver (&hpet_acpi_driver);if (result <0 ) { -if (sysctl_header) -unregister_sysctl_table (sysctl_header); +unregister_sysctl_table (sysctl_header);misc_deregister (&hpet_misc);return result; }
PATCH 1/1 DWC Ethernet QoS: Delete an unnecessary check before the function call "of_node_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 6 Nov 2015 08:00:22 +0100
The of_node_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/net/ethernet/synopsys/dwc_eth_qos.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/synopsys/dwc_eth_qos.c +1 -2
@@ -2970,8 +2970,7 @@ err_out_unregister_netdev: err_out_clk_dis_aper:clk_disable_unprepare (lp->apb_pclk); err_out_free_netdev: -if (lp->phy_node) -of_node_put (lp->phy_node); +of_node_put (lp->phy_node);free_netdev (ndev);platform_set_drvdata (pdev,NULL );return ret;
Signature · 1 line
2.6.2
David Miller
maintainerRe: [PATCH] DWC Ethernet QoS: Delete an unnecessary check before the function call "of_node_put"
From: SF Markus Elfring <[email protected]>
Date: Fri, 6 Nov 2015 08:15:30 +0100
Quoted 9 lines
From: Markus Elfring <[email protected]>
Date: Fri, 6 Nov 2015 08:00:22 +0100The
of_node_put()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Please resubmit this with a more appropriate Subject line.
The subsystem prefix should be all lower-case and typically indicate the most specific subsystem or area being changed.
In this case it's a driver, therefore simply use the driver name "dwc_eth_qos: ".
PATCH 1/1 ethernet-synopsys: Delete an unnecessary check before of_node_put()
From: Markus Elfring <[email protected]>
Date: Sat, 7 Nov 2015 15:10:29 +0100
The of_node_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/net/ethernet/synopsys/dwc_eth_qos.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/synopsys/dwc_eth_qos.c +1 -2
@@ -2970,8 +2970,7 @@ err_out_unregister_netdev: err_out_clk_dis_aper:clk_disable_unprepare (lp->apb_pclk); err_out_free_netdev: -if (lp->phy_node) -of_node_put (lp->phy_node); +of_node_put (lp->phy_node);free_netdev (ndev);platform_set_drvdata (pdev,NULL );return ret;
Signature · 1 line
2.6.2
David Miller
maintainerRe: [PATCH] ethernet-synopsys: Delete an unnecessary check before of_node_put()
From: SF Markus Elfring <[email protected]>
Date: Sat, 7 Nov 2015 15:15:24 +0100
Quoted 9 lines
From: Markus Elfring <[email protected]>
Date: Sat, 7 Nov 2015 15:10:29 +0100The
of_node_put()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
As I requested of you last night, please phrase the subsystem prefix of your Subject lines more correctly.
Just use the driver's name, in lower case, as one single word, which in this case would be "dwc_eth_qos: ".
I'm telling you exactly what to use in the Subject line, there is no ambiguity or confusion on what you need to do for me to accept this patch.
Thanks.
PATCH 1/1 dwc_eth_qos: Delete an unnecessary check before the function call "of_node_put"
In reply to David MillerFrom: Markus Elfring <[email protected]>
Date: Sat, 7 Nov 2015 16:30:34 +0100
The of_node_put() function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/net/ethernet/synopsys/dwc_eth_qos.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/synopsys/dwc_eth_qos.c +1 -2
@@ -2970,8 +2970,7 @@ err_out_unregister_netdev: err_out_clk_dis_aper:clk_disable_unprepare (lp->apb_pclk); err_out_free_netdev: -if (lp->phy_node) -of_node_put (lp->phy_node); +of_node_put (lp->phy_node);free_netdev (ndev);platform_set_drvdata (pdev,NULL );return ret;
Signature · 1 line
2.6.2
Re: [PATCH] dwc_eth_qos: Delete an unnecessary check before the function call "of_node_put"
From: SF Markus Elfring <[email protected]>
Date: Sat, 7 Nov 2015 16:34:48 +0100
Quoted 10 lines
From: Markus Elfring <[email protected]>
Date: Sat, 7 Nov 2015 16:30:34 +0100The
of_node_put()function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied.
PATCH 1/1 fjes: Delete an unnecessary check before the function call "vfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 6 Nov 2015 09:30:29 +0100
The vfree() function performs also input parameter validation. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/net/fjes/fjes_hw.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/fjes/fjes_hw.c +1 -3
@@ -143,9 +143,7 @@ static int fjes_hw_alloc_epbuf(struct epbuf_handler *epbh)static void fjes_hw_free_epbuf (struct epbuf_handler *epbh) { -if (epbh->buffer) -vfree (epbh->buffer); - +vfree (epbh->buffer); epbh->buffer =NULL ; epbh->size =0 ;
Signature · 1 line
2.6.2
Re: [PATCH] fjes: Delete an unnecessary check before the function call "vfree"
From: SF Markus Elfring <[email protected]>
Date: Fri, 6 Nov 2015 09:39:23 +0100
Quoted 9 lines
From: Markus Elfring <[email protected]>
Date: Fri, 6 Nov 2015 09:30:29 +0100The
vfree()function performs also input parameter validation. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied.
PATCH 1/1 SGI-XPC: Delete unnecessary checks before unregister_sysctl_table()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 6 Nov 2015 10:08:46 +0100
The unregister_sysctl_table() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/misc/sgi-xp/xpc_main.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/misc/sgi-xp/xpc_main.c +2 -6
@@ -1046,9 +1046,7 @@ xpc_do_exit(enum xp_retval reason)/* clear the interface to XPC's functions */ xpc_clear_interface (); -if (xpc_sysctl) -unregister_sysctl_table (xpc_sysctl); - +unregister_sysctl_table (xpc_sysctl);xpc_teardown_partitions ();if (is_shub ())
@@ -1331,9 +1329,7 @@ out_3: (void )unregister_die_notifier (&xpc_die_notifier); (void )unregister_reboot_notifier (&xpc_reboot_notifier); out_2: -if (xpc_sysctl) -unregister_sysctl_table (xpc_sysctl); - +unregister_sysctl_table (xpc_sysctl);xpc_teardown_partitions (); out_1:if (is_shub ())
Signature · 1 line
2.6.2
Re: [PATCH] SGI-XPC: Delete unnecessary checks before unregister_sysctl_table()
Quoted 1 line · SF Markus Elfring
Signed-off-by Markus Elfring <[email protected]>
PATCH 1/1 SRAM: Delete an unnecessary check before the function call "of_node_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 6 Nov 2015 10:36:49 +0100
The of_node_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/misc/sram.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/misc/sram.c +1 -3
@@ -326,9 +326,7 @@ static int sram_reserve_regions(struct sram_dev *sram, struct resource *res) } err_chunks: -if (child) -of_node_put (child); - +of_node_put (child);kfree (rblocks);return ret;
Signature · 1 line
2.6.2
Re: [PATCH] SRAM: Delete an unnecessary check before the function call "of_node_put"
Quoted 19 lines
From: Markus Elfring <[email protected]>
Date: Fri, 6 Nov 2015 10:36:49 +0100The
of_node_put()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/misc/sram.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/misc/sram.c +0
-0
drivers/misc/sram.c static int sram_reserve_regions(struct sram_dev *sram, struct resource *res) · line 332
Quoted 10 lines
drivers/misc/sram.c +1
-3@@ -326,9 +326,7 @@ static int sram_reserve_regions(struct sram_dev *sram, struct resource *res) } err_chunks: -if (child) -of_node_put (child); - +of_node_put (child);kfree (rblocks);return ret;
How do you think about to integrate this update suggestion into another source code repository?
Regards,
Markus
PATCH 1/1 cxl: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 6 Nov 2015 11:00:23 +0100
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/misc/cxl/context.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/misc/cxl/context.c +1 -3
@@ -275,9 +275,7 @@ static void reclaim_ctx(struct rcu_head *rcu)if (ctx->kernelapi)kfree (ctx->mapping); -if (ctx->irq_bitmap) -kfree (ctx->irq_bitmap); - +kfree (ctx->irq_bitmap);kfree (ctx); }
Signature · 1 line
2.6.2
Re: [PATCH] cxl: Delete an unnecessary check before the function call "kfree"
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 6 Nov 2015 11:00:23 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Thanks for picking this up - will remember in my future patches.
Signature · 3 lines
Andrew Donnellan Software Engineer, OzLabs [email protected] Australia Development Lab, Canberra +61 2 6201 8874 (work) IBM Australia Limited
Re: [PATCH] cxl: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringRe: cxl: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringQuoted 11 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 6 Nov 2015 11:00:23 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>Reviewed-by Andrew Donnellan <[email protected]>Acked-by Ian Munsie <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/1050e689a63baffdadcd33498c
cheers
PATCH 1/1 GPU-DRM-i915: Delete an unnecessary check before the function call "pwm_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 6 Nov 2015 13:38:22 +0100
The pwm_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/i915/intel_panel.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_panel.c +1 -2
@@ -1729,8 +1729,7 @@ void intel_panel_destroy_backlight(struct drm_connector *connector)struct intel_panel *panel = &intel_connector->panel;/* dispose of the pwm */ -if (panel->backlight.pwm) -pwm_put (panel->backlight.pwm); +pwm_put (panel->backlight.pwm); panel->backlight.present = false; }
Signature · 1 line
2.6.2
Jani Nikula
maintainerRe: [PATCH] GPU-DRM-i915: Delete an unnecessary check before the function call "pwm_put"
Quoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 6 Nov 2015 13:38:22 +0100The
pwm_put()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
The compiler doesn't need it, but IMO it's useful documentation for humans.
BR,
Jani.
Quoted 22 lines
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/gpu/drm/i915/intel_panel.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpu/drm/i915/intel_panel.c +1
-2@@ -1729,8 +1729,7 @@ void intel_panel_destroy_backlight(struct drm_connector *connector)struct intel_panel *panel = &intel_connector->panel;/* dispose of the pwm */ -if (panel->backlight.pwm) -pwm_put (panel->backlight.pwm); +pwm_put (panel->backlight.pwm); panel->backlight.present = false; }
Signature · 1 line
Jani Nikula, Intel Open Source Technology Center
Re: GPU-DRM-i915: Delete an unnecessary check before the function call "pwm_put"
Quoted 4 lines
Quoted 2 lines
The
pwm_put()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.The compiler doesn't need it, but IMO it's useful documentation for humans.
How do you think about to extend the explicit documentation for the affected parameters in the Linux programming interfaces?
Regards,
Markus
Jani Nikula
maintainerRe: GPU-DRM-i915: Delete an unnecessary check before the function call "pwm_put"
Quoted 7 lines · SF Markus Elfring
Quoted 4 lines
Quoted 2 lines
The
pwm_put()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.The compiler doesn't need it, but IMO it's useful documentation for humans.
How do you think about to extend the explicit documentation for the affected parameters in the Linux programming interfaces?
The question is, while reading intel_panel.c, which one conveys the reader better the idea that panel->backlight.pwm may be NULL for some connectors:
a) if (panel->backlight.pwm)
pwm_put(panel->backlight.pwm);
b) pwm_put(panel->backlight.pwm);
No amount of documentation in pwm_put() kernel-doc is going to help with that. In most cases, panel->backlight.pwm is in fact NULL. IMO unconditionally calling pwm_put() on it gives the reader the wrong idea.
Others may disagree.
BR,
Jani.
Signature · 1 line
Jani Nikula, Intel Open Source Technology Center
PATCH 1/1 GPU-DRM-ps8622: Delete an unnecessary check before backlight_device_unregister()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 6 Nov 2015 14:38:34 +0100
The backlight_device_unregister() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/bridge/parade-ps8622.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/bridge/parade-ps8622.c +1 -3
@@ -646,9 +646,7 @@ static int ps8622_remove(struct i2c_client *client) {struct ps8622_bridge *ps8622 =i2c_get_clientdata (client); -if (ps8622->bl) -backlight_device_unregister (ps8622->bl); - +backlight_device_unregister (ps8622->bl);drm_bridge_remove (&ps8622->bridge);return 0 ;
Signature · 1 line
2.6.2
PATCH 1/1 HDMI-HDCP: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 6 Nov 2015 15:00:22 +0100
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/msm/hdmi/hdmi_hdcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/hdmi/hdmi_hdcp.c +1 -1
@@ -1430,7 +1430,7 @@ struct hdmi_hdcp_ctrl *hdmi_hdcp_init(struct hdmi *hdmi)void hdmi_hdcp_destroy (struct hdmi *hdmi) { -if (hdmi && hdmi->hdcp_ctrl) { +if (hdmi) {kfree (hdmi->hdcp_ctrl); hdmi->hdcp_ctrl =NULL ; }
Signature · 1 line
2.6.2
PATCH 1/1 GPU-DRM-vc4: Delete unnecessary checks before two function calls
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 6 Nov 2015 16:04:22 +0100
The following functions test whether their argument is NULL and then return immediately.
* drm_fbdev_cma_hotplug_event
* drm_fbdev_cma_restore_mode
Thus the tests around their calls are not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/vc4/vc4_drv.c | 3 +-- drivers/gpu/drm/vc4/vc4_kms.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/vc4/vc4_drv.c +1 -2
@@ -54,8 +54,7 @@ static void vc4_lastclose(struct drm_device *dev) {struct vc4_dev *vc4 =to_vc4_dev (dev); -if (vc4->fbdev) -drm_fbdev_cma_restore_mode (vc4->fbdev); +drm_fbdev_cma_restore_mode (vc4->fbdev); }static const struct file_operations vc4_drm_fops = {
drivers/gpu/drm/vc4/vc4_kms.c +1 -2
@@ -25,8 +25,7 @@ static void vc4_output_poll_changed(struct drm_device *dev) {struct vc4_dev *vc4 =to_vc4_dev (dev); -if (vc4->fbdev) -drm_fbdev_cma_hotplug_event (vc4->fbdev); +drm_fbdev_cma_hotplug_event (vc4->fbdev); }static const struct drm_mode_config_funcs vc4_mode_funcs = {
Signature · 1 line
2.6.2
PATCH 1/1 drm/vc4: Delete unnecessary checks before two function calls
From: Markus Elfring <[email protected]>
Date: Fri, 15 Jul 2016 21:15:37 +0200
The following functions test whether their argument is NULL and then return immediately.
* drm_fbdev_cma_hotplug_event
* drm_fbdev_cma_restore_mode
Thus the tests around their calls are not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/vc4/vc4_drv.c | 3 +-- drivers/gpu/drm/vc4/vc4_kms.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/vc4/vc4_drv.c +1 -2
@@ -47,8 +47,7 @@ static void vc4_lastclose(struct drm_device *dev) {struct vc4_dev *vc4 =to_vc4_dev (dev); -if (vc4->fbdev) -drm_fbdev_cma_restore_mode (vc4->fbdev); +drm_fbdev_cma_restore_mode (vc4->fbdev); }static const struct file_operations vc4_drm_fops = {
drivers/gpu/drm/vc4/vc4_kms.c +1 -2
@@ -26,8 +26,7 @@ static void vc4_output_poll_changed(struct drm_device *dev) {struct vc4_dev *vc4 =to_vc4_dev (dev); -if (vc4->fbdev) -drm_fbdev_cma_hotplug_event (vc4->fbdev); +drm_fbdev_cma_hotplug_event (vc4->fbdev); }struct vc4_commit {
Signature · 1 line
2.9.1
PATCH 1/1 bq2415x_charger: Delete unnecessary checks before the function call "of_node_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 6 Nov 2015 16:48:46 +0100
The of_node_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/power/bq2415x_charger.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/power/bq2415x_charger.c +2 -4
@@ -1704,7 +1704,7 @@ error_4: error_3:bq2415x_power_supply_exit (bq); error_2: -if (bq && bq->notify_node) +if (bq)of_node_put (bq->notify_node);kfree (name); error_1:
@@ -1724,9 +1724,7 @@ static int bq2415x_remove(struct i2c_client *client)if (bq->nb.notifier_call)power_supply_unreg_notifier (&bq->nb); -if (bq->notify_node) -of_node_put (bq->notify_node); - +of_node_put (bq->notify_node);bq2415x_sysfs_exit (bq);bq2415x_power_supply_exit (bq);
Signature · 1 line
2.6.2
Re: [PATCH] bq2415x_charger: Delete unnecessary checks before the function call "of_node_put"
Quoted 9 lines · On Friday 06 November 2015 16:56:33 SF Markus Elfring wrote:
From: Markus Elfring <[email protected]>
Date: Fri, 6 Nov 2015 16:48:46 +0100The
of_node_put()function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Signature · 2 lines
Pali Rohár [email protected]
PATCH 1/1 HID: Wacom: Delete an unnecessary check before the function call "kobject_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 6 Nov 2015 17:55:23 +0100
The kobject_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/hid/wacom_sys.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/hid/wacom_sys.c +1 -2
@@ -1353,8 +1353,7 @@ static void wacom_clean_inputs(struct wacom *wacom)else input_free_device (wacom->wacom_wac.pad_input); } -if (wacom->remote_dir) -kobject_put (wacom->remote_dir); +kobject_put (wacom->remote_dir); wacom->wacom_wac.pen_input =NULL ; wacom->wacom_wac.touch_input =NULL ; wacom->wacom_wac.pad_input =NULL ;
Signature · 1 line
2.6.2
Re: [PATCH] HID: Wacom: Delete an unnecessary check before the function call "kobject_put"
Quoted 7 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 6 Nov 2015 17:55:23 +0100The
kobject_put()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Applied to for-4.5/wacom.
Thanks,
Signature · 2 lines
Jiri Kosina SUSE Labs
PATCH 1/1 net: dsa: Delete an unnecessary check before the function call "put_device"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 14 Nov 2015 17:58:00 +0100
The put_device() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- net/dsa/dsa.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/dsa/dsa.c +1 -2
@@ -671,8 +671,7 @@ static void dsa_of_free_platform_data(struct dsa_platform_data *pd)kfree (pd->chip[i].rtable);/* Drop our reference to the MDIO bus device */ -if (pd->chip[i].host_dev) -put_device (pd->chip[i].host_dev); +put_device (pd->chip[i].host_dev); }kfree (pd->chip); }
Signature · 1 line
2.6.2
David Miller
maintainerRe: [PATCH] net: dsa: Delete an unnecessary check before the function call "put_device"
I'm starting to grow quite weary of these "unnecessary check" changes.
Sometimes it is better to have them, either because the path is a hot path or some atomic sequence is involved.
But there is never harm in them being there.
All of this is a matter of taste, of course. But one thing I know for sure, it is undisputable that there are much more important things to work on than this kind of stuff...
So I'm not applying these changes any more and directing my time and effort to reviewing and applying patches that fix bugs, really restructure the code in useful ways that increase maintainability over the long time, and add interesting new features.
These patches do none of the above.
PATCH 1/1 net-ipv6: Delete unnecessary checks before the function call "kfree_skb"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 14 Nov 2015 19:55:00 +0100
The kfree_skb() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- net/ipv6/af_inet6.c | 7 ++----- net/ipv6/netfilter/nf_conntrack_reasm.c | 3 +-- 2 files changed, 3 insertions(+), 7 deletions(-)
net/ipv6/af_inet6.c +2 -5
@@ -416,12 +416,9 @@ void inet6_destroy_sock(struct sock *sk)/* Release rx options */ skb =xchg (&np->pktoptions,NULL ); -if (skb) -kfree_skb (skb); - +kfree_skb (skb); skb =xchg (&np->rxpmtu,NULL ); -if (skb) -kfree_skb (skb); +kfree_skb (skb);/* Free flowlabels */ fl6_free_socklist (sk);
net/ipv6/netfilter/nf_conntrack_reasm.c +1 -2
@@ -172,8 +172,7 @@ static unsigned int nf_hashfn(const struct inet_frag_queue *q)static void nf_skb_free (struct sk_buff *skb) { -if (NFCT_FRAG6_CB (skb)->orig) -kfree_skb (NFCT_FRAG6_CB (skb)->orig); +kfree_skb (NFCT_FRAG6_CB (skb)->orig); }static void nf_ct_frag6_expire (unsigned long data)
Signature · 1 line
2.6.2
Re: [PATCH] net-ipv6: Delete unnecessary checks before the function call "kfree_skb"
Quoted 21 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 14 Nov 2015 19:55:00 +0100The
kfree_skb()function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- net/ipv6/af_inet6.c | 7 ++----- net/ipv6/netfilter/nf_conntrack_reasm.c | 3 +-- 2 files changed, 3 insertions(+), 7 deletions(-)net/ipv6/af_inet6.c +0
-0@@ -416,12 +416,9 @@ void inet6_destroy_sock(struct sock *sk)/* Release rx options */
net/ipv6/af_inet6.c void inet6_destroy_sock(struct sock *sk) · line 422
Quoted 10 lines
net/ipv6/af_inet6.c +2
-5skb =xchg (&np->pktoptions,NULL ); -if (skb) -kfree_skb (skb); - +kfree_skb (skb); skb =xchg (&np->rxpmtu,NULL ); -if (skb) -kfree_skb (skb); +kfree_skb (skb);
There is no 'issue' here, or not this one.
In most cases, these pointers are NULL, so the test can be predicted by the processor.
While if the test is done in kfree_skb(), the branch predictor of the cpu wont be able to predict things.
By feeding too many NULL pointers to kfree_skb(), we slow down it.
Branch misses and hits were considered important years ago...
But seeing this inet6_destroy_sock() is (ab)using xchg() three times, I am not sure author cared that much about performance.
Re: net-ipv6: Delete unnecessary checks before the function call "kfree_skb"
Quoted 4 lines
While if the test is done in
kfree_skb(), the branch predictor of the cpu wont be able to predict things.By feeding too many NULL pointers to
kfree_skb(), we slow down it.
Would it make sense to annotate checks before such function calls as "UNLIKELY"?
Regards,
Markus
PATCH 1/1 mac802154: Delete an unnecessary check before the function call "kfree_skb"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 14 Nov 2015 20:22:41 +0100
The kfree_skb() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- net/mac802154/rx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/mac802154/rx.c +1 -2
@@ -217,8 +217,7 @@ __ieee802154_rx_handle_packet(struct ieee802154_local *local,break ; } -if (skb) -kfree_skb (skb); +kfree_skb (skb); } static void
Signature · 1 line
2.6.2
Marcel Holtmann
maintainerRe: [PATCH] mac802154: Delete an unnecessary check before the function call "kfree_skb"
Hi Markus,
Quoted 9 lines
The
kfree_skb()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>---
net/mac802154/rx.c| 3 +--1 file changed, 1 insertion(+), 2 deletions(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel
PATCH 1/1 Bluetooth-cmtp: Delete an unnecessary check before the function call "kfree_skb"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 14 Nov 2015 22:00:27 +0100
The kfree_skb() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- net/bluetooth/cmtp/core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/bluetooth/cmtp/core.c +1 -2
@@ -178,8 +178,7 @@ static inline int cmtp_recv_frame(struct cmtp_session *session, struct sk_buff *cmtp_add_msgpart (session, id, skb->data + hdrlen, len);break ;default : -if (session->reassembly[id] !=NULL ) -kfree_skb (session->reassembly[id]); +kfree_skb (session->reassembly[id]); session->reassembly[id] =NULL ;break ; }
Signature · 1 line
2.6.2
Marcel Holtmann
maintainerRe: [PATCH] Bluetooth-cmtp: Delete an unnecessary check before the function call "kfree_skb"
Hi Markus,
Quoted 9 lines
The
kfree_skb()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>---
net/bluetooth/cmtp/core.c| 3 +--1 file changed, 1 insertion(+), 2 deletions(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel
PATCH 1/1 net-hsr: Delete unnecessary checks before the function call "kfree_skb"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 14 Nov 2015 22:23:48 +0100
The kfree_skb() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- net/hsr/hsr_forward.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
net/hsr/hsr_forward.c +2 -5
@@ -355,11 +355,8 @@ void hsr_forward_skb(struct sk_buff *skb, struct hsr_port *port) goto out_drop;hsr_register_frame_in (frame.node_src, port, frame.sequence_nr);hsr_forward_do (&frame); - -if (frame.skb_hsr !=NULL ) -kfree_skb (frame.skb_hsr); -if (frame.skb_std !=NULL ) -kfree_skb (frame.skb_std); +kfree_skb (frame.skb_hsr); +kfree_skb (frame.skb_std);return ; out_drop:
Signature · 1 line
2.6.2
Re: [PATCH] net-hsr: Delete unnecessary checks before the function call "kfree_skb"
Quoted 12 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 14 Nov 2015 22:23:48 +0100The
kfree_skb()function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.net/hsr/hsr_forward.c +0
-0
net/hsr/hsr_forward.c void hsr_forward_skb(struct sk_buff *skb, struct hsr_port *port) · line 359
Quoted 10 lines
net/hsr/hsr_forward.c +2
-5@@ -355,11 +355,8 @@ void hsr_forward_skb(struct sk_buff *skb, struct hsr_port *port) goto out_drop;hsr_register_frame_in (frame.node_src, port, frame.sequence_nr);hsr_forward_do (&frame); - -if (frame.skb_hsr !=NULL ) -kfree_skb (frame.skb_hsr); -if (frame.skb_std !=NULL ) -kfree_skb (frame.skb_std); +kfree_skb (frame.skb_hsr); +kfree_skb (frame.skb_std);
Thanks for doing checks on the HSR code, and I apologise for the late reply! Not sure if this has already been applied, but:
You're right of course that these checks are not strictly necessary. However, it is likely that at least one of these (.skb_hsr or .skb_std) will be NULL here, so it could be considered nice form to check for this and not just trust kfree_skb() to do this. I'm not sure what's considered more correct in the kernel, so I will just say that I'm agnostic about this and let others decide.
Again, thanks!
Signature · 3 lines
Arvid Brodin ALTEN Sweden www.alten.com | www.alten.se
PATCH 1/1 NFC-nci: Delete unnecessary checks before the function call "kfree_skb"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 14 Nov 2015 22:42:48 +0100
The kfree_skb() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- net/nfc/nci/uart.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
net/nfc/nci/uart.c +2 -5
@@ -199,11 +199,8 @@ static void nci_uart_tty_close(struct tty_struct *tty)if (!nu)return ; -if (nu->tx_skb) -kfree_skb (nu->tx_skb); -if (nu->rx_skb) -kfree_skb (nu->rx_skb); - +kfree_skb (nu->tx_skb); +kfree_skb (nu->rx_skb);skb_queue_purge (&nu->tx_q); nu->ops.close (nu);
Signature · 1 line
2.6.2
cover batman-adv: Deletion of some unnecessary checks
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 15 Nov 2015 09:34:12 +0100
Another update suggestion was taken into account after a patch was applied from static source code analysis.
Markus Elfring (2):
Delete unnecessary checks before the function call "kfree_skb" Less checks in batadv_tvlv_unicast_send()
net/batman-adv/main.c | 15 +++++---------- net/batman-adv/network-coding.c | 4 +--- net/batman-adv/send.c | 3 +-- 3 files changed, 7 insertions(+), 15 deletions(-)
Signature · 1 line
2.6.2
PATCH 1/2 batman-adv: Delete unnecessary checks before the function call "kfree_skb"
From: Markus Elfring <[email protected]>
Date: Sun, 15 Nov 2015 08:04:43 +0100
The kfree_skb() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- net/batman-adv/main.c | 2 +- net/batman-adv/network-coding.c | 4 +--- net/batman-adv/send.c | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-)
net/batman-adv/main.c +1 -1
@@ -1184,7 +1184,7 @@ void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, u8 *src, ret = true; out: -if (skb && !ret) +if (!ret)kfree_skb (skb);if (orig_node)batadv_orig_node_free_ref (orig_node);
net/batman-adv/network-coding.c +1 -3
@@ -244,9 +244,7 @@ static void batadv_nc_path_free_ref(struct batadv_nc_path *nc_path)*/ static void batadv_nc_packet_free (struct batadv_nc_packet *nc_packet) { -if (nc_packet->skb) -kfree_skb (nc_packet->skb); - +kfree_skb (nc_packet->skb);batadv_nc_path_free_ref (nc_packet->nc_path);kfree (nc_packet); }
net/batman-adv/send.c +1 -2
@@ -407,8 +407,7 @@ void batadv_schedule_bat_ogm(struct batadv_hard_iface *hard_iface)static void batadv_forw_packet_free (struct batadv_forw_packet *forw_packet) { -if (forw_packet->skb) -kfree_skb (forw_packet->skb); +kfree_skb (forw_packet->skb);if (forw_packet->if_incoming)batadv_hardif_free_ref (forw_packet->if_incoming);if (forw_packet->if_outgoing)
Signature · 1 line
2.6.2
Marek Lindner
AppliedRe: [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: Delete unnecessary checks before the function call "kfree_skb"
Quoted 6 lines · On Sunday, November 15, 2015 09:43:26 SF Markus Elfring wrote:
From: Markus Elfring <[email protected]>
Date: Sun, 15 Nov 2015 08:04:43 +0100The
kfree_skb()function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.
Quoted 8 lines
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- net/batman-adv/main.c | 2 +- net/batman-adv/network-coding.c | 4 +--- net/batman-adv/send.c | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-)
Applied in revision 77d84a6.
Thanks,
Marek
Marek Lindner
AppliedRe: [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: Delete unnecessary checks before the function call "kfree_skb"
In reply to SF Markus ElfringQuoted 6 lines · On Sunday, November 15, 2015 09:43:26 SF Markus Elfring wrote:
From: Markus Elfring <[email protected]>
Date: Sun, 15 Nov 2015 08:04:43 +0100The
kfree_skb()function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.
Quoted 8 lines
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- net/batman-adv/main.c | 2 +- net/batman-adv/network-coding.c | 4 +--- net/batman-adv/send.c | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-)
Applied in revision 77d84a6.
Thanks,
Marek
PATCH 2/2 batman-adv: Less checks in batadv_tvlv_unicast_send()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 15 Nov 2015 09:00:42 +0100
* Let us return directly if a call of the batadv_orig_hash_find() function returned a null pointer.
* Omit the initialisation for the variable "skb" at the beginning.
* Replace an assignment by a call of the kfree_skb() function and delete the affected variable "ret" then.
--- net/batman-adv/main.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
net/batman-adv/main.c +5 -10
@@ -1143,15 +1143,14 @@ void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, u8 *src,struct batadv_unicast_tvlv_packet *unicast_tvlv_packet;struct batadv_tvlv_hdr *tvlv_hdr;struct batadv_orig_node *orig_node; -struct sk_buff *skb =NULL ; +struct sk_buff *skb;unsigned char *tvlv_buff;unsigned int tvlv_len;ssize_t hdr_len =sizeof (*unicast_tvlv_packet); -bool ret = false; orig_node =batadv_orig_hash_find (bat_priv, dst);if (!orig_node) - goto out; +return ; tvlv_len =sizeof (*tvlv_hdr) + tvlv_value_len;
@@ -1180,14 +1179,10 @@ void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, u8 *src, tvlv_buff +=sizeof (*tvlv_hdr);memcpy (tvlv_buff, tvlv_value, tvlv_value_len); -if (batadv_send_skb_to_orig (skb, orig_node,NULL ) !=NET_XMIT_DROP ) - ret = true; - -out: -if (!ret) +if (batadv_send_skb_to_orig (skb, orig_node,NULL ) ==NET_XMIT_DROP )kfree_skb (skb); -if (orig_node) -batadv_orig_node_free_ref (orig_node); +out: +batadv_orig_node_free_ref (orig_node); }/**
Signature · 1 line
2.6.2
Marek Lindner
AppliedRe: [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: Less checks in batadv_tvlv_unicast_send()
Quoted 8 lines · On Sunday, November 15, 2015 09:45:51 SF Markus Elfring wrote:
From: Markus Elfring <[email protected]>
Date: Sun, 15 Nov 2015 09:00:42 +0100* Let us return directly if a call of the
batadv_orig_hash_find()function returned a null pointer.* Omit the initialisation for the variable "skb" at the beginning.
Quoted 7 lines
* Replace an assignment by a call of the
kfree_skb()function and delete the affected variable "ret" then.Signed-off-by Markus Elfring <[email protected]>--- net/batman-adv/main.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
Applied in revision 5a878b8.
Thanks,
Marek
Marek Lindner
AppliedRe: [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: Less checks in batadv_tvlv_unicast_send()
In reply to SF Markus ElfringQuoted 8 lines · On Sunday, November 15, 2015 09:45:51 SF Markus Elfring wrote:
From: Markus Elfring <[email protected]>
Date: Sun, 15 Nov 2015 09:00:42 +0100* Let us return directly if a call of the
batadv_orig_hash_find()function returned a null pointer.* Omit the initialisation for the variable "skb" at the beginning.
Quoted 7 lines
* Replace an assignment by a call of the
kfree_skb()function and delete the affected variable "ret" then.Signed-off-by Markus Elfring <[email protected]>--- net/batman-adv/main.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
Applied in revision 5a878b8.
Thanks,
Marek
PATCH 1/1 KVM-async_pf: Delete an unnecessary check before the function call "kmem_cache_destroy"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 15 Nov 2015 10:40:36 +0100
The kmem_cache_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- virt/kvm/async_pf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
virt/kvm/async_pf.c +1 -2
@@ -57,8 +57,7 @@ int kvm_async_pf_init(void)void kvm_async_pf_deinit (void ) { -if (async_pf_cache) -kmem_cache_destroy (async_pf_cache); +kmem_cache_destroy (async_pf_cache); async_pf_cache =NULL ; }
Signature · 1 line
2.6.2
Re: [PATCH] KVM-async_pf: Delete an unnecessary check before the function call "kmem_cache_destroy"
Quoted 19 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 15 Nov 2015 10:40:36 +0100The
kmem_cache_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- virt/kvm/async_pf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)virt/kvm/async_pf.c +0
-0
virt/kvm/async_pf.c int kvm_async_pf_init(void) · line 63
Quoted 9 lines
virt/kvm/async_pf.c +1
-2@@ -57,8 +57,7 @@ int kvm_async_pf_init(void)void kvm_async_pf_deinit (void ) { -if (async_pf_cache) -kmem_cache_destroy (async_pf_cache); +kmem_cache_destroy (async_pf_cache); async_pf_cache =NULL ; }
Applied to kvm/queue, thanks.
Paolo
PATCH 1/1 kernel-audit: Delete unnecessary checks before two function calls
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 15 Nov 2015 12:38:33 +0100
The functions consume_skb() and kfree_skb() test whether their argument is NULL and then return immediately.
Thus the tests around their calls are not needed.
This issue was detected by using the Coccinelle software.
--- kernel/audit.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
kernel/audit.c +2 -5
@@ -509,8 +509,7 @@ static void flush_hold_queue(void)* if auditd just disappeared but we * dequeued an skb we need to drop ref */ -if (skb) -consume_skb (skb); +consume_skb (skb); }static int kauditd_thread (void *dummy)
@@ -1232,9 +1231,7 @@ static void audit_buffer_free(struct audit_buffer *ab)if (!ab)return ; -if (ab->skb) -kfree_skb (ab->skb); - +kfree_skb (ab->skb);spin_lock_irqsave (&audit_freelist_lock, flags);if (audit_freelist_count >AUDIT_MAXFREE )kfree (ab);
Signature · 1 line
2.6.2
Re: [PATCH] kernel-audit: Delete unnecessary checks before two function calls
Quoted 7 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 15 Nov 2015 12:38:33 +0100The functions
consume_skb()andkfree_skb()test whether their argument is NULL and then return immediately.
Thus the tests around their calls are not needed.
Quoted 6 lines
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- kernel/audit.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
Merged, thanks.
Quoted 25 lines
kernel/audit.c +2
-5@@ -509,8 +509,7 @@ static void flush_hold_queue(void)* if auditd just disappeared but we * dequeued an skb we need to drop ref */ -if (skb) -consume_skb (skb); +consume_skb (skb); }static int kauditd_thread (void *dummy)@@ -1232,9 +1231,7 @@ static void audit_buffer_free(struct audit_buffer *ab)if (!ab)return ; -if (ab->skb) -kfree_skb (ab->skb); - +kfree_skb (ab->skb);spin_lock_irqsave (&audit_freelist_lock, flags);if (audit_freelist_count >AUDIT_MAXFREE )kfree (ab);
Signature · 2 lines
paul moore www.paul-moore.com
cover crypto-ixp4xx: Deletion of a few unnecessary checks
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 15 Nov 2015 19:39:00 +0100
Further update suggestions were taken into account after a patch was applied from static source code analysis.
Markus Elfring (4):
Delete unnecessary checks before the function call "dma_pool_destroy" Two function calls less in init_ixp_crypto() after error detection Reduce assignment for a variable in init_ixp_crypto()
Less function calls in init_ixp_crypto() after error detection
drivers/crypto/ixp4xx_crypto.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
Signature · 1 line
2.6.2
PATCH 1/4 crypto-ixp4xx: Delete unnecessary checks before the function call "dma_pool_destroy"
From: Markus Elfring <[email protected]>
Date: Sun, 15 Nov 2015 16:51:21 +0100
The dma_pool_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/crypto/ixp4xx_crypto.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/crypto/ixp4xx_crypto.c +2 -4
@@ -510,10 +510,8 @@ npe_error:printk (KERN_ERR "%s not responding\n" ,npe_name (npe_c)); ret = -EIO ; err: -if (ctx_pool) -dma_pool_destroy (ctx_pool); -if (buffer_pool) -dma_pool_destroy (buffer_pool); +dma_pool_destroy (ctx_pool); +dma_pool_destroy (buffer_pool);npe_release (npe_c);return ret; }
Signature · 1 line
2.6.2
Herbert Xu
maintainerRe: [PATCH 1/4] crypto-ixp4xx: Delete unnecessary checks before the function call "dma_pool_destroy"
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 15 Nov 2015 16:51:21 +0100The
dma_pool_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
PATCH 2/4 crypto-ixp4xx: Two function calls less in init_ixp_crypto() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 15 Nov 2015 18:28:39 +0100
The dma_pool_destroy() function was called twice with a null pointer if a "npe_error" was reported.
This implementation detail could be improved by the introduction of another jump label.
--- drivers/crypto/ixp4xx_crypto.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/crypto/ixp4xx_crypto.c +2 -0
@@ -509,9 +509,11 @@ static int init_ixp_crypto(struct device *dev) npe_error:printk (KERN_ERR "%s not responding\n" ,npe_name (npe_c)); ret = -EIO ; + goto release_npe; err:dma_pool_destroy (ctx_pool);dma_pool_destroy (buffer_pool); +release_npe:npe_release (npe_c);return ret; }
Signature · 1 line
2.6.2
Herbert Xu
maintainerRe: [PATCH 2/4] crypto-ixp4xx: Two function calls less in init_ixp_crypto() after error detection
Quoted 19 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 15 Nov 2015 18:28:39 +0100The
dma_pool_destroy()function was called twice with a null pointer if a "npe_error" was reported.This implementation detail could be improved by the introduction of another jump label.
Signed-off-by Markus Elfring <[email protected]>--- drivers/crypto/ixp4xx_crypto.c | 2 ++ 1 file changed, 2 insertions(+)drivers/crypto/ixp4xx_crypto.c +0
-0
drivers/crypto/ixp4xx_crypto.c static int init_ixp_crypto(struct device *dev) · line 518
Quoted 10 lines
drivers/crypto/ixp4xx_crypto.c +2
-0@@ -509,9 +509,11 @@ static int init_ixp_crypto(struct device *dev) npe_error:printk (KERN_ERR "%s not responding\n" ,npe_name (npe_c)); ret = -EIO ; + goto release_npe; err:dma_pool_destroy (ctx_pool);dma_pool_destroy (buffer_pool); +release_npe:npe_release (npe_c);return ret;
I think this patch is making the code worse so I'm not applying it.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
PATCH 3/4 crypto-ixp4xx: Reduce assignment for a variable in init_ixp_crypto()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 15 Nov 2015 19:06:44 +0100
The variable "ret" was set more often than necessary by the init_ixp_crypto() function.
* Omit its initialisation at the beginning.
* Use an error return code in two cases directly.
* Improve compliance with the Linux coding style convention.
--- drivers/crypto/ixp4xx_crypto.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/crypto/ixp4xx_crypto.c +5 -4
@@ -433,17 +433,17 @@ static void crypto_done_action(unsigned long arg)static int init_ixp_crypto (struct device *dev) { -int ret = -ENODEV ; +int ret;u32 msg[2 ] = {0 ,0 };if (! ( ~(*IXP4XX_EXP_CFG2 ) & (IXP4XX_FEATURE_HASH |IXP4XX_FEATURE_AES |IXP4XX_FEATURE_DES ))) {printk (KERN_ERR "ixp_crypto: No HW crypto available\n" ); -return ret; +return -ENODEV ; } npe_c =npe_request (NPE_ID );if (!npe_c) -return ret; +return -ENODEV ;if (!npe_running (npe_c)) { ret =npe_load_firmware (npe_c,npe_name (npe_c), dev);
@@ -481,13 +481,14 @@ static int init_ixp_crypto(struct device *dev)BUILD_BUG_ON (SHA1_DIGEST_SIZE >sizeof (struct buffer_desc )); buffer_pool =dma_pool_create ("buffer" , dev,sizeof (struct buffer_desc ),32 ,0 ); - ret = -ENOMEM ;if (!buffer_pool) { + ret = -ENOMEM ; goto err; } ctx_pool =dma_pool_create ("context" , dev,NPE_CTX_LEN ,16 ,0 );if (!ctx_pool) { + ret = -ENOMEM ; goto err; } ret = qmgr_request_queue(SEND_QID, NPE_QLEN_TOTAL, 0, 0,
Signature · 1 line
2.6.2
Herbert Xu
maintainerRe: [PATCH 3/4] crypto-ixp4xx: Reduce assignment for a variable in init_ixp_crypto()
Quoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 15 Nov 2015 19:06:44 +0100The variable "ret" was set more often than necessary by the
init_ixp_crypto()function.
Quoted 7 lines
* Omit its initialisation at the beginning.
* Use an error return code in two cases directly.
* Improve compliance with the Linux coding style convention.
Signed-off-by Markus Elfring <[email protected]>
Again I don't see how this is making the code better so nack.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
PATCH 4/4 crypto-ixp4xx: Less function calls in init_ixp_crypto() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 15 Nov 2015 19:23:55 +0100
The dma_pool_destroy() function was called in up to two cases by the init_ixp_crypto() function during error handling even if a call of the dma_pool_create() function failed.
This implementation detail could be improved by the adjustment of jump targets according to the Linux coding style convention.
--- drivers/crypto/ixp4xx_crypto.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/crypto/ixp4xx_crypto.c +6 -5
@@ -483,23 +483,23 @@ static int init_ixp_crypto(struct device *dev) sizeof(struct buffer_desc), 32, 0);if (!buffer_pool) { ret = -ENOMEM ; - goto err; + goto release_npe; } ctx_pool =dma_pool_create ("context" , dev,NPE_CTX_LEN ,16 ,0 );if (!ctx_pool) { ret = -ENOMEM ; - goto err; + goto destroy_buffer_pool; } ret =qmgr_request_queue (SEND_QID ,NPE_QLEN_TOTAL ,0 ,0 ,"ixp_crypto:out" ,NULL );if (ret) - goto err; + goto destroy_ctx_pool; ret =qmgr_request_queue (RECV_QID ,NPE_QLEN ,0 ,0 ,"ixp_crypto:in" ,NULL );if (ret) {qmgr_release_queue (SEND_QID ); - goto err; + goto destroy_ctx_pool; }qmgr_set_irq (RECV_QID ,QUEUE_IRQ_SRC_NOT_EMPTY , irqhandler,NULL );tasklet_init (&crypto_done_tasklet, crypto_done_action,0 );
@@ -511,8 +511,9 @@ npe_error:printk (KERN_ERR "%s not responding\n" ,npe_name (npe_c)); ret = -EIO ; goto release_npe; -err: +destroy_ctx_pool:dma_pool_destroy (ctx_pool); +destroy_buffer_pool:dma_pool_destroy (buffer_pool); release_npe:npe_release (npe_c);
Signature · 1 line
2.6.2
v2 cover crypto-ixp4xx: Deletion of a few unnecessary checks
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 17 Nov 2015 16:26:01 +0100
Subject: [PATCH 0/3] crypto-ixp4xx: Deletion of a few unnecessary checks
Further update suggestions were taken into account after a patch was applied from static source code analysis.
Markus Elfring (3):
Delete unnecessary checks before the function call "dma_pool_destroy" Reduce assignment for a variable in init_ixp_crypto()
crypto-ixp4xx: Less function calls in init_ixp_crypto() after error detection
drivers/crypto/ixp4xx_crypto.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
Signature · 1 line
2.6.2
PATCH v2 1/3 crypto-ixp4xx: Delete unnecessary checks before the function call "dma_pool_destroy"
From: Markus Elfring <[email protected]>
Date: Sun, 15 Nov 2015 16:51:21 +0100
The dma_pool_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/crypto/ixp4xx_crypto.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/crypto/ixp4xx_crypto.c +2 -4
@@ -510,10 +510,8 @@ npe_error:printk (KERN_ERR "%s not responding\n" ,npe_name (npe_c)); ret = -EIO ; err: -if (ctx_pool) -dma_pool_destroy (ctx_pool); -if (buffer_pool) -dma_pool_destroy (buffer_pool); +dma_pool_destroy (ctx_pool); +dma_pool_destroy (buffer_pool);npe_release (npe_c);return ret; }
Signature · 1 line
2.6.2
PATCH v2 2/3 crypto-ixp4xx: Reduce assignment for a variable in init_ixp_crypto()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 17 Nov 2015 15:45:32 +0100
The variable "ret" was set more often than necessary by the init_ixp_crypto() function.
* Omit its initialisation at the beginning.
* Use an error return code in two cases directly.
* Improve compliance with the Linux coding style convention.
--- drivers/crypto/ixp4xx_crypto.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/crypto/ixp4xx_crypto.c +5 -4
@@ -433,17 +433,17 @@ static void crypto_done_action(unsigned long arg)static int init_ixp_crypto (struct device *dev) { -int ret = -ENODEV ; +int ret;u32 msg[2 ] = {0 ,0 };if (! ( ~(*IXP4XX_EXP_CFG2 ) & (IXP4XX_FEATURE_HASH |IXP4XX_FEATURE_AES |IXP4XX_FEATURE_DES ))) {printk (KERN_ERR "ixp_crypto: No HW crypto available\n" ); -return ret; +return -ENODEV ; } npe_c =npe_request (NPE_ID );if (!npe_c) -return ret; +return -ENODEV ;if (!npe_running (npe_c)) { ret =npe_load_firmware (npe_c,npe_name (npe_c), dev);
@@ -481,13 +481,14 @@ static int init_ixp_crypto(struct device *dev)BUILD_BUG_ON (SHA1_DIGEST_SIZE >sizeof (struct buffer_desc )); buffer_pool =dma_pool_create ("buffer" , dev,sizeof (struct buffer_desc ),32 ,0 ); - ret = -ENOMEM ;if (!buffer_pool) { + ret = -ENOMEM ; goto err; } ctx_pool =dma_pool_create ("context" , dev,NPE_CTX_LEN ,16 ,0 );if (!ctx_pool) { + ret = -ENOMEM ; goto err; } ret = qmgr_request_queue(SEND_QID, NPE_QLEN_TOTAL, 0, 0,
Signature · 1 line
2.6.2
PATCH v2 3/3 crypto-ixp4xx: Less function calls in init_ixp_crypto() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 17 Nov 2015 16:15:21 +0100
The dma_pool_destroy() function was called in up to two cases by the init_ixp_crypto() function during error handling even if a call of the dma_pool_create() function failed.
This implementation detail could be improved by the adjustment of jump targets according to the Linux coding style convention.
--- drivers/crypto/ixp4xx_crypto.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/crypto/ixp4xx_crypto.c +7 -5
@@ -483,23 +483,23 @@ static int init_ixp_crypto(struct device *dev) sizeof(struct buffer_desc), 32, 0);if (!buffer_pool) { ret = -ENOMEM ; - goto err; + goto release_npe; } ctx_pool =dma_pool_create ("context" , dev,NPE_CTX_LEN ,16 ,0 );if (!ctx_pool) { ret = -ENOMEM ; - goto err; + goto destroy_buffer_pool; } ret =qmgr_request_queue (SEND_QID ,NPE_QLEN_TOTAL ,0 ,0 ,"ixp_crypto:out" ,NULL );if (ret) - goto err; + goto destroy_ctx_pool; ret =qmgr_request_queue (RECV_QID ,NPE_QLEN ,0 ,0 ,"ixp_crypto:in" ,NULL );if (ret) {qmgr_release_queue (SEND_QID ); - goto err; + goto destroy_ctx_pool; }qmgr_set_irq (RECV_QID ,QUEUE_IRQ_SRC_NOT_EMPTY , irqhandler,NULL );tasklet_init (&crypto_done_tasklet, crypto_done_action,0 );
@@ -510,9 +510,11 @@ static int init_ixp_crypto(struct device *dev) npe_error:printk (KERN_ERR "%s not responding\n" ,npe_name (npe_c)); ret = -EIO ; -err: +destroy_ctx_pool:dma_pool_destroy (ctx_pool); +destroy_buffer_pool:dma_pool_destroy (buffer_pool); +release_npe:npe_release (npe_c);return ret; }
Signature · 1 line
2.6.2
Herbert Xu
maintainerRe: [PATCH v2 0/3] crypto-ixp4xx: Deletion of a few unnecessary checks
In reply to SF Markus ElfringQuoted 11 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 17 Nov 2015 16:26:01 +0100
Subject: [PATCH 0/3] crypto-ixp4xx: Deletion of a few unnecessary checksFurther update suggestions were taken into account after a patch was applied from static source code analysis.
Markus Elfring (3):
Delete unnecessary checks before the function call "dma_pool_destroy" Reduce assignment for a variable ininit_ixp_crypto()
crypto-ixp4xx: Less function calls ininit_ixp_crypto()after error detection
You completely ignored my comments. Nack.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Re: crypto-ixp4xx: Deletion of a few unnecessary checks
Quoted 1 line
Quoted 1 line
Delete unnecessary checks before the function call "
dma_pool_destroy"
It seems that you accepted this specific update suggestion, didn't you?
https://lkml.org/lkml/2015/11/17/391
https://www.mail-archive.com/[email protected]/msg1021951.html
Quoted 4 lines
Quoted 2 lines
Reduce assignment for a variable in
init_ixp_crypto()
crypto-ixp4xx: Less function calls ininit_ixp_crypto()after error detectionYou completely ignored my comments. Nack.
Will it be useful to clarify the proposed changes a bit more?
Regards,
Markus
PATCH 1/1 staging-EHCA: Delete unnecessary checks before the function call "kmem_cache_destroy"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 15 Nov 2015 21:58:45 +0100
The kmem_cache_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/staging/rdma/ehca/ehca_av.c | 3 +-- drivers/staging/rdma/ehca/ehca_cq.c | 3 +-- drivers/staging/rdma/ehca/ehca_main.c | 3 +-- drivers/staging/rdma/ehca/ehca_mrmw.c | 6 ++---- drivers/staging/rdma/ehca/ehca_pd.c | 3 +-- drivers/staging/rdma/ehca/ehca_qp.c | 3 +-- 6 files changed, 7 insertions(+), 14 deletions(-)
drivers/staging/rdma/ehca/ehca_av.c +1 -2
@@ -272,6 +272,5 @@ int ehca_init_av_cache(void)void ehca_cleanup_av_cache (void ) { -if (av_cache) -kmem_cache_destroy (av_cache); +kmem_cache_destroy (av_cache); }
drivers/staging/rdma/ehca/ehca_cq.c +1 -2
@@ -393,6 +393,5 @@ int ehca_init_cq_cache(void)void ehca_cleanup_cq_cache (void ) { -if (cq_cache) -kmem_cache_destroy (cq_cache); +kmem_cache_destroy (cq_cache); }
drivers/staging/rdma/ehca/ehca_main.c +1 -2
@@ -245,8 +245,7 @@ static void ehca_destroy_slab_caches(void)ehca_cleanup_cq_cache ();ehca_cleanup_pd_cache ();#ifdef CONFIG_PPC_64K_PAGES -if (ctblk_cache) -kmem_cache_destroy (ctblk_cache); +kmem_cache_destroy (ctblk_cache);#endif }
drivers/staging/rdma/ehca/ehca_mrmw.c +2 -4
@@ -2251,10 +2251,8 @@ int ehca_init_mrmw_cache(void)void ehca_cleanup_mrmw_cache (void ) { -if (mr_cache) -kmem_cache_destroy (mr_cache); -if (mw_cache) -kmem_cache_destroy (mw_cache); +kmem_cache_destroy (mr_cache); +kmem_cache_destroy (mw_cache); } static inline int ehca_init_top_bmap(struct ehca_top_bmap *ehca_top_bmap,
drivers/staging/rdma/ehca/ehca_pd.c +1 -2
@@ -119,6 +119,5 @@ int ehca_init_pd_cache(void)void ehca_cleanup_pd_cache (void ) { -if (pd_cache) -kmem_cache_destroy (pd_cache); +kmem_cache_destroy (pd_cache); }
drivers/staging/rdma/ehca/ehca_qp.c +1 -2
@@ -2252,6 +2252,5 @@ int ehca_init_qp_cache(void)void ehca_cleanup_qp_cache (void ) { -if (qp_cache) -kmem_cache_destroy (qp_cache); +kmem_cache_destroy (qp_cache); }
Signature · 1 line
2.6.2
PATCH 1/1 ACPI-EC: Delete an unnecessary check before the function call "acpi_ec_delete_query"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 15 Nov 2015 22:42:27 +0100
The acpi_ec_delete_query() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/acpi/ec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/ec.c +1 -1
@@ -1103,7 +1103,7 @@ static int acpi_ec_query(struct acpi_ec *ec, u8 *data) } err_exit: -if (result && q) +if (result)acpi_ec_delete_query (q);if (data) *data = value;
Signature · 1 line
2.6.2
PATCH 1/1 sh-DWARF: Delete unnecessary checks before the function call "mempool_destroy"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 08:20:36 +0100
The mempool_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- arch/sh/kernel/dwarf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
arch/sh/kernel/dwarf.c +2 -4
@@ -1009,10 +1009,8 @@ static void __init dwarf_unwinder_cleanup(void)rbtree_postorder_for_each_entry_safe (cie, next_cie, &cie_root, node)kfree (cie); -if (dwarf_reg_pool) -mempool_destroy (dwarf_reg_pool); -if (dwarf_frame_pool) -mempool_destroy (dwarf_frame_pool); +mempool_destroy (dwarf_reg_pool); +mempool_destroy (dwarf_frame_pool);kmem_cache_destroy (dwarf_reg_cachep);kmem_cache_destroy (dwarf_frame_cachep); }
Signature · 1 line
2.6.2
Re: [PATCH] sh-DWARF: Delete unnecessary checks before the function call "mempool_destroy"
Quoted 21 lines
From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 08:20:36 +0100The
mempool_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- arch/sh/kernel/dwarf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)arch/sh/kernel/dwarf.c +0
-0@@ -1009,10 +1009,8 @@ static void __init dwarf_unwinder_cleanup(void)rbtree_postorder_for_each_entry_safe (cie, next_cie, &cie_root, node)kfree (cie);
arch/sh/kernel/dwarf.c static void __init dwarf_unwinder_cleanup(void) · line 1016
Quoted 10 lines
arch/sh/kernel/dwarf.c +2
-4-if (dwarf_reg_pool) -mempool_destroy (dwarf_reg_pool); -if (dwarf_frame_pool) -mempool_destroy (dwarf_frame_pool); +mempool_destroy (dwarf_reg_pool); +mempool_destroy (dwarf_frame_pool);kmem_cache_destroy (dwarf_reg_cachep);kmem_cache_destroy (dwarf_frame_cachep); }
How do you think about to integrate this update suggestion into another source code repository?
Regards,
Markus
Re: [PATCH] sh-DWARF: Delete unnecessary checks before the function call "mempool_destroy"
Quoted 21 lines · SF Markus Elfring
Quoted 21 lines
From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 08:20:36 +0100The
mempool_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- arch/sh/kernel/dwarf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)arch/sh/kernel/dwarf.c +0
-0@@ -1009,10 +1009,8 @@ static void __init dwarf_unwinder_cleanup(void)rbtree_postorder_for_each_entry_safe (cie, next_cie, &cie_root, node)kfree (cie);
Quoted 14 lines
arch/sh/kernel/dwarf.c static void __init dwarf_unwinder_cleanup(void) · line 1016
Quoted 10 lines
arch/sh/kernel/dwarf.c +2
-4-if (dwarf_reg_pool) -mempool_destroy (dwarf_reg_pool); -if (dwarf_frame_pool) -mempool_destroy (dwarf_frame_pool); +mempool_destroy (dwarf_reg_pool); +mempool_destroy (dwarf_frame_pool);kmem_cache_destroy (dwarf_reg_cachep);kmem_cache_destroy (dwarf_frame_cachep); }How do you think about to integrate this update suggestion into another source code repository?
Your patch is fine, but you may want to send it to the maintainers directly to merge.
$ ./scripts/get_maintainer.pl -f arch/sh/kernel/dwarf.c Yoshinori Sato <[email protected]> (maintainer:SUPERH) Rich Felker <[email protected]> (maintainer:SUPERH) [email protected] (open list:SUPERH) [email protected] (open list)
Re: [PATCH] sh-DWARF: Delete unnecessary checks before the function call "mempool_destroy"
In reply to SF Markus ElfringQuoted 21 lines
From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 08:20:36 +0100The
mempool_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- arch/sh/kernel/dwarf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)arch/sh/kernel/dwarf.c +0
-0@@ -1009,10 +1009,8 @@ static void __init dwarf_unwinder_cleanup(void)rbtree_postorder_for_each_entry_safe (cie, next_cie, &cie_root, node)kfree (cie);
arch/sh/kernel/dwarf.c static void __init dwarf_unwinder_cleanup(void) · line 1016
Quoted 10 lines
arch/sh/kernel/dwarf.c +2
-4-if (dwarf_reg_pool) -mempool_destroy (dwarf_reg_pool); -if (dwarf_frame_pool) -mempool_destroy (dwarf_frame_pool); +mempool_destroy (dwarf_reg_pool); +mempool_destroy (dwarf_frame_pool);kmem_cache_destroy (dwarf_reg_cachep);kmem_cache_destroy (dwarf_frame_cachep); }
Would you like to integrate this update suggestion into another source code repository?
Regards,
Markus
Rich Felker
maintainerRe: [PATCH] sh-DWARF: Delete unnecessary checks before the function call "mempool_destroy"
Quoted 21 lines · SF Markus Elfring
Quoted 21 lines
From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 08:20:36 +0100The
mempool_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- arch/sh/kernel/dwarf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)arch/sh/kernel/dwarf.c +0
-0@@ -1009,10 +1009,8 @@ static void __init dwarf_unwinder_cleanup(void)rbtree_postorder_for_each_entry_safe (cie, next_cie, &cie_root, node)kfree (cie);
Quoted 13 lines
arch/sh/kernel/dwarf.c static void __init dwarf_unwinder_cleanup(void) · line 1016
Quoted 10 lines
arch/sh/kernel/dwarf.c +2
-4-if (dwarf_reg_pool) -mempool_destroy (dwarf_reg_pool); -if (dwarf_frame_pool) -mempool_destroy (dwarf_frame_pool); +mempool_destroy (dwarf_reg_pool); +mempool_destroy (dwarf_frame_pool);kmem_cache_destroy (dwarf_reg_cachep);kmem_cache_destroy (dwarf_frame_cachep); }Would you like to integrate this update suggestion into another source code repository?
Looks OK. I have it in my linux-sh tree to go upstream.
Rich
PATCH 1/1 SCSI-libfc: Delete an unnecessary check before the function call "kmem_cache_destroy"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 09:39:12 +0100
The kmem_cache_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/scsi/libfc/fc_fcp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/libfc/fc_fcp.c +1 -2
@@ -2216,8 +2216,7 @@ int fc_setup_fcp(void)void fc_destroy_fcp (void ) { -if (scsi_pkt_cachep) -kmem_cache_destroy (scsi_pkt_cachep); +kmem_cache_destroy (scsi_pkt_cachep); }/**
Signature · 1 line
2.6.2
Re: [PATCH] SCSI-libfc: Delete an unnecessary check before the function call "kmem_cache_destroy"
Quoted 18 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 09:39:12 +0100The
kmem_cache_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/scsi/libfc/fc_fcp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/scsi/libfc/fc_fcp.c +0
-0
drivers/scsi/libfc/fc_fcp.c int fc_setup_fcp(void) · line 2222
Quoted 9 lines
drivers/scsi/libfc/fc_fcp.c +1
-2@@ -2216,8 +2216,7 @@ int fc_setup_fcp(void)void fc_destroy_fcp (void ) { -if (scsi_pkt_cachep) -kmem_cache_destroy (scsi_pkt_cachep); +kmem_cache_destroy (scsi_pkt_cachep); }/**
Looks good.
cover mISDN: Deletion of an unnecessary check
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 10:40:11 +0100
Another update suggestion was taken into account after a patch was applied from static source code analysis.
Markus Elfring (2):
Delete an unnecessary check before the function call "kfree_skb" One function call less in mISDN_sock_sendmsg() after error detection
drivers/isdn/mISDN/socket.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
2.6.2
PATCH 1/2 mISDN: Delete an unnecessary check before the function call "kfree_skb"
From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 10:10:53 +0100
The kfree_skb() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/isdn/mISDN/socket.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/isdn/mISDN/socket.c +1 -2
@@ -236,8 +236,7 @@ mISDN_sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) } done: -if (skb) -kfree_skb (skb); +kfree_skb (skb);release_sock (sk);return err; }
Signature · 1 line
2.6.2
PATCH 2/2 mISDN: One function call less in mISDN_sock_sendmsg() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 10:30:29 +0100
The kfree_skb() function was called in one case by the mISDN_sock_sendmsg() function during error handling even if a call of the _l2_alloc_skb() function returned a null pointer.
This implementation detail could be improved by the introduction of another jump label.
--- drivers/isdn/mISDN/socket.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/isdn/mISDN/socket.c +2 -1
@@ -200,7 +200,7 @@ mISDN_sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) skb =_l2_alloc_skb (len,GFP_KERNEL );if (!skb) - goto done; + goto release_socket;if (memcpy_from_msg (skb_put (skb, len), msg, len)) { err = -EFAULT ;
@@ -237,6 +237,7 @@ mISDN_sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) done:kfree_skb (skb); +release_socket:release_sock (sk);return err; }
Signature · 1 line
2.6.2
PATCH 1/1 WiMAX-i2400m: Delete an unnecessary check before the function call "kfree_skb"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 11:17:55 +0100
The kfree_skb() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/net/wimax/i2400m/control.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wimax/i2400m/control.c +1 -1
@@ -644,7 +644,7 @@ void i2400m_msg_to_dev_cancel_wait(struct i2400m *i2400m, int code)spin_lock_irqsave (&i2400m->rx_lock, flags); ack_skb = i2400m->ack_skb; -if (ack_skb && !IS_ERR (ack_skb)) +if (!IS_ERR (ack_skb))kfree_skb (ack_skb); i2400m->ack_skb =ERR_PTR (code);spin_unlock_irqrestore (&i2400m->rx_lock, flags);
Signature · 1 line
2.6.2
Re: [PATCH] WiMAX-i2400m: Delete an unnecessary check before the function call "kfree_skb"
Quoted 19 lines
From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 11:17:55 +0100The
kfree_skb()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/net/wimax/i2400m/control.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/wimax/i2400m/control.c +0
-0
drivers/net/wimax/i2400m/control.c void i2400m_msg_to_dev_cancel_wait(struct i2400m *i2400m, int code) · line 650
Quoted 8 lines
drivers/net/wimax/i2400m/control.c +1
-1@@ -644,7 +644,7 @@ void i2400m_msg_to_dev_cancel_wait(struct i2400m *i2400m, int code)spin_lock_irqsave (&i2400m->rx_lock, flags); ack_skb = i2400m->ack_skb; -if (ack_skb && !IS_ERR (ack_skb)) +if (!IS_ERR (ack_skb))kfree_skb (ack_skb); i2400m->ack_skb =ERR_PTR (code);spin_unlock_irqrestore (&i2400m->rx_lock, flags);
How do you think about to integrate this update suggestion into another source code repository?
Regards,
Markus
PATCH 1/1 ixp4xx_eth: Delete an unnecessary check before the function call "dma_pool_destroy"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 12:23:23 +0100
The dma_pool_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/net/ethernet/xscale/ixp4xx_eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/xscale/ixp4xx_eth.c +1 -1
@@ -1192,7 +1192,7 @@ static void destroy_queues(struct port *port) port->desc_tab =NULL ; } -if (!ports_open && dma_pool) { +if (!ports_open) {dma_pool_destroy (dma_pool); dma_pool =NULL ; }
Signature · 1 line
2.6.2
Re: [PATCH] ixp4xx_eth: Delete an unnecessary check before the function call "dma_pool_destroy"
Quoted 8 lines · SF Markus Elfring
The
dma_pool_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
drivers/net/ethernet/xscale/ixp4xx_eth.c static void destroy_queues(struct port *port) · line 1198
Quoted 8 lines
drivers/net/ethernet/xscale/ixp4xx_eth.c +1
-1@@ -1192,7 +1192,7 @@ static void destroy_queues(struct port *port) port->desc_tab =NULL ; } -if (!ports_open && dma_pool) { +if (!ports_open) {dma_pool_destroy (dma_pool); dma_pool =NULL ; }
Signature · 4 lines
Krzysztof Halasa Industrial Research Institute for Automation and Measurements PIAP Al. Jerozolimskie 202, 02-486 Warsaw, Poland
PATCH 1/1 cxgb3: Delete unnecessary checks before the function call "kfree_skb"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 12:46:41 +0100
The kfree_skb() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c | 3 +-- drivers/net/ethernet/chelsio/cxgb3/cxgb3_offload.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c +1 -2
@@ -3401,8 +3401,7 @@ static void remove_one(struct pci_dev *pdev)free_netdev (adapter->port[i]);iounmap (adapter->regs); -if (adapter->nofail_skb) -kfree_skb (adapter->nofail_skb); +kfree_skb (adapter->nofail_skb);kfree (adapter);pci_release_regions (pdev);pci_disable_device (pdev);
drivers/net/ethernet/chelsio/cxgb3/cxgb3_offload.c +1 -2
@@ -1323,8 +1323,7 @@ void cxgb3_offload_deactivate(struct adapter *adapter)rcu_read_unlock ();RCU_INIT_POINTER (tdev->l2opt,NULL );call_rcu (&d->rcu_head, clean_l2_data); -if (t->nofail_skb) -kfree_skb (t->nofail_skb); +kfree_skb (t->nofail_skb);kfree (t); }
Signature · 1 line
2.6.2
PATCH 1/1 rtlwifi: Delete unnecessary checks before the function call "kfree_skb"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 13:12:25 +0100
The kfree_skb() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/net/wireless/realtek/rtlwifi/core.c | 3 +-- drivers/net/wireless/realtek/rtlwifi/rtl8723com/fw_common.c | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/net/wireless/realtek/rtlwifi/core.c +1 -2
@@ -1833,8 +1833,7 @@ bool rtl_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb)spin_lock_irqsave (&rtlpriv->locks.irq_th_lock, flags); pskb =__skb_dequeue (&ring->queue); -if (pskb) -kfree_skb (pskb); +kfree_skb (pskb);/*this is wrong, fill_tx_cmddesc needs update*/ pdesc = &ring->desc[0 ];
drivers/net/wireless/realtek/rtlwifi/rtl8723com/fw_common.c +1 -3
@@ -318,9 +318,7 @@ bool rtl8723_cmd_send_packet(struct ieee80211_hw *hw, ring = &rtlpci->tx_ring[BEACON_QUEUE ]; pskb =__skb_dequeue (&ring->queue); -if (pskb) -kfree_skb (pskb); - +kfree_skb (pskb);spin_lock_irqsave (&rtlpriv->locks.irq_th_lock, flags); pdesc = &ring->desc[0 ];
Signature · 1 line
2.6.2
Kalle Valo
AppliedRe: rtlwifi: Delete unnecessary checks before the function call"kfree_skb"
Quoted 10 lines
From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 13:12:25 +0100The
kfree_skb()function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Thanks, applied to wireless-drivers-next.git.
Kalle Valo
PATCH 1/1 ixp4xx_hss: Delete an unnecessary check before the function call "dma_pool_destroy"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 13:30:37 +0100
The dma_pool_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/net/wan/ixp4xx_hss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wan/ixp4xx_hss.c +1 -1
@@ -1037,7 +1037,7 @@ static void destroy_hdlc_queues(struct port *port) port->desc_tab =NULL ; } -if (!ports_open && dma_pool) { +if (!ports_open) {dma_pool_destroy (dma_pool); dma_pool =NULL ; }
Signature · 1 line
2.6.2
Re: [PATCH] ixp4xx_hss: Delete an unnecessary check before the function call "dma_pool_destroy"
Quoted 8 lines · SF Markus Elfring
The
dma_pool_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
drivers/net/wan/ixp4xx_hss.c static void destroy_hdlc_queues(struct port *port) · line 1043
Quoted 8 lines
drivers/net/wan/ixp4xx_hss.c +1
-1@@ -1037,7 +1037,7 @@ static void destroy_hdlc_queues(struct port *port) port->desc_tab =NULL ; } -if (!ports_open && dma_pool) { +if (!ports_open) {dma_pool_destroy (dma_pool); dma_pool =NULL ; }
Signature · 4 lines
Krzysztof Halasa Industrial Research Institute for Automation and Measurements PIAP Al. Jerozolimskie 202, 02-486 Warsaw, Poland
PATCH 1/1 ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 13:50:23 +0100
The kfree_skb() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/net/ieee802154/atusb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ieee802154/atusb.c +1 -2
@@ -310,8 +310,7 @@ static void atusb_free_urbs(struct atusb *atusb) urb =usb_get_from_anchor (&atusb->idle_urbs);if (!urb)break ; -if (urb->context) -kfree_skb (urb->context); +kfree_skb (urb->context);usb_free_urb (urb); } }
Signature · 1 line
2.6.2
Re: [PATCH] ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
Hello.
Quoted 18 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 13:50:23 +0100The
kfree_skb()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/net/ieee802154/atusb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/net/ieee802154/atusb.c +0
-0
drivers/net/ieee802154/atusb.c static void atusb_free_urbs(struct atusb *atusb) · line 316
Quoted 9 lines
drivers/net/ieee802154/atusb.c +1
-2@@ -310,8 +310,7 @@ static void atusb_free_urbs(struct atusb *atusb) urb =usb_get_from_anchor (&atusb->idle_urbs);if (!urb)break ; -if (urb->context) -kfree_skb (urb->context); +kfree_skb (urb->context);usb_free_urb (urb); } }
regards
Stefan Schmidt
Marcel Holtmann
maintainerRe: [PATCH] ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
Hi Stefan,
Quoted 10 lines
Quoted 10 lines
The
kfree_skb()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/net/ieee802154/atusb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Quoted 16 lines
Quoted 5 lines
drivers/net/ieee802154/atusb.c +0
-0drivers/net/ieee802154/atusb.c static void atusb_free_urbs(struct atusb *atusb) · line 316
Quoted 9 lines
drivers/net/ieee802154/atusb.c +1
-2@@ -310,8 +310,7 @@ static void atusb_free_urbs(struct atusb *atusb) urb =usb_get_from_anchor (&atusb->idle_urbs);if (!urb)break ; -if (urb->context) -kfree_skb (urb->context); +kfree_skb (urb->context);usb_free_urb (urb); } }Acked-by Stefan Schmidt <[email protected]>
for some reason I am missing the original patch, can someone resend it please.
Regards
Marcel
Re: [PATCH] ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
Hello.
Quoted 27 lines · Marcel Holtmann
Hi Stefan,
Quoted 10 lines
Quoted 10 lines
The
kfree_skb()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/net/ieee802154/atusb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)Quoted 15 lines
Quoted 5 lines
drivers/net/ieee802154/atusb.c +0
-0drivers/net/ieee802154/atusb.c static void atusb_free_urbs(struct atusb *atusb) · line 316
Quoted 9 lines
drivers/net/ieee802154/atusb.c +1
-2@@ -310,8 +310,7 @@ static void atusb_free_urbs(struct atusb *atusb) urb =usb_get_from_anchor (&atusb->idle_urbs);if (!urb)break ; -if (urb->context) -kfree_skb (urb->context); +kfree_skb (urb->context);usb_free_urb (urb); } }Acked-by Stefan Schmidt <[email protected]>
Quoted 2 lines
for some reason I am missing the original patch, can someone resend it please.
Done. Resend the original message from my address but with the From line intact inside the patch. Please check if it really lists Markus as author when applying. Acked-by also resend as reply to the resend patch.
regards
Stefan Schmidt
PATCH 1/1 SCSI-zfcp: Delete unnecessary checks before the function call "mempool_destroy"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 14:19:03 +0100
The mempool_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/s390/scsi/zfcp_aux.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-)
drivers/s390/scsi/zfcp_aux.c +7 -14
@@ -248,20 +248,13 @@ static int zfcp_allocate_low_mem_buffers(struct zfcp_adapter *adapter)static void zfcp_free_low_mem_buffers (struct zfcp_adapter *adapter) { -if (adapter->pool.erp_req) -mempool_destroy (adapter->pool.erp_req); -if (adapter->pool.scsi_req) -mempool_destroy (adapter->pool.scsi_req); -if (adapter->pool.scsi_abort) -mempool_destroy (adapter->pool.scsi_abort); -if (adapter->pool.qtcb_pool) -mempool_destroy (adapter->pool.qtcb_pool); -if (adapter->pool.status_read_req) -mempool_destroy (adapter->pool.status_read_req); -if (adapter->pool.sr_data) -mempool_destroy (adapter->pool.sr_data); -if (adapter->pool.gid_pn) -mempool_destroy (adapter->pool.gid_pn); +mempool_destroy (adapter->pool.erp_req); +mempool_destroy (adapter->pool.scsi_req); +mempool_destroy (adapter->pool.scsi_abort); +mempool_destroy (adapter->pool.qtcb_pool); +mempool_destroy (adapter->pool.status_read_req); +mempool_destroy (adapter->pool.sr_data); +mempool_destroy (adapter->pool.gid_pn); }/**
Signature · 1 line
2.6.2
Re: [PATCH] SCSI-zfcp: Delete unnecessary checks before the function call "mempool_destroy"
Hej Markus,
Quoted 47 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 14:19:03 +0100The
mempool_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/s390/scsi/zfcp_aux.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-)drivers/s390/scsi/zfcp_aux.c +7
-14@@ -248,20 +248,13 @@ static int zfcp_allocate_low_mem_buffers(struct zfcp_adapter *adapter)static void zfcp_free_low_mem_buffers (struct zfcp_adapter *adapter) { -if (adapter->pool.erp_req) -mempool_destroy (adapter->pool.erp_req); -if (adapter->pool.scsi_req) -mempool_destroy (adapter->pool.scsi_req); -if (adapter->pool.scsi_abort) -mempool_destroy (adapter->pool.scsi_abort); -if (adapter->pool.qtcb_pool) -mempool_destroy (adapter->pool.qtcb_pool); -if (adapter->pool.status_read_req) -mempool_destroy (adapter->pool.status_read_req); -if (adapter->pool.sr_data) -mempool_destroy (adapter->pool.sr_data); -if (adapter->pool.gid_pn) -mempool_destroy (adapter->pool.gid_pn); +mempool_destroy (adapter->pool.erp_req); +mempool_destroy (adapter->pool.scsi_req); +mempool_destroy (adapter->pool.scsi_abort); +mempool_destroy (adapter->pool.qtcb_pool); +mempool_destroy (adapter->pool.status_read_req); +mempool_destroy (adapter->pool.sr_data); +mempool_destroy (adapter->pool.gid_pn); }/** Signature · 1 line
2.6.2
Looks good to me, will have to wait though till Steffen is back around.
Beste Grüße / Best regards,
- Benjamin Block
Signature · 4 lines
Linux on z Systems Development / IBM Systems & Technology Group IBM Deutschland Research & Development GmbH Vorsitz. AufsR.: Martina Koederitz / Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen / Registergericht: AmtsG Stuttgart, HRB 243294
Re: [PATCH] SCSI-zfcp: Delete unnecessary checks before the function call "mempool_destroy"
Markus, thanks, I queued it for next time I send features upstream. Don't hold your breath, fixes will go first.
Benjamin, thanks for the review.
Will add an informational comment that this depends on 4e3ca3e033d1 ("mm/mempool: allow NULL `pool' pointer in mempool_destroy()").
Quoted 59 lines · Benjamin Block
Hej Markus,
Quoted 46 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 14:19:03 +0100The
mempool_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/s390/scsi/zfcp_aux.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-)drivers/s390/scsi/zfcp_aux.c +7
-15@@ -248,20 +248,13 @@ static int zfcp_allocate_low_mem_buffers(struct zfcp_adapter *adapter)static void zfcp_free_low_mem_buffers (struct zfcp_adapter *adapter) { -if (adapter->pool.erp_req) -mempool_destroy (adapter->pool.erp_req); -if (adapter->pool.scsi_req) -mempool_destroy (adapter->pool.scsi_req); -if (adapter->pool.scsi_abort) -mempool_destroy (adapter->pool.scsi_abort); -if (adapter->pool.qtcb_pool) -mempool_destroy (adapter->pool.qtcb_pool); -if (adapter->pool.status_read_req) -mempool_destroy (adapter->pool.status_read_req); -if (adapter->pool.sr_data) -mempool_destroy (adapter->pool.sr_data); -if (adapter->pool.gid_pn) -mempool_destroy (adapter->pool.gid_pn); +mempool_destroy (adapter->pool.erp_req); +mempool_destroy (adapter->pool.scsi_req); +mempool_destroy (adapter->pool.scsi_abort); +mempool_destroy (adapter->pool.qtcb_pool); +mempool_destroy (adapter->pool.status_read_req); +mempool_destroy (adapter->pool.sr_data); +mempool_destroy (adapter->pool.gid_pn); }/** -- Quoted 1 line
2.6.2
Looks good to me, will have to wait though till Steffen is back around.
Reviewed-by Benjamin Block <[email protected]>Beste Grüße / Best regards,
- Benjamin Block
Signature · 15 lines
Mit freundlichen Grüßen / Kind regards Steffen Maier Linux on z Systems Development IBM Deutschland Research & Development GmbH Vorsitzende des Aufsichtsrats: Martina Koederitz Geschaeftsfuehrung: Dirk Wittkopp Sitz der Gesellschaft: Boeblingen Registergericht: Amtsgericht Stuttgart, HRB 243294 -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/1 s390: Delete unnecessary checks before the function call "debug_unregister"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 14:45:40 +0100
The debug_unregister() function performs also input parameter validation. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/s390/cio/chsc_sch.c | 3 +-- drivers/s390/cio/cio.c | 9 +++------ drivers/s390/cio/qdio_debug.c | 6 ++---- drivers/s390/crypto/zcrypt_api.c | 6 ++---- 4 files changed, 8 insertions(+), 16 deletions(-)
drivers/s390/cio/chsc_sch.c +1 -2
@@ -185,8 +185,7 @@ static int __init chsc_init_dbfs(void)debug_set_level (chsc_debug_log_id,2 );return 0 ; out: -if (chsc_debug_msg_id) -debug_unregister (chsc_debug_msg_id); +debug_unregister (chsc_debug_msg_id);return -ENOMEM ; }
drivers/s390/cio/cio.c +3 -6
@@ -76,12 +76,9 @@ static int __init cio_debug_init(void)return 0 ; out_unregister: -if (cio_debug_msg_id) -debug_unregister (cio_debug_msg_id); -if (cio_debug_trace_id) -debug_unregister (cio_debug_trace_id); -if (cio_debug_crw_id) -debug_unregister (cio_debug_crw_id); +debug_unregister (cio_debug_msg_id); +debug_unregister (cio_debug_trace_id); +debug_unregister (cio_debug_crw_id);return -1 ; }
drivers/s390/cio/qdio_debug.c +2 -4
@@ -366,8 +366,6 @@ void qdio_debug_exit(void) {qdio_clear_dbf_list ();debugfs_remove (debugfs_root); -if (qdio_dbf_setup) -debug_unregister (qdio_dbf_setup); -if (qdio_dbf_error) -debug_unregister (qdio_dbf_error); +debug_unregister (qdio_dbf_setup); +debug_unregister (qdio_dbf_error); }
drivers/s390/crypto/zcrypt_api.c +2 -4
@@ -1428,10 +1428,8 @@ int __init zcrypt_debug_init(void)void zcrypt_debug_exit (void ) {debugfs_remove (debugfs_root); -if (zcrypt_dbf_common) -debug_unregister (zcrypt_dbf_common); -if (zcrypt_dbf_devices) -debug_unregister (zcrypt_dbf_devices); +debug_unregister (zcrypt_dbf_common); +debug_unregister (zcrypt_dbf_devices); }/**
Signature · 1 line
2.6.2
Heiko Carstens
AppliedRe: [PATCH] s390: Delete unnecessary checks before the function call "debug_unregister"
Quoted 8 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 14:45:40 +0100The
debug_unregister()function performs also input parameter validation. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Quoted 7 lines
Signed-off-by Markus Elfring <[email protected]>--- drivers/s390/cio/chsc_sch.c | 3 +-- drivers/s390/cio/cio.c | 9 +++------ drivers/s390/cio/qdio_debug.c | 6 ++---- drivers/s390/crypto/zcrypt_api.c | 6 ++---- 4 files changed, 8 insertions(+), 16 deletions(-)
Applied, thanks!
PATCH 1/1 GPU-DRM-TTM: Delete an unnecessary check before the function call "ttm_tt_destroy"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 15:40:58 +0100
The ttm_tt_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/ttm/ttm_bo.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +1 -2
@@ -147,8 +147,7 @@ static void ttm_bo_release_list(struct kref *list_kref)BUG_ON (!list_empty (&bo->lru));BUG_ON (!list_empty (&bo->ddestroy)); -if (bo->ttm) -ttm_tt_destroy (bo->ttm); +ttm_tt_destroy (bo->ttm);atomic_dec (&bo->glob->bo_count);if (bo->resv = &bo->ttm_resv)reservation_object_fini (&bo->ttm_resv);
Signature · 1 line
2.6.2
PATCH 1/1 drm/ttm: Delete an unnecessary check before the function call "ttm_tt_destroy"
From: Markus Elfring <[email protected]>
Date: Fri, 15 Jul 2016 20:20:48 +0200
The ttm_tt_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
--- drivers/gpu/drm/ttm/ttm_bo.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +1 -3
@@ -146,9 +146,7 @@ static void ttm_bo_release_list(struct kref *list_kref)BUG_ON (bo->mem.mm_node !=NULL );BUG_ON (!list_empty (&bo->lru));BUG_ON (!list_empty (&bo->ddestroy)); - -if (bo->ttm) -ttm_tt_destroy (bo->ttm); +tm_tt_destroy (bo->ttm);atomic_dec (&bo->glob->bo_count);if (bo->resv = &bo->ttm_resv)reservation_object_fini (&bo->ttm_resv);
Signature · 1 line
2.9.1
Re: [PATCH] drm/ttm: Delete an unnecessary check before the function call "ttm_tt_destroy"
Quoted 16 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 15 Jul 2016 20:20:48 +0200The
ttm_tt_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.Signed-off-by Markus Elfring <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +0
-0
drivers/gpu/drm/ttm/ttm_bo.c static void ttm_bo_release_list(struct kref *list_kref) · line 149
Quoted 7 lines
drivers/gpu/drm/ttm/ttm_bo.c +1
-3@@ -146,9 +146,7 @@ static void ttm_bo_release_list(struct kref *list_kref)BUG_ON (bo->mem.mm_node !=NULL );BUG_ON (!list_empty (&bo->lru));BUG_ON (!list_empty (&bo->ddestroy)); - -if (bo->ttm) -ttm_tt_destroy (bo->ttm); +tm_tt_destroy (bo->ttm);
This doesn't compile. Tsk, pls be more careful, and definitely compile-test _all_ your changes before hitting send. I've dropped this one from my queue, the others still look ok.
-Daniel
Quoted 10 lines
drivers/gpu/drm/ttm/ttm_bo.c +0
-0atomic_dec (&bo->glob->bo_count);if (bo->resv = &bo->ttm_resv)reservation_object_fini (&bo->ttm_resv);Signature · 6 lines
2.9.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
PATCH v3 1/1 drm/ttm: Delete an unnecessary check before the function call "ttm_tt_destroy"
From: Markus Elfring <[email protected]>
Date: Mon, 18 Jul 2016 16:06:18 +0200
The ttm_tt_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/ttm/ttm_bo.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +1 -3
@@ -146,9 +146,7 @@ static void ttm_bo_release_list(struct kref *list_kref)BUG_ON (bo->mem.mm_node !=NULL );BUG_ON (!list_empty (&bo->lru));BUG_ON (!list_empty (&bo->ddestroy)); - -if (bo->ttm) -ttm_tt_destroy (bo->ttm); +ttm_tt_destroy (bo->ttm);atomic_dec (&bo->glob->bo_count);if (bo->resv = &bo->ttm_resv)reservation_object_fini (&bo->ttm_resv);
Signature · 1 line
2.9.2
Re: [PATCH v3] drm/ttm: Delete an unnecessary check before the function call "ttm_tt_destroy"
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 18 Jul 2016 16:06:18 +0200The
ttm_tt_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
When resending pls describe what changed (and why). Also I'd still like that smatch included in the commit message.
-Daniel
Quoted 22 lines
--- drivers/gpu/drm/ttm/ttm_bo.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +1
-3@@ -146,9 +146,7 @@ static void ttm_bo_release_list(struct kref *list_kref)BUG_ON (bo->mem.mm_node !=NULL );BUG_ON (!list_empty (&bo->lru));BUG_ON (!list_empty (&bo->ddestroy)); - -if (bo->ttm) -ttm_tt_destroy (bo->ttm); +ttm_tt_destroy (bo->ttm);atomic_dec (&bo->glob->bo_count);if (bo->resv = &bo->ttm_resv)reservation_object_fini (&bo->ttm_resv);Signature · 1 line
2.9.2
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Re: drm/ttm: Delete an unnecessary check before the function call "ttm_tt_destroy"
Quoted 1 line
When resending pls describe what changed (and why).
v3: A bit of reformatting with current software
v2: Broken patch where I managed to delete a "t" too much in a source code
line somehow.
v1: See also a similar update suggestion
https://lkml.org/lkml/2015/11/16/416
Would you like to pick such a software adjustment up?
Regards,
Markus
Geert Uytterhoeven
Reviewed-by Alex DeucherRe: [PATCH v3] drm/ttm: Delete an unnecessary check before the function call "ttm_tt_destroy"
In reply to Daniel VetterQuoted 7 lines · Daniel Vetter
Quoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 18 Jul 2016 16:06:18 +0200The
ttm_tt_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
Quoted 6 lines
Quoted 3 lines
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>When resending pls describe what changed (and why). Also I'd still like that smatch included in the commit message.
A similar change was made in drm-next, causing a merge conflict between the drm-next and drm-misc trees.
commit 4279cb1423d96e53b6b98ae9f2b41003b013a31f
Author: Christian König <[email protected]> Date: Mon Jun 6 10:17:51 2016 +0200
drm/ttm: remove NULL checks when calling ttm_tt_destroy
The function is a no-op with a NULL pointer.
Signature · 10 lines
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus TorvaldsRe: [PATCH v3] drm/ttm: Delete an unnecessary check before the function call "ttm_tt_destroy"
Quoted 22 lines · Geert Uytterhoeven
Quoted 7 lines · Daniel Vetter
Quoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 18 Jul 2016 16:06:18 +0200The
ttm_tt_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.Quoted 6 lines
Quoted 3 lines
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>When resending pls describe what changed (and why). Also I'd still like that smatch included in the commit message.
A similar change was made in drm-next, causing a merge conflict between the drm-next and drm-misc trees.
commit
4279cb1423d96e53b6b98ae9f2b41003b013a31fAuthor: Christian König <[email protected]> Date: Mon Jun 6 10:17:51 2016 +0200
Quoted 7 lines
drm/ttm: remove NULL checks when calling
ttm_tt_destroyThe function is a no-op with a NULL pointer.
Reviewed-by Alex Deucher <[email protected]>Signed-off-by Christian König <[email protected]>Signed-off-by Alex Deucher <[email protected]>
Yeah, realized that too but then drm-misc is a non-rebasing tree now, so can't take this out.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
PATCH 1/1 USB-EHCI: Delete unnecessary checks before the function call "dma_pool_destroy"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 19:01:44 +0100
The dma_pool_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/usb/host/ehci-mem.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-)
drivers/usb/host/ehci-mem.c +5 -13
@@ -128,21 +128,13 @@ static void ehci_mem_cleanup (struct ehci_hcd *ehci) ehci->dummy =NULL ;/* DMA consistent memory and pools */ -if (ehci->qtd_pool) -dma_pool_destroy (ehci->qtd_pool); +dma_pool_destroy (ehci->qtd_pool); ehci->qtd_pool =NULL ; - -if (ehci->qh_pool) { -dma_pool_destroy (ehci->qh_pool); - ehci->qh_pool =NULL ; - } - -if (ehci->itd_pool) -dma_pool_destroy (ehci->itd_pool); +dma_pool_destroy (ehci->qh_pool); + ehci->qh_pool =NULL ; +dma_pool_destroy (ehci->itd_pool); ehci->itd_pool =NULL ; - -if (ehci->sitd_pool) -dma_pool_destroy (ehci->sitd_pool); +dma_pool_destroy (ehci->sitd_pool); ehci->sitd_pool =NULL ;if (ehci->periodic)
Signature · 1 line
2.6.2
Re: [PATCH] USB-EHCI: Delete unnecessary checks before the function call "dma_pool_destroy"
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 19:01:44 +0100The
dma_pool_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
cover ste_dma40: Deletion of a few unnecessary checks
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 22:12:23 +0100
Further update suggestions were taken into account after a patch was applied from static source code analysis.
Markus Elfring (3):
Delete an unnecessary check before the function call "kmem_cache_destroy" Delete another unnecessary check in d40_probe()
Delete an unnecessary variable initialisation in d40_probe()
drivers/dma/ste_dma40.c | 87 ++++++++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 45 deletions(-)
Signature · 1 line
2.6.2
PATCH 1/3 ste_dma40: Delete an unnecessary check before the function call "kmem_cache_destroy"
From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 20:26:27 +0100
The kmem_cache_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/dma/ste_dma40.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/dma/ste_dma40.c +1 -2
@@ -3694,8 +3694,7 @@ static int __init d40_probe(struct platform_device *pdev) failure:if (base) { -if (base->desc_slab) -kmem_cache_destroy (base->desc_slab); +kmem_cache_destroy (base->desc_slab);if (base->virtbase)iounmap (base->virtbase);
Signature · 1 line
2.6.2
Re: [PATCH 1/3] ste_dma40: Delete an unnecessary check before the function call "kmem_cache_destroy"
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 20:26:27 +0100The
kmem_cache_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Yours,
Linus Walleij
PATCH 2/3 ste_dma40: Delete another unnecessary check in d40_probe()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 21:56:07 +0100
A single jump label was used by the d40_probe() function in several cases for error handling which was a bit inefficient here.
* This implementation detail could be improved by the introduction of another jump label.
* Remove an extra check for the variable "base".
* Omit its explicit initialisation at the beginning then.
--- drivers/dma/ste_dma40.c | 82 ++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 42 deletions(-)
drivers/dma/ste_dma40.c +40 -42
@@ -3543,7 +3543,7 @@ static int __init d40_probe(struct platform_device *pdev)struct stedma40_platform_data *plat_data =dev_get_platdata (&pdev->dev);struct device_node *np = pdev->dev.of_node;int ret = -ENOENT ; -struct d40_base *base =NULL ; +struct d40_base *base;struct resource *res =NULL ;int num_reserved_chans;u32 val;
@@ -3552,17 +3552,17 @@ static int __init d40_probe(struct platform_device *pdev)if (np) {if (d40_of_probe (pdev, np)) { ret = -ENOMEM ; - goto failure; + goto report_failure; } }else {d40_err (&pdev->dev,"No pdata or Device Tree provided\n" ); - goto failure; + goto report_failure; } } base =d40_hw_detect_init (pdev);if (!base) - goto failure; + goto report_failure; num_reserved_chans =d40_phy_res_init (base);
@@ -3693,50 +3693,48 @@ static int __init d40_probe(struct platform_device *pdev)return 0 ; failure: -if (base) { -kmem_cache_destroy (base->desc_slab); -if (base->virtbase) -iounmap (base->virtbase); +kmem_cache_destroy (base->desc_slab); +if (base->virtbase) +iounmap (base->virtbase); -if (base->lcla_pool.base && base->plat_data->use_esram_lcla) { -iounmap (base->lcla_pool.base); - base->lcla_pool.base =NULL ; - } +if (base->lcla_pool.base && base->plat_data->use_esram_lcla) { +iounmap (base->lcla_pool.base); + base->lcla_pool.base =NULL ; + } -if (base->lcla_pool.dma_addr) -dma_unmap_single (base->dev, base->lcla_pool.dma_addr, -SZ_1K * base->num_phy_chans, -DMA_TO_DEVICE ); - -if (!base->lcla_pool.base_unaligned && base->lcla_pool.base) -free_pages ((unsigned long )base->lcla_pool.base, - base->lcla_pool.pages); - -kfree (base->lcla_pool.base_unaligned); - -if (base->phy_lcpa) -release_mem_region (base->phy_lcpa, - base->lcpa_size); -if (base->phy_start) -release_mem_region (base->phy_start, - base->phy_size); -if (base->clk) { -clk_disable_unprepare (base->clk); -clk_put (base->clk); - } +if (base->lcla_pool.dma_addr) +dma_unmap_single (base->dev, base->lcla_pool.dma_addr, +SZ_1K * base->num_phy_chans, +DMA_TO_DEVICE ); -if (base->lcpa_regulator) { -regulator_disable (base->lcpa_regulator); -regulator_put (base->lcpa_regulator); - } +if (!base->lcla_pool.base_unaligned && base->lcla_pool.base) +free_pages ((unsigned long )base->lcla_pool.base, + base->lcla_pool.pages); -kfree (base->lcla_pool.alloc_map); -kfree (base->lookup_log_chans); -kfree (base->lookup_phy_chans); -kfree (base->phy_res); -kfree (base); +kfree (base->lcla_pool.base_unaligned); + +if (base->phy_lcpa) +release_mem_region (base->phy_lcpa, + base->lcpa_size); +if (base->phy_start) +release_mem_region (base->phy_start, + base->phy_size); +if (base->clk) { +clk_disable_unprepare (base->clk); +clk_put (base->clk); + } + +if (base->lcpa_regulator) { +regulator_disable (base->lcpa_regulator); +regulator_put (base->lcpa_regulator); } +kfree (base->lcla_pool.alloc_map); +kfree (base->lookup_log_chans); +kfree (base->lookup_phy_chans); +kfree (base->phy_res); +kfree (base); +report_failure:d40_err (&pdev->dev,"probe failed\n" );return ret; }
Signature · 1 line
2.6.2
Re: [PATCH 2/3] ste_dma40: Delete another unnecessary check in d40_probe()
Quoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 21:56:07 +0100A single jump label was used by the
d40_probe()function in several cases for error handling which was a bit inefficient here.
Quoted 8 lines
* This implementation detail could be improved by the introduction of another jump label.
* Remove an extra check for the variable "base".
* Omit its explicit initialisation at the beginning then.
Signed-off-by Markus Elfring <[email protected]>
Yours,
Linus Walleij
PATCH 3/3 ste_dma40: Delete an unnecessary variable initialisation in d40_probe()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 22:00:28 +0100
The variable "res" will eventually be set to a resource pointer from a call of the d40_hw_detect_init(() function.
Thus let us omit the explicit initialisation at the beginning.
--- drivers/dma/ste_dma40.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/ste_dma40.c +1 -1
@@ -3544,7 +3544,7 @@ static int __init d40_probe(struct platform_device *pdev)struct device_node *np = pdev->dev.of_node;int ret = -ENOENT ;struct d40_base *base; -struct resource *res =NULL ; +struct resource *res;int num_reserved_chans;u32 val;
Signature · 1 line
2.6.2
Re: [PATCH 3/3] ste_dma40: Delete an unnecessary variable initialisation in d40_probe()
Quoted 8 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 22:00:28 +0100The variable "res" will eventually be set to a resource pointer from a call of the d40_hw_detect_init(() function.
Thus let us omit the explicit initialisation at the beginning.Signed-off-by Markus Elfring <[email protected]>
Yours,
Linus Walleij
Vinod Koul
AppliedRe: [PATCH 0/3] ste_dma40: Deletion of a few unnecessary checks
In reply to SF Markus ElfringQuoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 22:12:23 +0100Further update suggestions were taken into account after a patch was applied from static source code analysis.
Applied, thanks
Signature · 1 line
~Vinod
PATCH 1/1 SCSI-aic94xx: Delete unnecessary checks before the function call "kmem_cache_destroy"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 17 Nov 2015 08:14:52 +0100
The kmem_cache_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/scsi/aic94xx/aic94xx_init.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/scsi/aic94xx/aic94xx_init.c +2 -5
@@ -660,12 +660,9 @@ Err:static void asd_destroy_global_caches (void ) { -if (asd_dma_token_cache) -kmem_cache_destroy (asd_dma_token_cache); +kmem_cache_destroy (asd_dma_token_cache); asd_dma_token_cache =NULL ; - -if (asd_ascb_cache) -kmem_cache_destroy (asd_ascb_cache); +kmem_cache_destroy (asd_ascb_cache); asd_ascb_cache =NULL ; }
Signature · 1 line
2.6.2
Re: [PATCH] SCSI-aic94xx: Delete unnecessary checks before the function call "kmem_cache_destroy"
Quoted 23 lines
From: Markus Elfring <[email protected]>
Date: Tue, 17 Nov 2015 08:14:52 +0100The
kmem_cache_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/scsi/aic94xx/aic94xx_init.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/scsi/aic94xx/aic94xx_init.c +0
-1@@ -660,12 +660,9 @@ Err:static void asd_destroy_global_caches (void ) { -if (asd_dma_token_cache)
drivers/scsi/aic94xx/aic94xx_init.c Err: · line 668
Quoted 10 lines
drivers/scsi/aic94xx/aic94xx_init.c +2
-4-kmem_cache_destroy (asd_dma_token_cache); +kmem_cache_destroy (asd_dma_token_cache); asd_dma_token_cache =NULL ; - -if (asd_ascb_cache) -kmem_cache_destroy (asd_ascb_cache); +kmem_cache_destroy (asd_ascb_cache); asd_ascb_cache =NULL ; }
How do you think about to integrate this update suggestion into another source code repository?
Regards,
Markus
Jinpu Wang
Reviewed-byRe: [PATCH] SCSI-aic94xx: Delete unnecessary checks before the function call "kmem_cache_destroy"
Quoted 38 lines · SF Markus Elfring
Quoted 24 lines
From: Markus Elfring <[email protected]>
Date: Tue, 17 Nov 2015 08:14:52 +0100The
kmem_cache_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/scsi/aic94xx/aic94xx_init.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/scsi/aic94xx/aic94xx_init.c +0
-1@@ -660,12 +660,9 @@ Err:static void asd_destroy_global_caches (void ) { -if (asd_dma_token_cache)drivers/scsi/aic94xx/aic94xx_init.c Err: · line 668
Quoted 10 lines
drivers/scsi/aic94xx/aic94xx_init.c +2
-4-kmem_cache_destroy (asd_dma_token_cache); +kmem_cache_destroy (asd_dma_token_cache); asd_dma_token_cache =NULL ; - -if (asd_ascb_cache) -kmem_cache_destroy (asd_ascb_cache); +kmem_cache_destroy (asd_ascb_cache); asd_ascb_cache =NULL ; }How do you think about to integrate this update suggestion into another source code repository?
Quoted 2 lines
Regards,
Markus
Looks good to me!
PS: resend to fix mal-format rejection, sorry!
Signature · 4 lines
Mit freundlichen Grüßen, Best Regards, Jack Wang
PATCH 1/1 scsi_lib: Delete unnecessary checks before two function calls
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 17 Nov 2015 09:00:31 +0100
The functions kmem_cache_destroy() and mempool_destroy() test whether their argument is NULL and then return immediately.
Thus the tests around their calls are not needed.
This issue was detected by using the Coccinelle software.
--- drivers/scsi/scsi_lib.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/scsi/scsi_lib.c +2 -4
@@ -2298,10 +2298,8 @@ int __init scsi_init_queue(void) cleanup_sdb:for (i =0 ; i <SG_MEMPOOL_NR ; i++) {struct scsi_host_sg_pool *sgp = scsi_sg_pools + i; -if (sgp->pool) -mempool_destroy (sgp->pool); -if (sgp->slab) -kmem_cache_destroy (sgp->slab); +mempool_destroy (sgp->pool); +kmem_cache_destroy (sgp->slab); }kmem_cache_destroy (scsi_sdb_cache);
Signature · 1 line
2.6.2
PATCH 1/1 SCSI-lpfc: Delete unnecessary checks before the function call "mempool_destroy"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 17 Nov 2015 09:34:27 +0100
The mempool_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/scsi/lpfc/lpfc_mem.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/scsi/lpfc/lpfc_mem.c +2 -4
@@ -231,15 +231,13 @@ lpfc_mem_free(struct lpfc_hba *phba)if (phba->lpfc_hbq_pool)pci_pool_destroy (phba->lpfc_hbq_pool); phba->lpfc_hbq_pool =NULL ; - -if (phba->rrq_pool) -mempool_destroy (phba->rrq_pool); +mempool_destroy (phba->rrq_pool); phba->rrq_pool =NULL ;/* Free NLP memory pool */ mempool_destroy (phba->nlp_mem_pool); phba->nlp_mem_pool =NULL ; -if (phba->sli_rev =LPFC_SLI_REV4 && phba->active_rrq_pool) { +if (phba->sli_rev =LPFC_SLI_REV4 ) {mempool_destroy (phba->active_rrq_pool); phba->active_rrq_pool =NULL ; }
Signature · 1 line
2.6.2
Re: [PATCH] SCSI-lpfc: Delete unnecessary checks before the function call "mempool_destroy"
fyi - this patch was just pushed in our 11.0.0.10 patch set - patch 15/17
-- james s
Quoted 35 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 17 Nov 2015 09:34:27 +0100The
mempool_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/scsi/lpfc/lpfc_mem.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/scsi/lpfc/lpfc_mem.c +2
-4@@ -231,15 +231,13 @@ lpfc_mem_free(struct lpfc_hba *phba)if (phba->lpfc_hbq_pool)pci_pool_destroy (phba->lpfc_hbq_pool); phba->lpfc_hbq_pool =NULL ; - -if (phba->rrq_pool) -mempool_destroy (phba->rrq_pool); +mempool_destroy (phba->rrq_pool); phba->rrq_pool =NULL ;/* Free NLP memory pool */ mempool_destroy (phba->nlp_mem_pool); phba->nlp_mem_pool =NULL ; -if (phba->sli_rev =LPFC_SLI_REV4 && phba->active_rrq_pool) { +if (phba->sli_rev =LPFC_SLI_REV4 ) {mempool_destroy (phba->active_rrq_pool); phba->active_rrq_pool =NULL ; }
PATCH 1/1 ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 13:50:23 +0100
The kfree_skb() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/net/ieee802154/atusb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ieee802154/atusb.c +1 -2
@@ -310,8 +310,7 @@ static void atusb_free_urbs(struct atusb *atusb) urb =usb_get_from_anchor (&atusb->idle_urbs);if (!urb)break ; -if (urb->context) -kfree_skb (urb->context); +kfree_skb (urb->context);usb_free_urb (urb); } }
Signature · 3 lines
2.6.2 --
Re: [PATCH] ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
Hello.
Quoted 19 lines · Stefan Schmidt
From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 13:50:23 +0100The
kfree_skb()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/net/ieee802154/atusb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/net/ieee802154/atusb.c +0
-0
drivers/net/ieee802154/atusb.c static void atusb_free_urbs(struct atusb *atusb) · line 316
Quoted 9 lines
drivers/net/ieee802154/atusb.c +1
-2@@ -310,8 +310,7 @@ static void atusb_free_urbs(struct atusb *atusb) urb =usb_get_from_anchor (&atusb->idle_urbs);if (!urb)break ; -if (urb->context) -kfree_skb (urb->context); +kfree_skb (urb->context);usb_free_urb (urb); } }
regards
Stefan Schmidt
Re: [PATCH] ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
Marcel,
Quoted 25 lines · Stefan Schmidt
Hello.
Quoted 22 lines · Stefan Schmidt
From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 13:50:23 +0100The
kfree_skb()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/net/ieee802154/atusb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/net/ieee802154/atusb.c +0
-0@@ -310,8 +310,7 @@ static void atusb_free_urbs(struct atusb *atusb) urb =usb_get_from_anchor (&atusb->idle_urbs);if (!urb)break ;
Quoted 8 lines
drivers/net/ieee802154/atusb.c static void atusb_free_urbs(struct atusb *atusb) · line 316
Quoted 6 lines
drivers/net/ieee802154/atusb.c +1
-2-if (urb->context) -kfree_skb (urb->context); +kfree_skb (urb->context);usb_free_urb (urb); } }Acked-by Stefan Schmidt <[email protected]>
You got the original patch and my ACK on this one or would you prefer me to resend it again?
regards
Stefan Schmidt
Marcel Holtmann
maintainerRe: [PATCH] ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
Hi Stefan,
Quoted 31 lines
Quoted 13 lines
Quoted 13 lines
From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 13:50:23 +0100The
kfree_skb()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>---
drivers/net/ieee802154/atusb.c| 3 +--1 file changed, 1 insertion(+), 2 deletions(-)Quoted 16 lines
Quoted 5 lines
drivers/net/ieee802154/atusb.c +0
-0drivers/net/ieee802154/atusb.c static void atusb_free_urbs(struct atusb *atusb) · line 316
Quoted 9 lines
drivers/net/ieee802154/atusb.c +1
-2@@ -310,8 +310,7 @@ static void atusb_free_urbs(struct atusb *atusb) urb =usb_get_from_anchor (&atusb->idle_urbs);if (!urb)break ; -if (urb->context) -kfree_skb (urb->context); +kfree_skb (urb->context);usb_free_urb (urb); } }Acked-by Stefan Schmidt <[email protected]>
Quoted 1 line
You got the original patch and my ACK on this one or would you prefer me to resend it again?
this slipped through, but now it does no longer apply.
Applying: ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
error: patch failed: drivers/net/ieee802154/atusb.c:310
error: drivers/net/ieee802154/atusb.c: patch does not apply
Patch failed at 0001 ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
Regards
Marcel
Re: [PATCH] ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
Hello.
Quoted 31 lines · Marcel Holtmann
Hi Stefan,
Quoted 29 lines
Quoted 28 lines
Quoted 18 lines
From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 13:50:23 +0100The
kfree_skb()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>---
drivers/net/ieee802154/atusb.c| 3 +--1 file changed, 1 insertion(+), 2 deletions(-)drivers/net/ieee802154/atusb.c +0
-0drivers/net/ieee802154/atusb.c static void atusb_free_urbs(struct atusb *atusb) · line 316
Quoted 9 lines
drivers/net/ieee802154/atusb.c +1
-2@@ -310,8 +310,7 @@ static void atusb_free_urbs(struct atusb *atusb) urb =usb_get_from_anchor (&atusb->idle_urbs);if (!urb)break ; -if (urb->context) -kfree_skb (urb->context); +kfree_skb (urb->context);usb_free_urb (urb); } }Acked-by Stefan Schmidt <[email protected]>
Quoted 7 lines
Quoted 1 line
You got the original patch and my ACK on this one or would you prefer me to resend it again?
this slipped through, but now it does no longer apply.
Applying: ieee802154-atusb: Delete an unnecessary check before the function call "
kfree_skb"
error: patch failed:drivers/net/ieee802154/atusb.c:310
error:drivers/net/ieee802154/atusb.c: patch does not apply
Patch failed at 0001 ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
Not good. I did another resend, this one applied, compiled and worked fine for me. You will be in the to line.
regards
Stefan Schmidt
Re: ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
In reply to Marcel HoltmannQuoted 6 lines
this slipped through, but now it does no longer apply.
Applying: ieee802154-atusb: Delete an unnecessary check before the function call "
kfree_skb"
error: patch failed:drivers/net/ieee802154/atusb.c:310
error:drivers/net/ieee802154/atusb.c: patch does not apply
Patch failed at 0001 ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
How can this hiccup happen?
A command like the following is still working for me on source files for the software "Linux next-20151211".
elfring@Sonne:~/Projekte/Linux/next-patched> git apply ~/Projekte/Bau/Linux/scripts/Coccinelle/deletions1/next/20151113/Flicken/0001-ieee802154-atusb-Delete-an-unnecessary-check-before.patch
Regards,
Markus
Re: ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
Hello.
Quoted 8 lines · SF Markus Elfring
Quoted 6 lines
this slipped through, but now it does no longer apply.
Applying: ieee802154-atusb: Delete an unnecessary check before the function call "
kfree_skb"
error: patch failed:drivers/net/ieee802154/atusb.c:310
error:drivers/net/ieee802154/atusb.c: patch does not apply
Patch failed at 0001 ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"How can this hiccup happen?
I might have been a problem when I was resending your patch the first time as Marcel was not able to find the original one.
I have send it a second time now and it worked fine. The patch is already applied to the bluetooth-next tree and thus on its way. All good now.
regards
Stefan Schmidt
PATCH 1/1 net-scm: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 17 Nov 2015 17:37:22 +0100
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- net/core/scm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/scm.c +1 -1
@@ -193,7 +193,7 @@ int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *p) } } -if (p->fp && !p->fp->count) +if (likely (!p->fp->count)) {kfree (p->fp); p->fp =NULL ;
Signature · 1 line
2.6.2
David Miller
maintainerRe: [PATCH] net-scm: Delete an unnecessary check before the function call "kfree"
From: SF Markus Elfring <[email protected]>
Date: Tue, 17 Nov 2015 17:43:35 +0100
Quoted 9 lines
From: Markus Elfring <[email protected]>
Date: Tue, 17 Nov 2015 17:37:22 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
STOP submitting this crap, NOW!
I told you I won't review nor apply these patches any more.
And ever worse, this one is BUGGY.
We're testing p->fp so we know if we can safely dereference it or not.
You're adding an OOPS to the kernel.
This is why these mindless mechanical transformations are not only often a waste of time, they are dangerous as well.
I am silently rejecting from patchwork, immediately, any and all patches you submit of this nature.
Daniel Borkmann
maintainerRe: [PATCH] net-scm: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringQuoted 19 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 17 Nov 2015 17:37:22 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- net/core/scm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/core/scm.c +0
-0
net/core/scm.c int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *p) · line 199
Quoted 8 lines
net/core/scm.c +1
-1@@ -193,7 +193,7 @@ int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *p) } } -if (p->fp && !p->fp->count) +if (likely (!p->fp->count)) {kfree (p->fp); p->fp =NULL ;
Really, I don't like your blind, silly removals everywhere throughout the kernel tree for these tests. Eric already mentioned that in some situations where it's critical, it actually slows down the code, i.e. you'll have an extra function call to get there and inside kfree() / kfree_skb() / etc, the test is actually marked as unlikely().
Anyway, I think this one in particular could throw a NULL pointer deref. You even say in your commit message "kfree() function tests whether its argument [p->fp] is NULL" and yet if that is the case then, you already deref'ed on the p->fp->count test ???
Re: net-scm: Delete an unnecessary check before the function call "kfree"
Quoted 4 lines
Eric already mentioned that in some situations where it's critical, it actually slows down the code, i.e. you'll have an extra function call to get there and inside
kfree()/kfree_skb()/ etc, the test is actually marked asunlikely().
How do you think about to add similar annotations to any more source code places?
Regards,
Markus
Daniel Borkmann
maintainerRe: net-scm: Delete an unnecessary check before the function call "kfree"
Quoted 7 lines · SF Markus Elfring
Quoted 4 lines
Eric already mentioned that in some situations where it's critical, it actually slows down the code, i.e. you'll have an extra function call to get there and inside
kfree()/kfree_skb()/ etc, the test is actually marked asunlikely().How do you think about to add similar annotations to any more source code places?
You mean this likely() annotation of yours? It doesn't make any sense to me to place it there, and since you've spend the second thinking about it when adding it to the diff, you should have already realized that your code was buggy ...
Re: net-scm: Macro for special pattern?
Quoted 1 line
You mean this
likely()annotation of yours?
How do you think about to express the software design pattern which is applied at the mentioned source code place by a dedicated preprocessor macro?
Regards,
Markus
Re: net-scm: Macro for special pattern?
Quoted 5 lines · SF Markus Elfring
Quoted 1 line
You mean this
likely()annotation of yours?How do you think about to express the software design pattern which is applied at the mentioned source code place by a dedicated preprocessor macro?
likely()/unlikely() are not always applicable.
In the Ipv6 case I mentioned to you, it all depends if an application for some reason absolutely wants the sockets to store the extra skb
There are seldom used socket options. _if_/_when_ they are used, a likely()/unlikely() would give the wrong signal.
likely() should only be used in contexts we know better than branch predictor/compiler.
PATCH 1/1 s390-ctcm: Delete unnecessary checks before the function call "channel_remove"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 17 Nov 2015 20:10:02 +0100
The channel_remove() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/s390/net/ctcm_main.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/s390/net/ctcm_main.c +2 -5
@@ -1677,11 +1677,8 @@ static int ctcm_shutdown_device(struct ccwgroup_device *cgdev)ccw_device_set_offline (cgdev->cdev[1 ]);ccw_device_set_offline (cgdev->cdev[0 ]); - -if (priv->channel[CTCM_READ ]) -channel_remove (priv->channel[CTCM_READ ]); -if (priv->channel[CTCM_WRITE ]) -channel_remove (priv->channel[CTCM_WRITE ]); +channel_remove (priv->channel[CTCM_READ ]); +channel_remove (priv->channel[CTCM_WRITE ]); priv->channel[CTCM_READ ] = priv->channel[CTCM_WRITE ] =NULL ;return 0 ;
Signature · 1 line
2.6.2
Re: [PATCH] s390-ctcm: Delete unnecessary checks before the function call "channel_remove"
Applied to our local git. Thanks. It will be part of my next patch submission for net-next.
Kind regards, Ursula Braun, IBM Germany
Quoted 31 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 17 Nov 2015 20:10:02 +0100The
channel_remove()function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/s390/net/ctcm_main.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/s390/net/ctcm_main.c +2
-5@@ -1677,11 +1677,8 @@ static int ctcm_shutdown_device(struct ccwgroup_device *cgdev)ccw_device_set_offline (cgdev->cdev[1 ]);ccw_device_set_offline (cgdev->cdev[0 ]); - -if (priv->channel[CTCM_READ ]) -channel_remove (priv->channel[CTCM_READ ]); -if (priv->channel[CTCM_WRITE ]) -channel_remove (priv->channel[CTCM_WRITE ]); +channel_remove (priv->channel[CTCM_READ ]); +channel_remove (priv->channel[CTCM_WRITE ]); priv->channel[CTCM_READ ] = priv->channel[CTCM_WRITE ] =NULL ;return 0 ;
Re: [PATCH] s390-ctcm: Delete unnecessary checks before the function call "channel_remove"
In reply to SF Markus ElfringAm 25.11.2015 10:37, schrieb Ursula Braun:
Quoted 19 lines
Applied to our local git. Thanks. It will be part of my next patch submission for net-next.
Kind regards, Ursula Braun, IBM Germany
Quoted 13 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 17 Nov 2015 20:10:02 +0100The
channel_remove()function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/s390/net/ctcm_main.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
Quoted 8 lines
drivers/s390/net/ctcm_main.c static int ctcm_shutdown_device(struct ccwgroup_device *cgdev) · line 1679
Quoted 8 lines
drivers/s390/net/ctcm_main.c +0
-0@@ -1677,11 +1677,8 @@ static int ctcm_shutdown_device(struct ccwgroup_device *cgdev)ccw_device_set_offline (cgdev->cdev[1 ]);ccw_device_set_offline (cgdev->cdev[0 ]);
while you are at it ..
could it be that
cgdev->cdev[1] = cgdev->cdev[CTCM_WRITE]
if yes you may want to fix that also.
re,
wh
Quoted 12 lines
Quoted 10 lines
drivers/s390/net/ctcm_main.c +2
-5- -if (priv->channel[CTCM_READ ]) -channel_remove (priv->channel[CTCM_READ ]); -if (priv->channel[CTCM_WRITE ]) -channel_remove (priv->channel[CTCM_WRITE ]); +channel_remove (priv->channel[CTCM_READ ]); +channel_remove (priv->channel[CTCM_WRITE ]); priv->channel[CTCM_READ ] = priv->channel[CTCM_WRITE ] =NULL ;return 0 ;
Re: [PATCH] s390-ctcm: Delete unnecessary checks before the function call "channel_remove"
Quoted 32 lines · walter harms
Am 25.11.2015 10:37, schrieb Ursula Braun:
Quoted 19 lines
Applied to our local git. Thanks. It will be part of my next patch submission for net-next.
Kind regards, Ursula Braun, IBM Germany
Quoted 13 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 17 Nov 2015 20:10:02 +0100The
channel_remove()function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/s390/net/ctcm_main.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)Quoted 8 lines
drivers/s390/net/ctcm_main.c static int ctcm_shutdown_device(struct ccwgroup_device *cgdev) · line 1679
Quoted 8 lines
drivers/s390/net/ctcm_main.c +0
-0@@ -1677,11 +1677,8 @@ static int ctcm_shutdown_device(struct ccwgroup_device *cgdev)ccw_device_set_offline (cgdev->cdev[1 ]);ccw_device_set_offline (cgdev->cdev[0 ]);while you are at it ..
Quoted 7 lines
could it be that
cgdev->cdev[1] = cgdev->cdev[CTCM_WRITE]if yes you may want to fix that also.
re,
wh
Currently we use CTCM_READ and CTCM_WRITE as indices for the ctc-channel structures, while we use 0, 1, ... as indices for subchannel ccw dev's of our ccwgroup devices. Our other ccwgroup drivers use 0, 1, ... for this purpose as well. Thus I would like to keep this consistent, and stay with 0 and 1 as indices for subchannel ccw dev's in the ctcm driver.
Regards, Ursula
Quoted 14 lines
Quoted 13 lines
Quoted 11 lines
drivers/s390/net/ctcm_main.c +2
-5- -if (priv->channel[CTCM_READ ]) -channel_remove (priv->channel[CTCM_READ ]); -if (priv->channel[CTCM_WRITE ]) -channel_remove (priv->channel[CTCM_WRITE ]); +channel_remove (priv->channel[CTCM_READ ]); +channel_remove (priv->channel[CTCM_WRITE ]); priv->channel[CTCM_READ ] = priv->channel[CTCM_WRITE ] =NULL ;return 0 ;
cover block-rbd: Deletion of an unnecessary check
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 23 Nov 2015 20:33:59 +0100
Another update suggestion was taken into account after a patch was applied from static source code analysis.
Markus Elfring (2):
Delete an unnecessary check before the function call "rbd_dev_destroy" One function call less in rbd_dev_probe_parent() after error detection
drivers/block/rbd.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
Signature · 1 line
2.6.3
PATCH 1/2 block-rbd: Delete an unnecessary check before the function call "rbd_dev_destroy"
From: Markus Elfring <[email protected]>
Date: Mon, 23 Nov 2015 20:16:45 +0100
The rbd_dev_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/block/rbd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/block/rbd.c +1 -2
@@ -5184,8 +5184,7 @@ static int rbd_dev_probe_parent(struct rbd_device *rbd_dev, int depth) out_err:rbd_dev_unparent (rbd_dev); -if (parent) -rbd_dev_destroy (parent); +rbd_dev_destroy (parent);return ret; }
Signature · 1 line
2.6.3
Re: [PATCH 1/2] block-rbd: Delete an unnecessary check before the function call "rbd_dev_destroy"
Quoted 18 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 23 Nov 2015 20:16:45 +0100The
rbd_dev_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/block/rbd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/block/rbd.c +0
-0
drivers/block/rbd.c static int rbd_dev_probe_parent(struct rbd_device *rbd_dev, int depth) · line 5189
Quoted 8 lines
drivers/block/rbd.c +1
-2@@ -5184,8 +5184,7 @@ static int rbd_dev_probe_parent(struct rbd_device *rbd_dev, int depth) out_err:rbd_dev_unparent (rbd_dev); -if (parent) -rbd_dev_destroy (parent); +rbd_dev_destroy (parent);return ret; }
Applied, see https://github.com/ceph/ceph-client/commit/b0098c3eadd33fa212987dab0529e35c948aaff4.
Thanks,
Ilya
PATCH 2/2 block-rbd: One function call less in rbd_dev_probe_parent() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 23 Nov 2015 20:22:41 +0100
The rbd_dev_destroy() function was called in two cases by the rbd_dev_probe_parent() function during error handling even if the passed variable contained a null pointer.
* This implementation detail could be improved by adjustments for jump targets according to the Linux coding style convention.
* Drop an unnecessary initialisation for the variable "parent" then.
--- drivers/block/rbd.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/block/rbd.c +7 -7
@@ -5148,7 +5148,7 @@ out_err:*/ static int rbd_dev_probe_parent (struct rbd_device *rbd_dev,int depth) { -struct rbd_device *parent =NULL ; +struct rbd_device *parent;int ret;if (!rbd_dev->parent_spec)
@@ -5157,14 +5157,14 @@ static int rbd_dev_probe_parent(struct rbd_device *rbd_dev, int depth)if (++depth >RBD_MAX_PARENT_CHAIN_LEN ) {pr_info ("parent chain is too long (%d)\n" , depth); ret = -EINVAL ; - goto out_err; + goto unparent_device; } parent =rbd_dev_create (rbd_dev->rbd_client, rbd_dev->parent_spec,NULL );if (!parent) { ret = -ENOMEM ; - goto out_err; + goto unparent_device; }/*
@@ -5176,15 +5176,15 @@ static int rbd_dev_probe_parent(struct rbd_device *rbd_dev, int depth) ret =rbd_dev_image_probe (parent, depth);if (ret <0 ) - goto out_err; + goto destroy_device; rbd_dev->parent = parent;atomic_set (&rbd_dev->parent_ref,1 );return 0 ; - -out_err: -rbd_dev_unparent (rbd_dev); +destroy_device:rbd_dev_destroy (parent); +unparent_device: +rbd_dev_unparent (rbd_dev);return ret; }
Signature · 1 line
2.6.3
Ilya Dryomov
maintainerRe: [PATCH 2/2] block-rbd: One function call less in rbd_dev_probe_parent() after error detection
Quoted 56 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 23 Nov 2015 20:22:41 +0100The
rbd_dev_destroy()function was called in two cases by therbd_dev_probe_parent()function during error handling even if the passed variable contained a null pointer.* This implementation detail could be improved by adjustments for jump targets according to the Linux coding style convention.
* Drop an unnecessary initialisation for the variable "parent" then.
Signed-off-by Markus Elfring <[email protected]>--- drivers/block/rbd.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/block/rbd.c +4
-4@@ -5148,7 +5148,7 @@ out_err:*/ static int rbd_dev_probe_parent (struct rbd_device *rbd_dev,int depth) { -struct rbd_device *parent =NULL ; +struct rbd_device *parent;int ret;if (!rbd_dev->parent_spec)@@ -5157,14 +5157,14 @@ static int rbd_dev_probe_parent(struct rbd_device *rbd_dev, int depth)if (++depth >RBD_MAX_PARENT_CHAIN_LEN ) {pr_info ("parent chain is too long (%d)\n" , depth); ret = -EINVAL ; - goto out_err; + goto unparent_device; } parent =rbd_dev_create (rbd_dev->rbd_client, rbd_dev->parent_spec,NULL );if (!parent) { ret = -ENOMEM ; - goto out_err; + goto unparent_device; }/* @@ -5176,15 +5176,15 @@ static int rbd_dev_probe_parent(struct rbd_device *rbd_dev, int depth) ret =rbd_dev_image_probe (parent, depth);if (ret <0 ) - goto out_err; + goto destroy_device; rbd_dev->parent = parent;atomic_set (&rbd_dev->parent_ref,1 );
drivers/block/rbd.c static int rbd_dev_probe_parent(struct rbd_device *rbd_dev, int depth) · line 5189
Quoted 10 lines
drivers/block/rbd.c +3
-3return 0 ; - -out_err: -rbd_dev_unparent (rbd_dev); +destroy_device:rbd_dev_destroy (parent); +unparent_device: +rbd_dev_unparent (rbd_dev);return ret; }
Cleanup here is (and should be) done in reverse order. We allocate parent rbd_device and then link it with what we already have, so the order in which we cleanup is unlink ("unparent"), destroy.
Changing it is just asking for use-after-free bugs.
Thanks,
Ilya
Re: [PATCH 2/2] block-rbd: One function call less in rbd_dev_probe_parent() after error detection
Quoted 24 lines
Quoted 24 lines
drivers/block/rbd.c +3
-3@@ -5157,14 +5157,14 @@ static int rbd_dev_probe_parent(struct rbd_device *rbd_dev, int depth)if (++depth >RBD_MAX_PARENT_CHAIN_LEN ) {pr_info ("parent chain is too long (%d)\n" , depth); ret = -EINVAL ; - goto out_err; + goto unparent_device; } parent =rbd_dev_create (rbd_dev->rbd_client, rbd_dev->parent_spec,NULL );if (!parent) { ret = -ENOMEM ; - goto out_err; + goto unparent_device; }/* @@ -5176,15 +5176,15 @@ static int rbd_dev_probe_parent(struct rbd_device *rbd_dev, int depth) ret =rbd_dev_image_probe (parent, depth);if (ret <0 ) - goto out_err; + goto destroy_device;
Quoted 14 lines
drivers/block/rbd.c static int rbd_dev_probe_parent(struct rbd_device *rbd_dev, int depth) · line 5189
Quoted 12 lines
drivers/block/rbd.c +3
-3rbd_dev->parent = parent;atomic_set (&rbd_dev->parent_ref,1 );return 0 ; - -out_err: -rbd_dev_unparent (rbd_dev); +destroy_device:rbd_dev_destroy (parent); +unparent_device: +rbd_dev_unparent (rbd_dev);return ret; }Cleanup here is (and should be) done in reverse order.
I have got an other impression about the appropriate order for the corresponding clean-up function calls.
Quoted 1 line
We allocate parent
rbd_deviceand then link it with what we already have,
I guess that we have got a different understanding about the relevant "linking".
Quoted 1 line
so the order in which we cleanup is unlink ("unparent"), destroy.
I interpreted the eventual passing of a null pointer to the rbd_dev_destroy() function as an indication for further source code adjustments.
Quoted 1 line
Changing it is just asking for use-after-free bugs.
Do the affected implementation details need a bit more clarification?
Regards,
Markus
Ilya Dryomov
maintainerRe: [PATCH 2/2] block-rbd: One function call less in rbd_dev_probe_parent() after error detection
Quoted 39 lines · SF Markus Elfring
Quoted 24 lines
Quoted 24 lines
drivers/block/rbd.c +3
-3@@ -5157,14 +5157,14 @@ static int rbd_dev_probe_parent(struct rbd_device *rbd_dev, int depth)if (++depth >RBD_MAX_PARENT_CHAIN_LEN ) {pr_info ("parent chain is too long (%d)\n" , depth); ret = -EINVAL ; - goto out_err; + goto unparent_device; } parent =rbd_dev_create (rbd_dev->rbd_client, rbd_dev->parent_spec,NULL );if (!parent) { ret = -ENOMEM ; - goto out_err; + goto unparent_device; }/* @@ -5176,15 +5176,15 @@ static int rbd_dev_probe_parent(struct rbd_device *rbd_dev, int depth) ret =rbd_dev_image_probe (parent, depth);if (ret <0 ) - goto out_err; + goto destroy_device;Quoted 14 lines
drivers/block/rbd.c static int rbd_dev_probe_parent(struct rbd_device *rbd_dev, int depth) · line 5189
Quoted 12 lines
drivers/block/rbd.c +3
-3rbd_dev->parent = parent;atomic_set (&rbd_dev->parent_ref,1 );return 0 ; - -out_err: -rbd_dev_unparent (rbd_dev); +destroy_device:rbd_dev_destroy (parent); +unparent_device: +rbd_dev_unparent (rbd_dev);return ret; }Cleanup here is (and should be) done in reverse order.
Quoted 7 lines
I have got an other impression about the appropriate order for the corresponding clean-up function calls.
Quoted 1 line
We allocate parent
rbd_deviceand then link it with what we already have,I guess that we have got a different understanding about the relevant "linking".
Well, there isn't any _literal_ linking (e.g. adding to a link list, etc) in this case. We just bump some refs and do probe to fill in the newly allocated parent. If probe fails, we put refs and free parent, reversing the "alloc parent, bump refs" order.
The actual linking (rbd_dev->parent = parent) is done right before returning so we never have to undo it in rbd_dev_probe_parent() and that's the only reason your patch probably doesn't break anything. Think about what happens if, after your patch is applied, someone moves that assignment up or adds an extra step that can fail after it...
Quoted 6 lines
Quoted 3 lines
so the order in which we cleanup is unlink ("unparent"), destroy.
I interpreted the eventual passing of a null pointer to the
rbd_dev_destroy()function as an indication for further source code adjustments.
If all error paths could be adjusted so that NULL pointers are never passed in, destroy functions wouldn't need to have a NULL check, would they?
Thanks,
Ilya
Re: block-rbd: One function call less in rbd_dev_probe_parent() after error detection
Quoted 3 lines
Well, there isn't any _literal_ linking (e.g. adding to a link list, etc) in this case. We just bump some refs and do probe to fill in the newly allocated parent.
Thanks for your clarification.
Quoted 3 lines
The actual linking (
rbd_dev->parent= parent) is done right before returning so we never have to undo it inrbd_dev_probe_parent()and that's the only reason your patch probably doesn't break anything.
Is this function implementation just also affected by an issue which is mentioned in the Linux document "CodingStyle" as "one err bugs"?
Quoted 2 lines
Think about what happens if, after your patch is applied, someone moves that assignment up or adds an extra step that can fail after it...
Is such a software maintenance concern really enough to delay (or reject) my second update suggestion in this small patch series?
Regards,
Markus
Ilya Dryomov
maintainerRe: block-rbd: One function call less in rbd_dev_probe_parent() after error detection
Quoted 7 lines · SF Markus Elfring
Quoted 3 lines
Well, there isn't any _literal_ linking (e.g. adding to a link list, etc) in this case. We just bump some refs and do probe to fill in the newly allocated parent.
Thanks for your clarification.
Quoted 6 lines
Quoted 3 lines
The actual linking (
rbd_dev->parent= parent) is done right before returning so we never have to undo it inrbd_dev_probe_parent()and that's the only reason your patch probably doesn't break anything.Is this function implementation just also affected by an issue which is mentioned in the Linux document "CodingStyle" as "one err bugs"?
No, why? "one err bug" as per CodingStyle is a NULL deref on line 2 if foo is NULL. If it was just "err: kfree(foo); return ret;", a NULL foo would be perfectly OK.
1 err:
2 kfree(foo->bar); 3 kfree(foo); 4 return ret;
If you can spot such a NULL deref in rbd_dev_probe_parent(), I'd gladly take a patch.
Quoted 7 lines
Quoted 4 lines
Think about what happens if, after your patch is applied, someone moves that assignment up or adds an extra step that can fail after it...
Is such a software maintenance concern really enough to delay (or reject) my second update suggestion in this small patch series?
Yes - it's rejected because it messes up the order of cleanup for no good reason. I realize why you think the patch is correct and it's not without merit, but it just doesn't fit the weird rbd_dev_probe_parent() contract.
Thanks,
Ilya
Re: block-rbd: One function call less in rbd_dev_probe_parent() after error detection
Quoted 2 lines
"one err bug" as per CodingStyle is a NULL deref on line 2 if foo is NULL. If it was just "err: kfree(foo); return ret;", a NULL foo would be perfectly OK.
Would it make sense to rename such an issue as the "one error jump label bug"?
https://plus.google.com/106378716002406849458/posts/dnanfhQ4mHQ
Regards,
Markus
Re: [PATCH 2/2] block-rbd: One function call less in rbd_dev_probe_parent() after error detection
In reply to Ilya DryomovQuoted 2 lines · Ilya Dryomov
Quoted 2 lines
Quoted 1 line
Cleanup here is (and should be) done in reverse order.
Yes. This is true.
Quoted 13 lines
Quoted 7 lines
I have got an other impression about the appropriate order for the corresponding clean-up function calls.
Quoted 1 line
We allocate parent
rbd_deviceand then link it with what we already have,I guess that we have got a different understanding about the relevant "linking".
Well, there isn't any _literal_ linking (e.g. adding to a link list, etc) in this case. We just bump some refs and do probe to fill in the newly allocated parent. If probe fails, we put refs and free parent, reversing the "alloc parent, bump refs" order.
Quoted 6 lines
The actual linking (
rbd_dev->parent= parent) is done right before returning so we never have to undo it inrbd_dev_probe_parent()and that's the only reason your patch probably doesn't break anything. Think about what happens if, after your patch is applied, someone moves that assignment up or adds an extra step that can fail after it...
The problem is that the unwind code should be a mirror of the allocate code but rbd_dev_unparent() doesn't mirror anything. Generally, writing future proof stubs like this is a wrong thing because predicting the future is hard and in the mean time we are left stubs which confuse everyone.
Quoted 3 lines
If all error paths could be adjusted so that NULL pointers are never passed in, destroy functions wouldn't need to have a NULL check, would they?
Yep. We agree on the right way to do it. I am probably the number one kernel developer for removing the most sanity checks. :P (As opposed to patch 1/1 where we now rely on the sanity check inside rbd_dev_destroy().)
drivers/block/rbd.c
5149 static int rbd_dev_probe_parent(struct rbd_device *rbd_dev, int depth) 5150 {
5151 struct rbd_device *parent = NULL;
5152 int ret;
5153
5154 if (!rbd_dev->parent_spec)
5155 return 0;
5156
5157 if (++depth > RBD_MAX_PARENT_CHAIN_LEN) {
5158 pr_info("parent chain is too long (%d)\n", depth);
5159 ret = -EINVAL;
5160 goto out_err;We haven't allocated anything so this should just be return -EINVAL; In the original code, we decrement the kref count on ->parent_spec on this error path so that is a classic One Err Bug.
5161 }
5162
5163 parent = rbd_dev_create(rbd_dev->rbd_client, rbd_dev->parent_spec,
5164 NULL);
5165 if (!parent) {
5166 ret = -ENOMEM;
5167 goto out_err;Still haven't allocated anything so return -ENOMEM, but if we fail after this point we will need to call rbd_dev_destroy().
5168 }
5169
5170 /*
5171 * Images related by parent/child relationships always share 5172 * rbd_client and spec/parent_spec, so bump their refcounts. 5173 */
5174 __rbd_get_client(rbd_dev->rbd_client);
5175 rbd_spec_get(rbd_dev->parent_spec);
We will need to put these on any later error paths.
5176 5177 ret = rbd_dev_image_probe(parent, depth); 5178 if (ret < 0) 5179 goto out_err;
Ok. We need to put the ->parent_spec, ->rbd_client and free the parent.
5180 5181 rbd_dev->parent = parent; 5182 atomic_set(&rbd_dev->parent_ref, 1); 5183 return 0; 5184 5185 out_err: 5186 rbd_dev_unparent(rbd_dev);
This is a complicated way to say rbd_spec_put(rbd_dev->parent_spec);
Also, is it really necessary to set ->parent_spec to NULL? If we didn't put the last reference then doesn't setting it to NULL mean we are leaking? Setting it to NULL is confusing and feels like a layering violation.
5187 if (parent) 5188 rbd_dev_destroy(parent); 5189 return ret; 5190 }
I feel like we should be calling rbd_put_client() on this error path or else the code is buggy or has layer violations. So I *think* it should look like this:
dec_ref_counts:
rbd_spec_put(rbd_dev->parent_spec); rbd_put_client(rbd_dev->rbd_client); rbd_dev_destroy(parent); return ret;
regards,
dan carpenter
Ilya Dryomov
maintainerRe: [PATCH 2/2] block-rbd: One function call less in rbd_dev_probe_parent() after error detection
Quoted 26 lines · Dan Carpenter
Quoted 2 lines · Ilya Dryomov
Quoted 2 lines
Quoted 1 line
Cleanup here is (and should be) done in reverse order.
Yes. This is true.
Quoted 13 lines
Quoted 7 lines
I have got an other impression about the appropriate order for the corresponding clean-up function calls.
Quoted 1 line
We allocate parent
rbd_deviceand then link it with what we already have,I guess that we have got a different understanding about the relevant "linking".
Well, there isn't any _literal_ linking (e.g. adding to a link list, etc) in this case. We just bump some refs and do probe to fill in the newly allocated parent. If probe fails, we put refs and free parent, reversing the "alloc parent, bump refs" order.
Quoted 6 lines
The actual linking (
rbd_dev->parent= parent) is done right before returning so we never have to undo it inrbd_dev_probe_parent()and that's the only reason your patch probably doesn't break anything. Think about what happens if, after your patch is applied, someone moves that assignment up or adds an extra step that can fail after it...
Quoted 5 lines
The problem is that the unwind code should be a mirror of the allocate code but
rbd_dev_unparent()doesn't mirror anything. Generally, writing future proof stubs like this is a wrong thing because predicting the future is hard and in the mean time we are left stubs which confuse everyone.
It's not a future proof stub. It's just some crufty code that was fixed over time to not leak things. I won't defend it - it is confusing and could definitely be improved - but that can't be done without refactoring a fair bunch of calling code. A patch changing rbd_dev_probe_parent() alone just won't do it.
Quoted 20 lines
Quoted 4 lines
If all error paths could be adjusted so that NULL pointers are never passed in, destroy functions wouldn't need to have a NULL check, would they?
Yep. We agree on the right way to do it. I am probably the number one kernel developer for removing the most sanity checks. :P (As opposed to patch 1/1 where we now rely on the sanity check inside
rbd_dev_destroy().)
drivers/block/rbd.c
5149 static intrbd_dev_probe_parent(struct rbd_device *rbd_dev, int depth)5150 {
5151 structrbd_device*parent = NULL;
5152 int ret;
5153
5154 if (!rbd_dev->parent_spec)
5155 return 0;
5156
5157 if (++depth >RBD_MAX_PARENT_CHAIN_LEN) {
Quoted 7 lines
5158 pr_info("parent chain is too long (%d)\n", depth); 5159 ret = -EINVAL; 5160 goto out_err;We haven't allocated anything so this should just be return
-EINVAL; In the original code, we decrement the kref count on ->parent_spec on this error path so that is a classic One Err Bug.
The caller expects rbd_dev->parent_spec to be put on any error. Notice that we return right away if !rbd_dev->parent_spec.
Quoted 15 lines
5161 } 5162 5163 parent = rbd_dev_create(rbd_dev->rbd_client, rbd_dev->parent_spec, 5164 NULL); 5165 if (!parent) { 5166 ret = -ENOMEM; 5167 goto out_err;Still haven't allocated anything so return
-ENOMEM, but if we fail after this point we will need to callrbd_dev_destroy().5168 }
5169
5170 /*
Quoted 7 lines
5171 * Images related by parent/child relationships always share 5172 * rbd_client and spec/parent_spec, so bump their refcounts. 5173 */5174
__rbd_get_client(rbd_dev->rbd_client);
5175rbd_spec_get(rbd_dev->parent_spec);We will need to put these on any later error paths.
And we do, in rbd_dev_destroy(parent), since these are references for the parent.
Quoted 16 lines
5176 5177 ret = rbd_dev_image_probe(parent, depth); 5178 if (ret < 0) 5179 goto out_err;Ok. We need to put the ->parent_spec, ->rbd_client and free the parent.
5180 5181 rbd_dev->parent = parent; 5182 atomic_set(&rbd_dev->parent_ref, 1); 5183 return 0; 5184 5185 out_err: 5186 rbd_dev_unparent(rbd_dev);
Quoted 6 lines
This is a complicated way to say
rbd_spec_put(rbd_dev->parent_spec);Also, is it really necessary to set ->parent_spec to NULL? If we didn't put the last reference then doesn't setting it to NULL mean we are leaking? Setting it to NULL is confusing and feels like a layering violation.
Yes, because as it is, ->parent_spec is a determinant of whether or not the image has a parent. If we fail in rbd_dev_probe_parent(), it needs to be set to NULL to signify that the image doesn't have a parent. Even if the entire thing was refactored, we'd still have to do the same because not every image has a parent and the same error path has to work for all images. The layering violation is that we have to do in rbd_dev_probe_parent() even though we didn't allocate it there.
Quoted 10 lines
5187 if (parent) 5188 rbd_dev_destroy(parent); 5189 return ret; 5190 }I feel like we should be calling
rbd_put_client()on this error path or else the code is buggy or has layer violations. So I *think* it should look like this:
Quoted 7 lines
dec_ref_counts:rbd_spec_put(rbd_dev->parent_spec); rbd_put_client(rbd_dev->rbd_client); rbd_dev_destroy(parent); return ret;
We do, in rbd_dev_destroy(parent).
Thanks,
Ilya
Re: [PATCH 2/2] block-rbd: One function call less in rbd_dev_probe_parent() after error detection
Ah... I see now. Thanks.
regards,
dan carpenter
Re: block-rbd: One function call less in rbd_dev_probe_parent() after error detection
In reply to Ilya DryomovQuoted 5 lines
Quoted 2 lines
I interpreted the eventual passing of a null pointer to the
rbd_dev_destroy()function as an indication for further source code adjustments.If all error paths could be adjusted so that NULL pointers are never passed in, destroy functions wouldn't need to have a NULL check, would they?
How do you think about to clarify corresponding implementation details a bit more?
* Why was the function "rbd_dev_probe_parent" implemented in the way that it relies on a sanity check in the function "rbd_dev_destroy" then?
* How are the chances to restructure the source code a bit (like changing a few jump labels) so that it should also work without an extra function call during error handling there?
Regards,
Markus
Ilya Dryomov
maintainerRe: block-rbd: One function call less in rbd_dev_probe_parent() after error detection
Quoted 10 lines · SF Markus Elfring
Quoted 5 lines
Quoted 2 lines
I interpreted the eventual passing of a null pointer to the
rbd_dev_destroy()function as an indication for further source code adjustments.If all error paths could be adjusted so that NULL pointers are never passed in, destroy functions wouldn't need to have a NULL check, would they?
How do you think about to clarify corresponding implementation details a bit more?
* Why was the function "
rbd_dev_probe_parent" implemented in the way that it relies on a sanity check in the function "rbd_dev_destroy" then?
Because it's not a bad thing? What's wrong with an init to NULL, a possible assignment, in this case from rbd_dev_create(), and an unconditional rbd_dev_destroy()?
The NULL check in rbd_dev_destroy() is not a sanity check, it's a feature. It's not there to "fixup" callers that pass NULL - it's there because it is _expected_ that some callers will pass NULL.
Quoted 3 lines
* How are the chances to restructure the source code a bit (like changing a few jump labels) so that it should also work without an extra function call during error handling there?
As I said in my reply to Dan, the problem with rbd_dev_probe_parent() is the calling code which expects it to call unparent if ->parent_spec. This makes it stand out and confuses people, but can't be fixed without refactoring a bunch of other code.
The extra function call is *not* a problem.
Thanks,
Ilya
Re: block-rbd: One function call less in rbd_dev_probe_parent() after error detection
Quoted 4 lines
Quoted 2 lines
* Why was the function "
rbd_dev_probe_parent" implemented in the way that it relies on a sanity check in the function "rbd_dev_destroy" then?Because it's not a bad thing?
There are different opinions about this implementation detail.
Quoted 2 lines
What's wrong with an init to NULL, a possible assignment, in this case from
rbd_dev_create(), and an unconditionalrbd_dev_destroy()?
Does this approach look like it is affected by a "one error jump label bug" symptom?
Quoted 2 lines
The NULL check in
rbd_dev_destroy()is not a sanity check, it's a feature.
I have got an other impression here.
Quoted 1 line
It's not there to "fixup" callers that pass NULL
It seems that the explanations on the detail why a function tolerates passed null pointers can also be different.
Quoted 1 line
- it's there because it is _expected_ that some callers will pass NULL.
I find it still unnecessary to let a called function like "rbd_dev_destroy" to repeat the check when you know already that the passed variable contains a null pointer.
Quoted 4 lines
As I said in my reply to Dan, the problem with
rbd_dev_probe_parent()is the calling code which expects it to call unparent if ->parent_spec. This makes it stand out and confuses people, but can't be fixed without refactoring a bunch of other code.
I would appreciate if the discussed function could be also improved by itself. More refactoring might follow at other source code places later.
Quoted 1 line
The extra function call is *not* a problem.
How many software developers and reviewers will care if corresponding error handling can also become a bit more efficient?
Regards,
Markus
PATCH 1/1 GPU-DRM-Radeon: Delete an unnecessary check before drm_gem_object_unreference_unlocked()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 12 Jul 2016 22:00:55 +0200
The drm_gem_object_unreference_unlocked() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/radeon/radeon_display.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/radeon/radeon_display.c +1 -3
@@ -1324,9 +1324,7 @@ static void radeon_user_framebuffer_destroy(struct drm_framebuffer *fb) {struct radeon_framebuffer *radeon_fb =to_radeon_framebuffer (fb); -if (radeon_fb->obj) { -drm_gem_object_unreference_unlocked (radeon_fb->obj); - } +drm_gem_object_unreference_unlocked (radeon_fb->obj);drm_framebuffer_cleanup (fb);kfree (radeon_fb); }
Signature · 1 line
2.9.0