[systemd-devel] [PATCH 3/3] coredump: make use of the cleanup macros

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Mon Feb 4 09:01:02 PST 2013


On Mon, Feb 04, 2013 at 03:13:25PM +0100, Mirco Tischler wrote:
> ---
>  src/journal/coredump.c | 28 ++++++----------------------
>  1 file changed, 6 insertions(+), 22 deletions(-)
> 
> diff --git a/src/journal/coredump.c b/src/journal/coredump.c
> index 91528d3..4f79c45 100644
> --- a/src/journal/coredump.c
> +++ b/src/journal/coredump.c
> @@ -32,6 +32,7 @@
>  
>  #include "log.h"
>  #include "util.h"
> +#include "macro.h"
>  #include "mkdir.h"
>  #include "special.h"
>  #include "cgroup-util.h"
> @@ -49,7 +50,7 @@ enum {
>  };
>  
>  static int divert_coredump(void) {
> -        FILE *f;
> +        _cleanup_fclose_ FILE *f = NULL;
>          int r;
>  
>          log_info("Detected coredump of the journal daemon itself, diverting coredump to /var/lib/systemd/coredump/.");
> @@ -94,21 +95,20 @@ static int divert_coredump(void) {
>          }
>  
>  finish:
> -        fclose(f);
>          return r;
>  }
>  
Hi,
if you do that, than you can go one step further, and get rid of
finish label. We don't enforce a single point of return, and it
is easier to read 'return -errno' instead of 'r = -errno; ...; return r;'.

Zbyszek


More information about the systemd-devel mailing list