Re: Formatting very long function parameters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/8/21 2:54 PM, Alejandro Colomar (man-pages) wrote:
> Hi Michael,
> 
> I have a problem with pthread_mutexattr_getpshared(3).
> After adding 'restrict', the first parameter alone would use 81 columns,
> so I came with 3 options:
> 
> A)	Move the parameter to a new line,
> 	leaving the open parenthesis at the end of a line.
> 
> [
>         int pthread_mutexattr_getpshared(
>                                       const pthread_mutexattr_t 
> *restrict attr,
>                                       int *restrict pshared);
>         int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr,
>                                       int pshared);
> ]
> 
> B)	Compact the pointer to use only 80 columns,
> 	by deleting a cosmetic whitespace,
> 	and exceptionally ignore the 78-column right margin.
> 
> [
>         int pthread_mutexattr_getpshared(const 
> pthread_mutexattr_t*restrict attr,
>                                          int *restrict pshared);
>         int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr,
>                                          int pshared);
> ]
> 
> C)	(What POSIX does) Break the 1st parameter at the pointer:
> 
> [
>         int pthread_mutexattr_getpshared(const pthread_mutexattr_t
>                                          *restrict attr,
>                                          int *restrict pshared);
>         int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr,
>                                          int pshared);
> ]
> 
> 
> I did the 1st one, but I'm not sure about it.  Do you have any preference?

I think (A) is more or less the way to go. But, so long as we
can't line anything up below the "(" of any function declaration,
I decided to tweak that a little so that the follow-on arguments
are not so deeply indented (which looks a little strange, I find).
Thus my commit 48ee34e75.

Cheers,

Michael


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux