summarylogtreecommitdiffstats
path: root/0001-Avoid-duplicate-definitions-of-globals.patch
blob: a2f77c7e0ed34111dcebe408c997e1416e370c0d (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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
From ac4debb46bc0b95ff2f98d416703bc8df60b8415 Mon Sep 17 00:00:00 2001
From: Cheyenne Wills <cwills@sinenomine.net>
Date: Fri, 22 May 2020 12:16:48 -0600
Subject: [PATCH 1/5] Avoid duplicate definitions of globals

GCC 10 changed a default flag from -fcommon to -fno-common.  See
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85678 for some background.

The change in gcc 10 results in build link-time errors. For example:
   ../../src/xstat/.libs/liboafs_xstat_cm.a(xstat_cm.o):(.bss+0x2050):
       multiple definition of `numCollections';

Ensure that only one definition for global data objects exist and change
references to use "extern" as needed.

To ensure that future changes do not introduce duplicated global
definitions, add the -fno-common flag to XCFLAGS when using the
configure --enable-checking setting.

[cwills@sinenomine.net: Note for 1.8.x: renamed terminationEvent
to cm_terminationEvent/fs_terminationEvent instead of deleting it.]

Reviewed-on: https://gerrit.openafs.org/14106
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 0e2072ae386d4111bef161eb955964b649c31386)

Change-Id: I54ca61d372cf763e4a28c0b0829ea361219f6203
Reviewed-on: https://gerrit.openafs.org/14217
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
---
 src/bucoord/main.c        | 6 ++----
 src/butc/dbentries.c      | 2 +-
 src/butc/dump.c           | 7 +++----
 src/butc/lwps.c           | 2 +-
 src/butc/tcmain.c         | 2 +-
 src/cf/osconf.m4          | 2 +-
 src/fsprobe/fsprobe.h     | 1 -
 src/uss/uss_vol.c         | 2 +-
 src/viced/host.c          | 2 ++
 src/viced/host.h          | 2 +-
 src/vol/fssync-server.c   | 3 ---
 src/vol/volume.c          | 3 ---
 src/xstat/xstat_cm.c      | 7 +++----
 src/xstat/xstat_cm.h      | 3 +--
 src/xstat/xstat_cm_test.c | 4 ++--
 src/xstat/xstat_fs.c      | 7 +++----
 src/xstat/xstat_fs.h      | 3 +--
 src/xstat/xstat_fs_test.c | 4 ++--
 18 files changed, 25 insertions(+), 37 deletions(-)

diff --git a/src/bucoord/main.c b/src/bucoord/main.c
index d2a5f368b..a453cc9dd 100644
--- a/src/bucoord/main.c
+++ b/src/bucoord/main.c
@@ -47,9 +47,9 @@ char tcell[64];
 /*
  * Global configuration information for the Backup Coordinator.
  */
-struct bc_config *bc_globalConfig;	/*Ptr to global BC configuration info */
+extern struct bc_config *bc_globalConfig;	/*Ptr to global BC configuration info */
 
-struct ubik_client *cstruct;	/* Ptr to Ubik client structure */
+extern struct ubik_client *cstruct;	/* Ptr to Ubik client structure */
 time_t tokenExpires;		/* The token's expiration time */
 
 static const char *DefaultConfDir;	/*Default backup config directory */
@@ -162,8 +162,6 @@ bc_InitTextConfig(void)
     udbClientTextP ctPtr;
     int i;
 
-    extern struct bc_config *bc_globalConfig;
-
     mkdir(DefaultConfDir, 777);	/* temporary */
 
     /* initialize the client text structures */
diff --git a/src/butc/dbentries.c b/src/butc/dbentries.c
index 37b35d307..29ddcbd01 100644
--- a/src/butc/dbentries.c
+++ b/src/butc/dbentries.c
@@ -31,7 +31,7 @@
 #include "error_macros.h"
 
 dlqlinkT savedEntries;
-dlqlinkT entries_to_flush;
+static dlqlinkT entries_to_flush;
 
 int dbWatcherinprogress;
 
diff --git a/src/butc/dump.c b/src/butc/dump.c
index 1f4eb9b8f..f8fc943a6 100644
--- a/src/butc/dump.c
+++ b/src/butc/dump.c
@@ -42,8 +42,7 @@ extern int isafile;
 extern int forcemultiple;
 
 extern struct ubik_client *cstruct;
-dlqlinkT savedEntries;
-dlqlinkT entries_to_flush;
+extern dlqlinkT savedEntries;
 
 extern afs_int32 groupId;
 extern afs_int32 BufferSize;
@@ -61,8 +60,8 @@ extern char *xbsalGName;
 extern char *globalButcLog;
 #endif /*xbsa */
 
-afs_int32 dataSize;		/* Size of data to read on each rx_Read() call */
-afs_int32 tapeblocks;		/* Number of 16K tape datablocks in buffer (!CONF_XBSA) */
+extern afs_int32 dataSize;		/* Size of data to read on each rx_Read() call */
+extern afs_int32 tapeblocks;		/* Number of 16K tape datablocks in buffer (!CONF_XBSA) */
 
 /* TBD
  *
diff --git a/src/butc/lwps.c b/src/butc/lwps.c
index d262991d8..aff5e9e07 100644
--- a/src/butc/lwps.c
+++ b/src/butc/lwps.c
@@ -51,7 +51,7 @@ extern int forcemultiple;
 #endif
 
 /* XBSA Global Parameters */
-afs_int32 xbsaType;
+extern afs_int32 xbsaType;
 #ifdef xbsa
 struct butx_transactionInfo butxInfo;
 #endif
diff --git a/src/butc/tcmain.c b/src/butc/tcmain.c
index e8a20938e..a0298addb 100644
--- a/src/butc/tcmain.c
+++ b/src/butc/tcmain.c
@@ -66,7 +66,7 @@
 #define TL_PREFIX  "TL"
 #define CFG_PREFIX "CFG"
 
-struct ubik_client *cstruct;
+extern struct ubik_client *cstruct;
 FILE *logIO, *ErrorlogIO, *centralLogIO, *lastLogIO;
 char lFile[AFSDIR_PATH_MAX];
 char logFile[AFSDIR_PATH_MAX + 256];
diff --git a/src/cf/osconf.m4 b/src/cf/osconf.m4
index 5f0d73fc2..e36152bd4 100644
--- a/src/cf/osconf.m4
+++ b/src/cf/osconf.m4
@@ -672,7 +672,7 @@ if test "x$GCC" = "xyes"; then
     XCFLAGS="${XCFLAGS} -Wall -Wstrict-prototypes -Wold-style-definition -Wpointer-arith"
   fi
   if test "x$enable_checking" != "xno"; then
-    XCFLAGS="${XCFLAGS} -Wall -Wstrict-prototypes -Wold-style-definition -Werror -fdiagnostics-show-option -Wpointer-arith"
+    XCFLAGS="${XCFLAGS} -Wall -Wstrict-prototypes -Wold-style-definition -Werror -fdiagnostics-show-option -Wpointer-arith -fno-common"
     if test "x$enable_checking" != "xall"; then
       CFLAGS_NOERROR="-Wno-error"
       CFLAGS_NOUNUSED="-Wno-unused"
diff --git a/src/fsprobe/fsprobe.h b/src/fsprobe/fsprobe.h
index 94083bfe9..3060371ae 100644
--- a/src/fsprobe/fsprobe.h
+++ b/src/fsprobe/fsprobe.h
@@ -103,7 +103,6 @@ struct fsprobe_ProbeResults {
 
 extern int fsprobe_numServers;	/*# servers connected */
 extern struct fsprobe_ConnectionInfo *fsprobe_ConnInfo;	/*Ptr to connections */
-extern int numCollections;	/*Num data collections */
 extern struct fsprobe_ProbeResults fsprobe_Results;	/*Latest probe results */
 
 extern int fsprobe_Init(int, struct sockaddr_in *, int, int (*)(void), int );
diff --git a/src/uss/uss_vol.c b/src/uss/uss_vol.c
index c9c13941d..b31a42a06 100644
--- a/src/uss/uss_vol.c
+++ b/src/uss/uss_vol.c
@@ -61,7 +61,7 @@ extern int line;
  * will work and we can avoid nasty little core dumps.
  */
 struct ubik_client *uconn_vldbP;	/*Ubik connection struct */
-struct ubik_client *cstruct;	/*Required name for above */
+extern struct ubik_client *cstruct;	/*Required name for above */
 
 /*
  * ------------------------ Private globals -----------------------
diff --git a/src/viced/host.c b/src/viced/host.c
index 36f9e88c0..e7657caac 100644
--- a/src/viced/host.c
+++ b/src/viced/host.c
@@ -67,6 +67,8 @@ int hostCount = 0;		/* number of hosts in hostList */
 int rxcon_ident_key;
 int rxcon_client_key;
 
+struct host *(hosttableptrs[h_MAXHOSTTABLES]);
+
 static struct rx_securityClass *sc = NULL;
 static int h_quota_limit;
 
diff --git a/src/viced/host.h b/src/viced/host.h
index fead948f6..272dcdbe7 100644
--- a/src/viced/host.h
+++ b/src/viced/host.h
@@ -254,7 +254,7 @@ extern int h_RestoreState(void);
 #define H_ENUMERATE_BAIL(flags)        ((flags)|0x80000000)
 #define H_ENUMERATE_ISSET_BAIL(flags)  ((flags)&0x80000000)
 
-struct host *(hosttableptrs[h_MAXHOSTTABLES]);	/* Used by h_itoh */
+extern struct host *(hosttableptrs[h_MAXHOSTTABLES]);	/* Used by h_itoh */
 #define h_htoi(host) ((host)->index)	/* index isn't zeroed, no need to lock */
 #define h_itoh(hostindex) (hosttableptrs[(hostindex)>>h_HTSHIFT]+((hostindex)&(h_HTSPERBLOCK-1)))
 
diff --git a/src/vol/fssync-server.c b/src/vol/fssync-server.c
index 2d7cd6011..69d902f1b 100644
--- a/src/vol/fssync-server.c
+++ b/src/vol/fssync-server.c
@@ -79,9 +79,6 @@
 #endif /* USE_UNIX_SOCKETS */
 
 #ifdef FSSYNC_BUILD_SERVER
-
-int (*V_BreakVolumeCallbacks) (VolumeId volume);
-
 #define MAXHANDLERS	4	/* Up to 4 clients; must be at least 2, so that
 				 * move = dump+restore can run on single server */
 #define MAXOFFLINEVOLUMES 128	/* This needs to be as big as the maximum
diff --git a/src/vol/volume.c b/src/vol/volume.c
index f1ff10a7b..3d9e47ef3 100644
--- a/src/vol/volume.c
+++ b/src/vol/volume.c
@@ -124,9 +124,6 @@ pthread_cond_t vol_vinit_cond;
 int vol_attach_threads = 1;
 #endif /* AFS_PTHREAD_ENV */
 
-/* start-time configurable I/O parameters */
-ih_init_params vol_io_params;
-
 #ifdef AFS_DEMAND_ATTACH_FS
 pthread_mutex_t vol_salvsync_mutex;
 
diff --git a/src/xstat/xstat_cm.c b/src/xstat/xstat_cm.c
index d8600c124..3f5bfc843 100644
--- a/src/xstat/xstat_cm.c
+++ b/src/xstat/xstat_cm.c
@@ -32,9 +32,8 @@
 int xstat_cm_numServers;	/*Num connected servers */
 struct xstat_cm_ConnectionInfo
  *xstat_cm_ConnInfo;		/*Ptr to connection array */
-int numCollections;		/*Number of data collections */
 struct xstat_cm_ProbeResults xstat_cm_Results;	/*Latest probe results */
-char terminationEvent;		/*One-shot termination event */
+char cm_terminationEvent;		/*One-shot termination event */
 
 afs_int32 xstat_cmData[AFSCB_MAX_XSTAT_LONGS];	/*Buffer for collected data */
 
@@ -315,8 +314,8 @@ xstat_cm_LWP(void *unused)
 	     */
 	    if (xstat_cm_debug)
 		printf("[%s] Signalling main process at %" AFS_PTR_FMT "\n", rn,
-		       &terminationEvent);
-	    oneShotCode = LWP_SignalProcess(&terminationEvent);
+		       &cm_terminationEvent);
+	    oneShotCode = LWP_SignalProcess(&cm_terminationEvent);
 	    if (oneShotCode)
 		fprintf(stderr, "[%s] Error %d from LWP_SignalProcess()", rn,
 			oneShotCode);
diff --git a/src/xstat/xstat_cm.h b/src/xstat/xstat_cm.h
index efbba531c..569011cc2 100644
--- a/src/xstat/xstat_cm.h
+++ b/src/xstat/xstat_cm.h
@@ -86,10 +86,9 @@ struct xstat_cm_ProbeResults {
 extern int xstat_cm_numServers;	/*# connected servers */
 extern struct xstat_cm_ConnectionInfo
  *xstat_cm_ConnInfo;		/*Ptr to connections */
-extern int numCollections;	/*Num data collections */
 extern struct xstat_cm_ProbeResults
   xstat_cm_Results;		/*Latest probe results */
-extern char terminationEvent;	/*One-shot termination event */
+extern char cm_terminationEvent;	/*One-shot termination event */
 
 /*
  * ------------------------ Exported functions ------------------------
diff --git a/src/xstat/xstat_cm_test.c b/src/xstat/xstat_cm_test.c
index b284237aa..7c5e56864 100644
--- a/src/xstat/xstat_cm_test.c
+++ b/src/xstat/xstat_cm_test.c
@@ -881,8 +881,8 @@ RunTheTest(struct cmd_syndesc *a_s, void *arock)
 	 */
 	if (debugging_on)
 	    printf("[%s] Calling LWP_WaitProcess() on event %" AFS_PTR_FMT
-		   "\n", rn, &terminationEvent);
-	waitCode = LWP_WaitProcess(&terminationEvent);
+		   "\n", rn, &cm_terminationEvent);
+	waitCode = LWP_WaitProcess(&cm_terminationEvent);
 	if (debugging_on)
 	    printf("[%s] Returned from LWP_WaitProcess()\n", rn);
 	if (waitCode) {
diff --git a/src/xstat/xstat_fs.c b/src/xstat/xstat_fs.c
index 51dbe3847..dff930472 100644
--- a/src/xstat/xstat_fs.c
+++ b/src/xstat/xstat_fs.c
@@ -33,9 +33,8 @@
 int xstat_fs_numServers;	/*Num connected servers */
 struct xstat_fs_ConnectionInfo
  *xstat_fs_ConnInfo;		/*Ptr to connection array */
-int numCollections;		/*Number of data collections */
 struct xstat_fs_ProbeResults xstat_fs_Results;	/*Latest probe results */
-char terminationEvent;		/*One-shot termination event */
+char fs_terminationEvent;		/*One-shot termination event */
 
 afs_int32 xstat_fsData[AFS_MAX_XSTAT_LONGS];	/*Buffer for collected data */
 
@@ -334,8 +333,8 @@ xstat_fs_LWP(void *unused)
 	     */
 	    if (xstat_fs_debug)
 		printf("[%s] Signalling main process at %" AFS_PTR_FMT "\n", rn,
-		       &terminationEvent);
-	    oneShotCode = LWP_SignalProcess(&terminationEvent);
+		       &fs_terminationEvent);
+	    oneShotCode = LWP_SignalProcess(&fs_terminationEvent);
 	    if (oneShotCode)
 		fprintf(stderr, "[%s] Error %d from LWP_SignalProcess()", rn,
 			oneShotCode);
diff --git a/src/xstat/xstat_fs.h b/src/xstat/xstat_fs.h
index 6e2b77b85..a800ba679 100644
--- a/src/xstat/xstat_fs.h
+++ b/src/xstat/xstat_fs.h
@@ -87,10 +87,9 @@ struct xstat_fs_ProbeResults {
 extern int xstat_fs_numServers;	/*# connected servers */
 extern struct xstat_fs_ConnectionInfo
  *xstat_fs_ConnInfo;		/*Ptr to connections */
-extern int numCollections;	/*Num data collections */
 extern struct xstat_fs_ProbeResults
   xstat_fs_Results;		/*Latest probe results */
-extern char terminationEvent;	/*One-shot termination event */
+extern char fs_terminationEvent;	/*One-shot termination event */
 
 /*
  * ------------------------ Exported functions ------------------------
diff --git a/src/xstat/xstat_fs_test.c b/src/xstat/xstat_fs_test.c
index 853c2121e..d58ecf014 100644
--- a/src/xstat/xstat_fs_test.c
+++ b/src/xstat/xstat_fs_test.c
@@ -778,8 +778,8 @@ RunTheTest(struct cmd_syndesc *a_s, void *dummy)
 	 */
 	if (debugging_on)
 	    printf("[%s] Calling LWP_WaitProcess() on event %" AFS_PTR_FMT "\n", rn,
-		   &terminationEvent);
-	waitCode = LWP_WaitProcess(&terminationEvent);
+		   &fs_terminationEvent);
+	waitCode = LWP_WaitProcess(&fs_terminationEvent);
 	if (debugging_on)
 	    printf("[%s] Returned from LWP_WaitProcess()\n", rn);
 	if (waitCode) {
-- 
2.30.0