mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shuah Khan <shuah@kernel.org>
To: "SF Markus Elfring" <elfring@users.sourceforge.net>,
	linux-kselftest@vger.kernel.org,
	"Emilio López" <emilio.lopez@collabora.co.uk>
Cc: LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org,
	Shuah Khan <shuahkh@osg.samsung.com>,
	Shuah Khan <shuah@kernel.org>
Subject: Re: [PATCH] selftest: sync: Use common error handling code in sync_file_info()
Date: Tue, 21 Nov 2017 08:46:52 -0700	[thread overview]
Message-ID: <3a27095e-84ad-6e93-bae5-3b242a042238@kernel.org> (raw)
In-Reply-To: <219c366b-d753-e65b-b021-6d4a584588d0@users.sourceforge.net>

On 11/20/2017 02:25 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 20 Nov 2017 22:20:37 +0100
> 
> Add a jump target so that a bit of exception handling can be better reused
> at the end of this function.
> 
> This issue was detected by using the Coccinelle software.

I would like to see the Coccinelle log included in the commit log

> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  tools/testing/selftests/sync/sync.c | 19 +++++++++----------
>  1 file changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/tools/testing/selftests/sync/sync.c b/tools/testing/selftests/sync/sync.c
> index f3d599f249b9..d0d55377f6f8 100644
> --- a/tools/testing/selftests/sync/sync.c
> +++ b/tools/testing/selftests/sync/sync.c
> @@ -92,10 +92,8 @@ static struct sync_file_info *sync_file_info(int fd)
>  		return NULL;
>  
>  	err = ioctl(fd, SYNC_IOC_FILE_INFO, info);
> -	if (err < 0) {
> -		free(info);
> -		return NULL;
> -	}
> +	if (err < 0)
> +		goto free_info;
>  
>  	num_fences = info->num_fences;
>  
> @@ -104,22 +102,23 @@ static struct sync_file_info *sync_file_info(int fd)
>  		info->num_fences = num_fences;
>  
>  		fence_info = calloc(num_fences, sizeof(*fence_info));
> -		if (!fence_info) {
> -			free(info);
> -			return NULL;
> -		}
> +		if (!fence_info)
> +			goto free_info;
>  
>  		info->sync_fence_info = (uint64_t)fence_info;
>  
>  		err = ioctl(fd, SYNC_IOC_FILE_INFO, info);
>  		if (err < 0) {
>  			free(fence_info);

Why not add a free_fence_info to make it consistent?

> -			free(info);
> -			return NULL;
> +			goto free_info;
>  		}
>  	}
>  
>  	return info;
> +
> +free_info:
> +	free(info);
> +	return NULL;
>  }
>  
>  static void sync_file_info_free(struct sync_file_info *info)
> 

thanks,
-- Shuah

  reply	other threads:[~2017-11-21 15:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-20 21:25 SF Markus Elfring
2017-11-21 15:46 ` Shuah Khan [this message]
2017-11-21 18:55   ` SF Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3a27095e-84ad-6e93-bae5-3b242a042238@kernel.org \
    --to=shuah@kernel.org \
    --cc=elfring@users.sourceforge.net \
    --cc=emilio.lopez@collabora.co.uk \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=shuahkh@osg.samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®