Re: [PATCH 4/6] tools/gup_benchmark: Allow user specified file

From: Keith Busch
Date: Wed Oct 10 2018 - 18:45:46 EST


On Wed, Oct 10, 2018 at 03:31:01PM -0700, Andrew Morton wrote:
> On Wed, 10 Oct 2018 13:56:03 -0600 Keith Busch <keith.busch@xxxxxxxxx> wrote:
> > + filed = open(file, O_RDWR|O_CREAT);
> > + if (filed < 0)
> > + perror("open"), exit(filed);
>
> Ick. Like this, please:

Yeah, I agree. I just copied the style this file had been using in other
error cases, but I still find it less readable than your recommendation.

> --- a/tools/testing/selftests/vm/gup_benchmark.c~tools-gup_benchmark-allow-user-specified-file-fix
> +++ a/tools/testing/selftests/vm/gup_benchmark.c
> @@ -71,8 +71,10 @@ int main(int argc, char **argv)
> }
>
> filed = open(file, O_RDWR|O_CREAT);
> - if (filed < 0)
> - perror("open"), exit(filed);
> + if (filed < 0) {
> + perror("open");
> + exit(filed);
> + }
>
> gup.nr_pages_per_call = nr_pages;
> gup.flags = write;
>