[systemd-devel] [PATCH 3/3] coredump: make use of the cleanup macros
Mirco Tischler
mt-ml at gmx.de
Mon Feb 4 16:41:01 PST 2013
2013/2/4 Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
> 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
>
Thanks for your comment; new patch following.
I tried the same for main() but return EXIT_FAILURE; all over the place
just looks ugly in my eyes.
Mirco
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20130205/fa991de0/attachment.html>
More information about the systemd-devel
mailing list