This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] glob: Avoid copying the d_name field of struct dirent [BZ #19779]
- From: Roland McGrath <roland at hack dot frob dot com>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Tue, 3 May 2016 14:46:19 -0700 (PDT)
- Subject: Re: [PATCH] glob: Avoid copying the d_name field of struct dirent [BZ #19779]
- Authentication-results: sourceware.org; auth=none
- References: <56E339A7 dot 7060704 at redhat dot com> <20160311222757 dot DB90C2C3C24 at topped-with-meat dot com> <56FBBA94 dot 1040605 at redhat dot com> <20160330232737 dot 2A3F32C3C35 at topped-with-meat dot com> <56FD5B69 dot 1010002 at redhat dot com> <20160401215549 dot E32FC2C3BCD at topped-with-meat dot com> <57233290 dot 8090900 at redhat dot com> <20160502224824 dot 2E3F62C3B69 at topped-with-meat dot com> <5728DD49 dot 8020608 at redhat dot com>
> >> + struct readdir_result result = {NULL};
> >
> > Put spaces around NULL, or just use {} (which has the same semantics).
>
> I have to use NULL because empty initializers are not part of C89. So I
> added the spaces.
OK. FWIW, I usually use a trailing comma i.e. "{ NULL, }" as implicit
documentation that it's zero-initializing members I didn't list explicitly.
> I prefer having the copy, it is quite short and avoids another level of
> macro nesting.
The libc sources are riddled with the evidence of my pathological aversion
to duplicated code, and there are certainly cases to be made that it has
not always been the easiest thing to maintain. Knee-jerk reactions aside,
my true motivation is to ease maintenance and minimize chances of omitting
a change in one place when making it in the other. So if we manifestly
achieve that not happening, then it's fine.
> I'm attaching the new version.
OK by me.