summarylogtreecommitdiffstats
path: root/0003-ubik-Use-typedef-for-ubik_call-function-parameter.patch
blob: 0ca632b8e4f91b64d9f37fc94850049e710011c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
From 514a8cb4eec6efdf85b54656f36a7caff54dab23 Mon Sep 17 00:00:00 2001
From: Cheyenne Wills <cwills@sinenomine.net>
Date: Tue, 13 May 2025 11:02:24 -0600
Subject: [PATCH 3/3] ubik: Use typedef for ubik_call function parameter
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

One of ubik_Call()/ubik_CallIter()/ubik_Call_SingleServer() parameters
is a function pointer (aproc). A function signature for this parameter
is not specified which leads to a strict-prototype warning which has
been addressed by suppressing the check by adding the
-Wno-strict-prototypes compiler flag for the files that need it.

A new C standard (C23) is coming out and newer versions of C compilers
(e.g. gcc 15) are using the new standard (or an extension of that
standard) as their default. The C23 standard has removed the ability to
declare functions with unspecified parameters; now any function that is
declared as:

   int foo();

is treated as:

   int foo(void);

Building with gcc-15 results in the following types of compile time
errors (even when -Wno-strict-prototypes is used):

  ubikclient.c: In function ‘CallIter’:
  ubikclient.c:391:10: error: too many arguments to function ‘aproc’; expected 0, have 17
    391 |         (*aproc) (tc, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
        |         ~^~~~~~~  ~~
  ubikclient.c: In function ‘ubik_Call’:
  ubikclient.c:577:18: error: too many arguments to function ‘aproc’; expected 0, have 17
    577 |                 (*aproc) (tc, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
        |                 ~^~~~~~~  ~~

To avoid this error, we must declare the parameters for the 'aproc'
function pointer.

Define a typedef, ubik_call_func, that can be used to define the data
type for the function parameter and can also be used as a cast on the
function parameter when calling ubik_Call() ubik_CallIter() or
ubik_Call_SingleServer().

Update the function prototypes and definitions for ubik_Call()
ubik_CallIter() and ubik_Call_SingleServer(), and add casts where
needed.

Define "UBIK_LEGACY_CALLITER" in ubik_db_if.c, so it can also use the
ubik_call_func typedef for its ubik_Call_SingleServer variant.

Remove the -Wno-strict-prototypes for the files that were updated. The
CFLAGS_NOSTRICT_PROTOTYPES autoconf var is now unused, so remove it.

Some minor whitespace/indentation cleanup.

Note: This problem occurred on Fedora 42 which comes with gcc 15.

Reviewed-on: https://gerrit.openafs.org/16370
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
(cherry picked from commit eddd5a060e9ed5acf10ee23359d54e22d4681592)

 Conflicts:   -- Due to differences between master and 1.8.x
	doc/process/compiler-warnings.md  - updated CODING instead
	src/cf/osconf.m4     - changes not applicable on 1.8.x

Change-Id: I75c40c3cc443a3b7c9039a248abed1a864746aae
---
 CODING                          |  5 -----
 src/bucoord/ubik_db_if.c        |  7 ++++---
 src/kauth/admin_tools.c         |  4 ++--
 src/kauth/authclient.c          |  8 ++++----
 src/libadmin/kas/afs_kasAdmin.c |  4 ++--
 src/ubik/ubik.p.h               | 13 ++++++++++---
 src/ubik/ubikclient.c           |  8 ++++----
 7 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/CODING b/CODING
index e89b691eb..53fa2fd38 100644
--- a/CODING
+++ b/CODING
@@ -332,7 +332,6 @@ afs/afs_syscall.c    : old-style
 		     : all (ukernel) : syscall pointer issues
 afsd/afsd_kernel.c   : deprecated    : daemon() marked as deprecated on Darwin
 bozo/bosserver.c     : deprecated    : daemon() marked as deprecated on Darwin
-bucoord/ubik_db_if.c : strict-proto  : ubik_Call_SingleServer
 bucoord/commands.c   : all	     : signed vs unsigned for dates
 external/heimdal/hcrypto/validate.c: all: statement with empty body
 external/heimdal/hcrypto/evp.c:      cast-function-type
@@ -341,13 +340,9 @@ external/heimdal/hcrypto/evp-algs.c: cast-function-type
              : Linux kernel build uses -Wcast-function-type
 external/heimdal/krb5/crypto.c: use-after-free : False postive on certain GCC
                                                  compilers
-kauth/admin_tools.c  : strict-proto  : ubik_Call
-kauth/authclient.c   : strict-proto  : ubik_Call nonsense
-libadmin/kas/afs_kasAdmin.c: strict-proto : ubik_Call nonsense
 libadmin/samples/rxstat_query_peer.c : all : util_RPCStatsStateGet types
 libadmin/samples/rxstat_query_process.c : all : util_RPCStatsStateGet types
 libadmin/test/client.c : all         : util_RPCStatsStateGet types
-ubik/ubikclient.c    : strict-protos : ubik_Call
 volser/vol-dump.c    : format        : afs_sfsize_t
 rxkad/ticket5.c      : format-truncation : inside included file v5der.c in the
                                        function _heim_time2generalizedtime, the
diff --git a/src/bucoord/ubik_db_if.c b/src/bucoord/ubik_db_if.c
index 9a0545941..85891dc25 100644
--- a/src/bucoord/ubik_db_if.c
+++ b/src/bucoord/ubik_db_if.c
@@ -21,6 +21,7 @@
 #include <afs/cmd.h>
 #include <afs/auth.h>
 #include <afs/cellconfig.h>
+#define UBIK_LEGACY_CALLITER 1
 #include <ubik.h>
 #include <afs/afsint.h>
 #include <afs/volser.h>
@@ -1001,7 +1002,7 @@ static struct ubikCallState uServer;
  */
 
 static afs_int32
-ubik_Call_SingleServer(int (*aproc) (), struct ubik_client *aclient,
+ubik_Call_SingleServer(ubik_call_func aproc, struct ubik_client *aclient,
 		       afs_int32 aflags, long p1, long p2, long p3,
 		       long p4, long p5, long p6, long p7, long p8,
 		       long p9, long p10, long p11, long p12, long p13,
@@ -1141,7 +1142,7 @@ ubik_Call_SingleServer_BUDB_GetVolumes(struct ubik_client *aclient,
 				       afs_int32 *dbUpdate,
 				       budb_volumeList *volumes)
 {
-    return ubik_Call_SingleServer(BUDB_GetVolumes, aclient, aflags,
+    return ubik_Call_SingleServer((ubik_call_func)BUDB_GetVolumes, aclient, aflags,
 				  (long)majorVersion, (long)flags, (long)name,
 				  (long)start, (long)end, (long)index,
 				  (long)nextIndex, (long)dbUpdate,
@@ -1154,7 +1155,7 @@ ubik_Call_SingleServer_BUDB_DumpDB(struct ubik_client *aclient,
 				   afs_int32 maxLength, charListT *charListPtr,
 				   afs_int32 *flags)
 {
-    return ubik_Call_SingleServer(BUDB_DumpDB, aclient, aflags, (long)firstcall,
+    return ubik_Call_SingleServer((ubik_call_func)BUDB_DumpDB, aclient, aflags, (long)firstcall,
 				  (long)maxLength, (long)charListPtr,
 				  (long)flags, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 				  0);
diff --git a/src/kauth/admin_tools.c b/src/kauth/admin_tools.c
index 769a9a9ac..bbdd74dfb 100644
--- a/src/kauth/admin_tools.c
+++ b/src/kauth/admin_tools.c
@@ -517,7 +517,7 @@ ka_islocked(char *name, char *instance, afs_uint32 * when)
     do {
 	tempwhen = 0;
 	code =
-	    ubik_CallIter(KAM_LockStatus, conn, UPUBIKONLY, &count, (long) name,
+	    ubik_CallIter((ubik_call_func)KAM_LockStatus, conn, UPUBIKONLY, &count, (long) name,
 			  (long) instance, (long) &tempwhen, 0, 0, 0,
 			  0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
 	if (code) {
@@ -554,7 +554,7 @@ Unlock(struct cmd_syndesc *as, void *arock)
 
     count = 0;
     do {
-	code = ubik_CallIter(KAM_Unlock, conn, 0, &count, (long) name, (long) instance,
+	code = ubik_CallIter((ubik_call_func)KAM_Unlock, conn, 0, &count, (long) name, (long) instance,
 			     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
 	if (code && (code != UNOSERVERS)) {
 	    server = 0;
diff --git a/src/kauth/authclient.c b/src/kauth/authclient.c
index c64f330ed..6b713ee13 100644
--- a/src/kauth/authclient.c
+++ b/src/kauth/authclient.c
@@ -425,9 +425,9 @@ CheckTicketAnswer(ka_BBS * oanswer, afs_int32 challenge,
  * this doesn't handle UNOTSYNC very well, should use ubik_Call if you care
  */
 static afs_int32
-kawrap_ubik_Call(int (*aproc) (), struct ubik_client *aclient,
-                 afs_int32 aflags, void *p1, void *p2, void *p3, void *p4,
-                 void *p5, void *p6, void *p7, void *p8)
+kawrap_ubik_Call(ubik_call_func aproc, struct ubik_client *aclient,
+		 afs_int32 aflags, void *p1, void *p2, void *p3, void *p4,
+		 void *p5, void *p6, void *p7, void *p8)
 {
     afs_int32 code, lcode;
     int count;
@@ -530,7 +530,7 @@ ka_Authenticate(char *name, char *instance, char *cell, struct ubik_client * con
 
     version = 2;
     code =
-	kawrap_ubik_Call(KAA_AuthenticateV2, conn, 0, name, instance,
+	kawrap_ubik_Call((ubik_call_func)KAA_AuthenticateV2, conn, 0, name, instance,
 			 (void*)(uintptr_t)start, (void*)(uintptr_t)end, &arequest, &oanswer, 0, 0);
     if (code == RXGEN_OPCODE) {
 	oanswer.SeqLen = 0;
diff --git a/src/libadmin/kas/afs_kasAdmin.c b/src/libadmin/kas/afs_kasAdmin.c
index 25a8c2851..546075ee2 100644
--- a/src/libadmin/kas/afs_kasAdmin.c
+++ b/src/libadmin/kas/afs_kasAdmin.c
@@ -713,7 +713,7 @@ GetPrincipalLockStatus(const kas_server_p kaserver, const kas_identity_p who,
     do {
 	locked = 0;
 	tst =
-	    ubik_CallIter(KAM_LockStatus, kaserver->servers, UPUBIKONLY,
+	    ubik_CallIter((ubik_call_func)KAM_LockStatus, kaserver->servers, UPUBIKONLY,
 			  &count, (long)who->principal, (long)who->instance, (long)&locked, 0,
 			  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
 	if (tst == 0) {
@@ -1272,7 +1272,7 @@ kas_PrincipalUnlock(const void *cellHandle, const void *serverHandle,
 
     do {
 	tst =
-	    ubik_CallIter(KAM_Unlock, kaserver.servers, 0, &count,
+	    ubik_CallIter((ubik_call_func)KAM_Unlock, kaserver.servers, 0, &count,
 			  (long)who->principal, (long)who->instance, 0, 0, 0,
 			  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
 	if (tst && (tst != UNOSERVERS)) {
diff --git a/src/ubik/ubik.p.h b/src/ubik/ubik.p.h
index 6567961df..60032884b 100644
--- a/src/ubik/ubik.p.h
+++ b/src/ubik/ubik.p.h
@@ -591,13 +591,20 @@ extern int ubik_ClientInit(struct rx_connection **serverconns,
 extern afs_int32 ubik_ClientDestroy(struct ubik_client *aclient);
 extern struct rx_connection *ubik_RefreshConn(struct rx_connection *tc);
 #ifdef UBIK_LEGACY_CALLITER
-extern afs_int32 ubik_CallIter(int (*aproc) (), struct ubik_client *aclient,
+typedef int (*ubik_call_func)(struct rx_connection *,
+		      long p1, long p2, long p3, long p4,
+		      long p5, long p6, long p7, long p8,
+		      long p9, long p10, long p11, long p12,
+		      long p13, long p14, long p15, long p16);
+extern afs_int32 ubik_CallIter(ubik_call_func aproc,
+			       struct ubik_client *aclient,
 			       afs_int32 aflags, int *apos, long p1, long p2,
 			       long p3, long p4, long p5, long p6, long p7,
 			       long p8, long p9, long p10, long p11, long p12,
 			       long p13, long p14, long p15, long p16);
-extern afs_int32 ubik_Call_New(int (*aproc) (), struct ubik_client
-			       *aclient, afs_int32 aflags, long p1, long p2,
+extern afs_int32 ubik_Call_New(ubik_call_func aproc,
+			       struct ubik_client *aclient,
+			       afs_int32 aflags, long p1, long p2,
 			       long p3, long p4, long p5, long p6, long p7,
 			       long p8, long p9, long p10, long p11, long p12,
 			       long p13, long p14, long p15, long p16);
diff --git a/src/ubik/ubikclient.c b/src/ubik/ubikclient.c
index 450b1531e..dd27fa2d2 100644
--- a/src/ubik/ubikclient.c
+++ b/src/ubik/ubikclient.c
@@ -411,7 +411,7 @@ try_GetSyncSite(struct ubik_client *aclient, afs_int32 apos)
  * been locked.
  */
 static afs_int32
-CallIter(int (*aproc) (), struct ubik_client *aclient,
+CallIter(ubik_call_func aproc, struct ubik_client *aclient,
 	 afs_int32 aflags, int *apos, long p1, long p2, long p3, long p4,
 	 long p5, long p6, long p7, long p8, long p9, long p10, long p11,
 	 long p12, long p13, long p14, long p15, long p16, int needlock)
@@ -474,7 +474,7 @@ errout:
  * \brief This is part of an iterator.  It doesn't handle finding sync sites.
  */
 afs_int32
-ubik_CallIter(int (*aproc) (), struct ubik_client *aclient,
+ubik_CallIter(ubik_call_func aproc, struct ubik_client *aclient,
 			       afs_int32 aflags, int *apos, long p1, long p2,
 			       long p3, long p4, long p5, long p6, long p7,
 			       long p8, long p9, long p10, long p11, long p12,
@@ -490,7 +490,7 @@ ubik_CallIter(int (*aproc) (), struct ubik_client *aclient,
  * \todo In the future, we should also put in a protocol to find the sync site.
  */
 afs_int32
-ubik_Call_New(int (*aproc) (), struct ubik_client *aclient,
+ubik_Call_New(ubik_call_func aproc, struct ubik_client *aclient,
 	      afs_int32 aflags, long p1, long p2, long p3, long p4, long p5,
 	      long p6, long p7, long p8, long p9, long p10, long p11,
 	      long p12, long p13, long p14, long p15, long p16)
@@ -551,7 +551,7 @@ ubik_Call_New(int (*aproc) (), struct ubik_client *aclient,
  * \todo In the future, we should also put in a protocol to find the sync site.
  */
 afs_int32
-ubik_Call(int (*aproc) (), struct ubik_client *aclient,
+ubik_Call(ubik_call_func aproc, struct ubik_client *aclient,
 	  afs_int32 aflags, long p1, long p2, long p3, long p4,
 	  long p5, long p6, long p7, long p8, long p9, long p10,
 	  long p11, long p12, long p13, long p14, long p15, long p16)
-- 
2.49.0