What is the preferred code style for uclibc?
Denys Vlasenko
vda.linux at googlemail.com
Mon Dec 1 19:44:55 UTC 2008
Hi Bernhard, folks,
Can you indicate what coding style you prefer
in uclibc?
Curretly we have a mixture of all kinds,
GNU style with its uniquely difficult placement
of {}s:
if (set == NULL || signo <= 0 || signo >= NSIG)
{
__set_errno (EINVAL);
return -1;
}
indent-by-4 style:
if (act) {
kact.k_sa_handler = act->sa_handler;
kact.sa_mask = act->sa_mask.__val[0];
kact.sa_flags = act->sa_flags;
# ifdef HAVE_SA_RESTORER
if (kact.sa_flags & SA_RESTORER) {
kact.sa_restorer = act->sa_restorer;
} else {
kact.sa_restorer = choose_restorer (kact.sa_flags);
kact.sa_flags |= SA_RESTORER;
}
# endif
}
Linux kernel style:
if (bufsize > count) {
bufsize = count;
if (count == 0) { /* We're at the end of the buffer... */
__set_errno(EFBIG);
return -1;
}
}
etc.
Can you let us know what aspects of style you plan to
make more uniform, and in what way; what you don't plan
to regulate.
For example, how would you write this?
while ((n > 1)
&& ((wi = fgetwc_unlocked(stream)) != WEOF)
&& ((*p++ = wi) != '\n')
) {
--n;
}
I promise to not engage in gratuitous style changes,
there will be no rain of commits with s/spaces/tabs/, :)
I merely plan to follow the agreed-on style in the code
I touch.
--
vda
More information about the uClibc
mailing list