]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
man/: Use typeof() to improve readability of function pointer types
authorAlejandro Colomar <alx@kernel.org>
Sun, 5 Jan 2025 19:22:04 +0000 (20:22 +0100)
committerAlejandro Colomar <alx@kernel.org>
Sun, 5 Jan 2025 19:45:44 +0000 (20:45 +0100)
An exception of good taste is structure members.  There, for alignment
reasons, traditional syntax seems more appropriate usually.

Suggested-by: Jorenar <dev@jorenar.com>
Cc: Martin Uecker <uecker@tugraz.at>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
man/man2/clone.2
man/man2/init_module.2
man/man2/signal.2
man/man3/dlopen.3
man/man3/malloc_hook.3
man/man3/rpc.3
man/man3/xdr.3

index 9428a56450c101bdeecb36b7c70944d91706e89b..3ffe8e7b821545d29575c3e91bdb996de83cbc6a 100644 (file)
@@ -1683,7 +1683,7 @@ On ia64, a different interface is used:
 .P
 .in +4n
 .EX
-.BI "int __clone2(int (*" "fn" ")(void *),"
+.BI "int __clone2(typeof(int (void *)) *" fn ,
 .BI "             void *" stack_base ", size_t " stack_size ,
 .BI "             int " flags ", void *" "arg" ", ..."
 .BI "          \fR/*\fP pid_t *" parent_tid ", struct user_desc *" tls ,
index b00b5a50c553226f5252dc99994e597e9d5f2256..5aed13e2ccae7e259ecb443f28da2f7a8faa48dd 100644 (file)
@@ -358,8 +358,8 @@ struct module {
     struct module_symbol *syms;
     struct module_ref    *deps;
     struct module_ref    *refs;
-    int                 (*init)(void);
-    void                (*cleanup)(void);
+    typeof(int (void))   *init;
+    typeof(void (void))  *cleanup;
     const struct exception_table_entry *ex_table_start;
     const struct exception_table_entry *ex_table_end;
 #ifdef __alpha__
index b4ac3922a79861e5b34e933d4b52c422a2a478c1..1e0e5f6c1580bcc726c1ed90a88405f519892a8e 100644 (file)
@@ -116,7 +116,7 @@ is the somewhat harder to read:
 .P
 .in +4n
 .EX
-.BI "void ( *" signal "(int " signum ", void (*" handler ")(int)) ) (int);"
+.BI "typeof(void (int)) *signal(int " signum ", typeof(void (int)) *" handler );
 .EE
 .in
 .SS Portability
index c3c6a9a9194cd8fa8c5f807e1b7d2c69d9be01d0..2c4ab2c25048b4d2247d8e85e37acbfe1aea5665 100644 (file)
@@ -564,7 +564,7 @@ int
 main(void)
 {
     void *handle;
-    double (*cosine)(double);
+    typeof(double (double)) *cosine;
     char *error;
 \&
     handle = dlopen(LIBM_SO, RTLD_LAZY);
@@ -575,7 +575,7 @@ main(void)
 \&
     dlerror();    /* Clear any existing error */
 \&
-    cosine = (double (*)(double)) dlsym(handle, "cos");
+    cosine = (typeof(double (double)) *) dlsym(handle, "cos");
 \&
     /* According to the ISO C standard, casting between function
        pointers and \[aq]void *\[aq], as done above, produces undefined results.
index afb253ea2620b99caa5ebc303a45b0e0ab55c934..0305f3ea8c097edd1230f9ca0a0aa47253112dcb 100644 (file)
@@ -52,7 +52,7 @@ the application with a definition like the following:
 .P
 .in +4n
 .EX
-void (*__malloc_initialize_hook)(void) = my_init_hook;
+typeof(void (void))  *__malloc_initialize_hook = my_init_hook;
 .EE
 .in
 .P
@@ -112,10 +112,10 @@ static void my_init_hook(void);
 static void *my_malloc_hook(size_t, const void *);
 \&
 /* Variables to save original hooks */
-static void *(*old_malloc_hook)(size_t, const void *);
+static typeof(void *(size_t, const void *))  *old_malloc_hook;
 \&
 /* Override initializing hook from the C library */
-void (*__malloc_initialize_hook)(void) = my_init_hook;
+typeof(void (void))  *__malloc_initialize_hook = my_init_hook;
 \&
 static void
 my_init_hook(void)
index 74a0c9313748c8a3677b69b0ab1d37fb225e0599..b5d7d84c4aeaed1604c2b28b5190ca11bdf4f2f6 100644 (file)
@@ -37,10 +37,10 @@ The prototypes below make use of the following types:
 .EX
 .BI "typedef int " bool_t ;
 .P
-.BI "typedef bool_t (*" xdrproc_t ")(XDR *, void *, ...);"
+.BI "typedef typeof(bool_t (XDR *, void *, ...))  *" xdrproc_t ;
 .P
-.BI "typedef bool_t (*" resultproc_t ")(caddr_t " resp ,
-.BI "                               struct sockaddr_in *" raddr );
+.BI "typedef typeof(bool_t (caddr_t " resp ", struct sockaddr_in *" raddr )
+.BI "    *" resultproc_t ;
 .EE
 .RE
 .P
@@ -644,7 +644,7 @@ This routine returns one if it succeeds, zero otherwise.
 .P
 .nf
 .BI "int registerrpc(unsigned long " prognum ", unsigned long " versnum ,
-.BI "                unsigned long " procnum ", char *(*" procname ")(char *),"
+.BI "                unsigned long " procnum ", typeof(char *(char *)) *" procname ,
 .BI "                xdrproc_t " inproc ", xdrproc_t " outproc );
 .fi
 .IP
@@ -785,7 +785,7 @@ This interface is obsoleted by
 .nf
 .BI "bool_t svc_register(SVCXPRT *" xprt ", unsigned long " prognum ,
 .BI "                    unsigned long " versnum ,
-.BI "                    void (*" dispatch ")(struct svc_req *, SVCXPRT *),"
+.BI "                    typeof(void (struct svc_req *, SVCXPRT *)) *" dispatch ,
 .BI "                    unsigned long " protocol );
 .fi
 .IP
index a4c906526f6af0ec91274aa2b33ac89d8dfc4c5e..25181f4814d57f79fdf35bb22636632d34f454d6 100644 (file)
@@ -29,7 +29,7 @@ and make use of the following types:
 .EX
 .BI "typedef int " bool_t ;
 .P
-.BI "typedef bool_t (*" xdrproc_t ")(XDR *, void *,...);"
+.BI "typedef typeof(bool_t (XDR *, void *, ...))  *" xdrproc_t ;
 .EE
 .RE
 .P
@@ -264,8 +264,8 @@ linked lists.
 .nf
 .BI "void xdrrec_create(XDR *" xdrs ", unsigned int " sendsize ,
 .BI "                   unsigned int " recvsize ", char *" handle ,
-.BI "                   int (*" readit ")(char *, char *, int),"
-.BI "                   int (*" writeit ")(char *, char *, int));"
+.BI "                   typeof(int (char *, char *, int)) *" readit ,
+.BI "                   typeof(int (char *, char *, int)) *" writeit );
 .fi
 .IP
 This routine initializes the XDR stream object pointed to by