Skip to contentSkip to conversation

Remove duplicate definitions in xfsprogs

PATCH In review Matthew Wilcox 2 participants 2 messages Mar 14, 2024 – Mar 17, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Remove duplicate definitions in xfsprogs

This is userspace. I have no idea what I'm doing.

Building on current Debian testing gives:

/usr/bin/ld: ../libxlog/.libs/libxlog.a(util.o):xfsprogs/libxlog/util.c:25: multiple definition of `x'; init.o:xfsprogs/db/init.c:42: first defined here

and

/usr/bin/ld: ../libxfs/.libs/libxfs.a(init.o):xfsprogs/libxfs/init.c:39: multiple definition of `progname'; xfs_mdrestore.o:xfsprogs/mdrestore/xfs_mdrestore.c:22: first defined here

It seems to me that xfsprogs was relying on the linker to merge duplicate definitions, and now the linker is declining to do so?

Feel free to split this up into individual patches, or whatever seems best ...

db/init.c +0 -1
index b108a06cfe..42757e44c6 100644
@@ -39,7 +39,6 @@ int			force;
 struct xfs_mount	xmount;
 struct xfs_mount	*mp;
 struct xlog		xlog;
-libxfs_init_t		x;
 xfs_agnumber_t		cur_agno = NULLAGNUMBER;
 
 static void
logprint/logprint.c +1 -1
index 37b8cb9116..a14ba185a5 100644
@@ -36,7 +36,6 @@ int	print_buffer;
 int	print_overwrite;
 int     print_no_data;
 int     print_no_print;
-int     print_exit = 1; /* -e is now default. specify -c to override */
 int	print_operation = OP_PRINT;
 
 void
@@ -146,6 +145,7 @@ main(int argc, char **argv)
 	memset(&mount, 0, sizeof(mount));
 
 	progname = basename(argv[0]);
+	print_exit = 1; /* -e is now default. specify -c to override */
 	while ((c = getopt(argc, argv, "bC:cdefl:iqnors:tDVv")) != EOF) {
 		switch (c) {
 			case 'D':
mdrestore/xfs_mdrestore.c +0 -1
index c9d4b0c149..90383f6744 100644
@@ -19,7 +19,6 @@
 #include "libxfs.h"
 #include "xfs_metadump.h"
 
-char 		*progname;
 int		show_progress = 0;
 int		show_info = 0;
 int		progress_since_warning = 0;
#1 lore raw
Quoted 1 line · Matthew Wilcox

This is userspace. I have no idea what I'm doing.

Heh.

db/init.c int force; · line 42

Quoted 9 lines
db/init.c +0 -1
index b108a06cfe..42757e44c6 100644
@@ -39,7 +39,6 @@ int			force;
 struct xfs_mount	xmount;
 struct xfs_mount	*mp;
 struct xlog		xlog;
-libxfs_init_t		x;

I did rework the libxfs_init structure (and remove this typedef) in xfsprogs for-next, which I think should have also fixed the duplicated declaration for "x".

The other fixups look ok to me. The global variables in libraries aren't exactly a nice pattern, but I think we'll have to live with them for now.