Patchwork [1/2] bios: hdaaudio: use calloc() instead of malloc()

login
register
mail settings
Submitter Colin King
Date March 2, 2012, 9:52 a.m.
Message ID <1330681947-17406-2-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/144182/
State Accepted
Headers show

Comments

Colin King - March 2, 2012, 9:52 a.m.
From: Colin Ian King <colin.king@canonical.com>

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/bios/hdaaudio/hdaaudio.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
Keng-Yu Lin - March 5, 2012, 9:01 a.m.
On Fri, Mar 2, 2012 at 5:52 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/bios/hdaaudio/hdaaudio.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/src/bios/hdaaudio/hdaaudio.c b/src/bios/hdaaudio/hdaaudio.c
> index b49f202..7dc1823 100644
> --- a/src/bios/hdaaudio/hdaaudio.c
> +++ b/src/bios/hdaaudio/hdaaudio.c
> @@ -43,7 +43,8 @@ static int hda_audio_read_pins(fwts_framework *fw, const char *path,
>                return FWTS_ERROR;
>
>        while (fscanf(fp, "0x%hx 0x%x\n", &pin, &setting) == 2) {
> -               if ((pin_setting = malloc(sizeof(hda_audio_pin_setting))) == NULL) {
> +               pin_setting = calloc(1, sizeof(hda_audio_pin_setting));
> +               if (pin_setting == NULL) {
>                        fwts_list_free(settings, free);
>                        fclose(fp);
>                        return FWTS_ERROR;
> --
> 1.7.9
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
Alex Hung - March 7, 2012, 9:54 a.m.
On 03/02/2012 05:52 PM, Colin King wrote:
> From: Colin Ian King<colin.king@canonical.com>
>
> Signed-off-by: Colin Ian King<colin.king@canonical.com>
> ---
>   src/bios/hdaaudio/hdaaudio.c |    3 ++-
>   1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/src/bios/hdaaudio/hdaaudio.c b/src/bios/hdaaudio/hdaaudio.c
> index b49f202..7dc1823 100644
> --- a/src/bios/hdaaudio/hdaaudio.c
> +++ b/src/bios/hdaaudio/hdaaudio.c
> @@ -43,7 +43,8 @@ static int hda_audio_read_pins(fwts_framework *fw, const char *path,
>   		return FWTS_ERROR;
>
>   	while (fscanf(fp, "0x%hx 0x%x\n",&pin,&setting) == 2) {
> -		if ((pin_setting = malloc(sizeof(hda_audio_pin_setting))) == NULL) {
> +		pin_setting = calloc(1, sizeof(hda_audio_pin_setting));
> +		if (pin_setting == NULL) {
>   			fwts_list_free(settings, free);
>   			fclose(fp);
>   			return FWTS_ERROR;
Acked-by: Alex Hung <alex.hung@canonical.com>

Patch

diff --git a/src/bios/hdaaudio/hdaaudio.c b/src/bios/hdaaudio/hdaaudio.c
index b49f202..7dc1823 100644
--- a/src/bios/hdaaudio/hdaaudio.c
+++ b/src/bios/hdaaudio/hdaaudio.c
@@ -43,7 +43,8 @@  static int hda_audio_read_pins(fwts_framework *fw, const char *path,
 		return FWTS_ERROR;
 
 	while (fscanf(fp, "0x%hx 0x%x\n", &pin, &setting) == 2) {
-		if ((pin_setting = malloc(sizeof(hda_audio_pin_setting))) == NULL) {
+		pin_setting = calloc(1, sizeof(hda_audio_pin_setting));
+		if (pin_setting == NULL) {
 			fwts_list_free(settings, free);
 			fclose(fp);
 			return FWTS_ERROR;