This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 1/2]: Refactor relocate_path to also check if the relocated file/directory exists
On Fri, 21 Sep 2012 20:35:39 +0200, Eli Zaretskii wrote:
> > Date: Fri, 21 Sep 2012 20:26:37 +0200
> > From: Jan Kratochvil <jan.kratochvil@redhat.com>
> > Cc: GDB Patches <gdb-patches@sourceware.org>
> >
> > if (stat (path, &s) != 0 || (isdir && !S_ISDIR (s.st_mode))
> > || (!isdir && S_ISDIR (s.st_mode)))
>
> a.k.a.
>
> if (stat (path, &s) != 0 || isdir != S_ISDIR (s.st_mode))
It is not POSIX compliant:
The macro evaluates to a non-zero value if the test is true
It would have to be written as:
if (stat (path, &s) != 0 || !isdir != !S_ISDIR (s.st_mode))
I would find it still OK but this is why I wrote in the mail above:
# (I would write it differently but reviews here point to this style.)
Because I already posted some such patch here before and it was reviewed by
Joel to the form I wrote above. Unfortunately I cannot find the mail now, it
is difficult to find a search pattern for this case.
Regards,
Jan