Bug 280514 - Function cast warnings in lib/libypclnt
Summary: Function cast warnings in lib/libypclnt
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 15.0-CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Mark Johnston
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-07-30 18:09 UTC by Dimitry Andric
Modified: 2024-11-05 16:20 UTC (History)
2 users (show)

See Also:


Attachments
clang 19 warnings emitted for lib/libypclnt (12.86 KB, text/plain)
2024-07-30 18:09 UTC, Dimitry Andric
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitry Andric freebsd_committer freebsd_triage 2024-07-30 18:09:52 UTC
Created attachment 252374 [details]
clang 19 warnings emitted for lib/libypclnt

While doing a buildworld with https://github.com/DimitryAndric/freebsd-src/tree/llvm-19-update using clang 19, I got a number of -Wcast-function-type-mismatch warnings for lib/libypclnt (via the generated $WORLDTMP/usr/include/rpc/clnt.h headers):

yp_clnt.c:19:3: warning: cast from 'bool_t (*)(void)' (aka 'int (*)(void)') to 'xdrproc_t' (aka 'int (*)(struct XDR *, ...)') converts to incompatible function type [-Wcast-function-type-mismatch
   19 |                 (xdrproc_t) xdr_void, (caddr_t) argp,
      |                 ^~~~~~~~~~~~~~~~~~~~
/usr/obj/share/dim/src/freebsd/llvm-19-update/amd64.amd64/tmp/usr/include/rpc/clnt.h:162:38: note: expanded from macro 'clnt_call'
  162 |         ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, \
      |                                             ^~~~~

and a bunch more of these. I attached a log file with the full list of warnings.
Comment 1 Brooks Davis freebsd_committer freebsd_triage 2024-07-30 18:30:52 UTC
We've got a number of xdr and rpc related function type fixes in CheriBSD where having things be wrong breaks functionality.  I'll look into upstreaming them.
Comment 2 Brooks Davis freebsd_committer freebsd_triage 2024-09-13 08:15:03 UTC
I took a look at this and the changes I'd made to CheriBSD aren't what we want here. Fortunately, it looks like you can fix these warnings with a simple change:

diff --git a/include/rpc/xdr.h b/include/rpc/xdr.h
index 11d6a8d13b49..ecf10e1659e4 100644
--- a/include/rpc/xdr.h
+++ b/include/rpc/xdr.h
@@ -278,7 +278,7 @@ struct xdr_discrim {
  * These are the "generic" xdr routines.
  */
 __BEGIN_DECLS
-extern bool_t  xdr_void(void);
+extern bool_t  xdr_void(XDR *, void *);
 extern bool_t  xdr_int(XDR *, int *);
 extern bool_t  xdr_u_int(XDR *, u_int *);
 extern bool_t  xdr_long(XDR *, long *);
diff --git a/lib/libc/xdr/xdr.c b/lib/libc/xdr/xdr.c
index 6992cae69bf1..5db3b0eb212e 100644
--- a/lib/libc/xdr/xdr.c
+++ b/lib/libc/xdr/xdr.c
@@ -84,9 +84,8 @@ xdr_free(xdrproc_t proc, void *objp)
  * XDR nothing
  */
 bool_t
-xdr_void(void)
+xdr_void(XDR *xdrs __unused, void *p __unused)
 {
-
        return (TRUE);
 }
Comment 3 commit-hook freebsd_committer freebsd_triage 2024-10-30 19:29:06 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=a5d1cf5e362a2e3c3ebdf6d8f2b86658a6d0b9d6

commit a5d1cf5e362a2e3c3ebdf6d8f2b86658a6d0b9d6
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-10-30 19:27:18 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-10-30 19:27:18 +0000

    rpc: Fix the definition of xdr_void()

    xdr_void() should have type xdrproc_t, make it so.

    PR:             280514
    Reviewed by:    brooks, dim
    MFC after:      2 weeks
    Differential Revision:  https://reviews.freebsd.org/D47340

 include/rpc/xdr.h  | 2 +-
 lib/libc/xdr/xdr.c | 4 +---
 sys/rpc/xdr.h      | 2 +-
 sys/xdr/xdr.c      | 3 +--
 4 files changed, 4 insertions(+), 7 deletions(-)
Comment 4 commit-hook freebsd_committer freebsd_triage 2024-11-05 14:30:54 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=b698c825f3b6699b278122da776bdfe5f360619f

commit b698c825f3b6699b278122da776bdfe5f360619f
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-10-30 19:27:18 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-11-05 01:05:26 +0000

    rpc: Fix the definition of xdr_void()

    xdr_void() should have type xdrproc_t, make it so.

    PR:             280514
    Reviewed by:    brooks, dim
    MFC after:      2 weeks
    Differential Revision:  https://reviews.freebsd.org/D47340

    (cherry picked from commit a5d1cf5e362a2e3c3ebdf6d8f2b86658a6d0b9d6)

 include/rpc/xdr.h  | 2 +-
 lib/libc/xdr/xdr.c | 4 +---
 sys/rpc/xdr.h      | 2 +-
 sys/xdr/xdr.c      | 3 +--
 4 files changed, 4 insertions(+), 7 deletions(-)
Comment 5 commit-hook freebsd_committer freebsd_triage 2024-11-05 14:30:55 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=b59d578945807e487a2ed20ff6387f40c89db47d

commit b59d578945807e487a2ed20ff6387f40c89db47d
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-10-30 19:27:18 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-11-05 01:05:31 +0000

    rpc: Fix the definition of xdr_void()

    xdr_void() should have type xdrproc_t, make it so.

    PR:             280514
    Reviewed by:    brooks, dim
    MFC after:      2 weeks
    Differential Revision:  https://reviews.freebsd.org/D47340

    (cherry picked from commit a5d1cf5e362a2e3c3ebdf6d8f2b86658a6d0b9d6)

 include/rpc/xdr.h  | 2 +-
 lib/libc/xdr/xdr.c | 4 +---
 sys/rpc/xdr.h      | 2 +-
 sys/xdr/xdr.c      | 3 +--
 4 files changed, 4 insertions(+), 7 deletions(-)
Comment 6 commit-hook freebsd_committer freebsd_triage 2024-11-05 16:20:10 UTC
A commit in branch releng/14.2 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=a231e2990776a28f8c3b01b946e7774b3f6bb39b

commit a231e2990776a28f8c3b01b946e7774b3f6bb39b
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-10-30 19:27:18 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-11-05 16:17:03 +0000

    rpc: Fix the definition of xdr_void()

    xdr_void() should have type xdrproc_t, make it so.

    Approved by:    re (kib)
    PR:             280514
    Reviewed by:    brooks, dim
    MFC after:      2 weeks
    Differential Revision:  https://reviews.freebsd.org/D47340

    (cherry picked from commit a5d1cf5e362a2e3c3ebdf6d8f2b86658a6d0b9d6)
    (cherry picked from commit b698c825f3b6699b278122da776bdfe5f360619f)

 include/rpc/xdr.h  | 2 +-
 lib/libc/xdr/xdr.c | 4 +---
 sys/rpc/xdr.h      | 2 +-
 sys/xdr/xdr.c      | 3 +--
 4 files changed, 4 insertions(+), 7 deletions(-)