Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1445055

Re: [PATCH 7/8] drm/amd/powerplay: Change assignment for a buffer variable in phm_dispatch_table()

From walter harms <wharms@bfs.de>
Newsgroups linux.kernel
Subject Re: [PATCH 7/8] drm/amd/powerplay: Change assignment for a buffer variable in phm_dispatch_table()
Date 2016-07-17 17:10 +0200
Message-ID <rVVRD-2lL-3@gated-at.bofh.it> (permalink)
References (15 earlier) <mSsDN-4wa-65@gated-at.bofh.it> <mSsDN-4wa-33@gated-at.bofh.it> <pGgrL-7JT-5@gated-at.bofh.it> <rVyV3-4Wl-5@gated-at.bofh.it> <rVzo6-5n4-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



Am 16.07.2016 17:08, schrieb SF Markus Elfring:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/gpu/drm/amd/powerplay/hwmgr/functiontables.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/functiontables.c b/drivers/gpu/drm/amd/powerplay/hwmgr/functiontables.c
> index 024e22e..735aeb0 100644
> --- a/drivers/gpu/drm/amd/powerplay/hwmgr/functiontables.c
> +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/functiontables.c
> @@ -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);


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

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/8] drm/amdgpu: Fine-tuning for three function  implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-16 16:40 +0200
  [PATCH 2/8] drm/amdgpu/powerplay: Delete unnecessary checks before  the function call "kfree" SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-16 16:50 +0200
  [PATCH 1/8] drm/amdgpu: Delete an unnecessary check before  drm_gem_object_unreference_unlocked() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-16 16:50 +0200
  [PATCH 4/8] drm/amdgpu: Delete a variable in  amdgpu_cgs_acpi_eval_object() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-16 17:00 +0200
    [PATCH 5/8] drm/amdgpu: Delete an unnecessary variable initialisation  in amdgpu_cgs_acpi_eval_object() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-16 17:00 +0200
  [PATCH 3/8] drm/amdgpu: One function call less in  amdgpu_cgs_acpi_eval_object() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-16 17:00 +0200
  [PATCH 6/8] drm/amdgpu: Change assignment for a variable in  amdgpu_cgs_acpi_eval_object() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-16 17:10 +0200
  [PATCH 7/8] drm/amd/powerplay: Change assignment for a buffer  variable in phm_dispatch_table() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-16 17:10 +0200
    Re: [PATCH 7/8] drm/amd/powerplay: Change assignment for a buffer  variable in phm_dispatch_table() walter harms <wharms@bfs.de> - 2016-07-17 17:10 +0200
  [PATCH 5/8] drm/amdgpu: Delete an unnecessary variable initialisation  in amdgpu_cgs_acpi_eval_object() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-16 17:10 +0200
  [PATCH 8/8] drm/amd/powerplay: Delete an unnecessary variable  initialisation in phm_dispatch_table() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-16 17:20 +0200

csiph-web