Hey Zbyszek,

Zbigniew Jędrzejewski-Szmek [2015-01-28 15:37 +0100]:
> > +static int handle_requests(int socket_fd) {
> > +        Clients *first = NULL;
> > +        usec_t last_activity = 0;
> > +        int numdevices = 0, clear = 0;
> > +        double percent = 100;
> > +        _cleanup_fclose_ FILE *console = NULL;
> NULL not necessary (and you don't have it in similar circumstances above ;))

How is that not necessary? Just because the very next line initializes
it, and there is no exit path before? Because in the general case it
certainly is necessary, otherwise the _cleanup_ handler will try to
free/close/clean up a random pointer value and crash.

So IMHO it's a good defensive habit to always init _cleanup_* vars
with NULL. In the future someone might put some code with "return"
before the fopen() below, and then get a crash.

Or is there some gcc magic that I missed? (I thought only global
variables were guaranteed to be NULL, not stack vars).

> 
> > +
> > +        console = fopen("/dev/console", "we");

Thanks for clarifying,

Martin
-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)

Attachment: signature.asc
Description: Digital signature

_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to