Today I found this gem on the GIT mailing list:
Timo Hirvonen wrote:
> Linus Torvalds wrote:
>
> > +void verify_filename(const char *prefix, const char *arg)
> > +{
> > + const char *name;
> > + struct stat st;
> > +
> > + if (*arg == '-')
> > + die("bad flag '%s' used after filename", arg);
> > + name = prefix ? prefix_filename(prefix, strlen(prefix), arg) : arg;
> > + if (!lstat(name, &st))
> > + return;
> > + if (errno == ENOENT);
>
> Extra semicolon.
Just what were the authors of C thinking when they decided to allow:
if (errno == ENOENT);
as a legal statement? It clearly has no real purpose as the "then-clause" of the if statement is completely empty.
What's really bad is this language feature is also available in C++, Objective-C, Java, Perl, etc. I'm so glad modern language designers have kept the warts intact.