Control: tag -1 patch

On Fri, 2020-04-17 at 11:10:50 +0000, Matthias Klose wrote:
> Package: src:sipsak
> Version: 0.9.7-1
> Severity: normal
> Tags: sid bullseye
> User: debian-...@lists.debian.org
> Usertags: ftbfs-gcc-10

> [...]
> /usr/bin/ld: src/sipsak.o:./src/sipsak.h:327: multiple definition of 
> `cseq_counter'; src/transport.o:./src/sipsak.h:327: first defined here
> /usr/bin/ld: src/exit_code.o:./src/sipsak.h:332: multiple definition of 
> `sysl'; src/transport.o:./src/sipsak.h:332: first defined here
> /usr/bin/ld: src/exit_code.o:./src/sipsak.h:326: multiple definition of 
> `transport'; src/transport.o:./src/sipsak.h:326: first defined here
> /usr/bin/ld: src/exit_code.o:./src/sipsak.h:313: multiple definition of 
> `tls_session'; src/transport.o:./src/sipsak.h:313: first defined here
[…]
> collect2: error: ld returned 1 exit status
> make[1]: *** [Makefile:676: sipsak] Error 1
> make[1]: Leaving directory '/<<PKGBUILDDIR>>'
> make: *** [debian/rules:41: build-arch] Error 2
> dpkg-buildpackage: error: debian/rules build subprocess returned exit status 2

I've fixed this with the attached patch.

Thanks,
Guillem
Author: Guillem Jover <gjo...@sipwise.com>
Description: Fix global variables declarations and definitions
 The global variables were not declared as extern, so each time the header
 was getting included it would define a new instance. Declare them as extern
 in the header, and define them in the files that use them, also shared by
 the test cases.

---
 src/exit_code.c |    9 +++++++++
 src/helper.c    |    8 ++++++++
 src/shoot.c     |    2 ++
 src/shoot.h     |    2 +-
 src/sipsak.c    |   28 ++++++++++++++++++++++++++++
 src/sipsak.h    |   40 ++++++++++++++++++++--------------------
 6 files changed, 68 insertions(+), 21 deletions(-)

--- a/src/sipsak.h
+++ b/src/sipsak.h
@@ -307,34 +307,34 @@
 #define SIPSAK_HASHHEXLEN 2 * SIPSAK_HASHLEN
 
 #ifdef WITH_TLS_TRANSP
-char *cert_file, *ca_file;
-int ignore_ca_fail;
+extern char *cert_file, *ca_file;
+extern int ignore_ca_fail;
 # ifdef USE_GNUTLS
-gnutls_session_t tls_session;
+extern gnutls_session_t tls_session;
 //gnutls_anon_client_credentials_t anoncred;
-gnutls_certificate_credentials_t xcred;
+extern gnutls_certificate_credentials_t xcred;
 # else
 #  ifdef USE_OPENSSL
-SSL_CTX* ctx;
-SSL* ssl;
+extern SSL_CTX* ctx;
+extern SSL* ssl;
 #  endif
 # endif
 #endif
 
 /* lots of global variables. ugly but makes life easier. */
-unsigned long address;
-unsigned int nonce_count, transport;
-int sleep_ms, processes, cseq_counter;
-int verbose, nameend, namebeg, expires_t, flood, warning_ext, invite, message;
-int maxforw, lport, rport, randtrash, trashchar, numeric, symmetric;
-int file_b, uri_b, trace, via_ins, usrloc, redirects, rand_rem, replace_b;
-int empty_contact, nagios_warn, fix_crlf, timing, outbound_proxy;
-int timer_t1, timer_t2, timer_final, sysl;
-char *username, *domainname, *password, *replace_str, *hostname, *contact_uri;
-char *mes_body, *con_dis, *auth_username, *from_uri, *headers, *authhash, *local_ip;
-char fqdn[FQDN_SIZE];
-char target_dot[INET_ADDRSTRLEN], source_dot[INET_ADDRSTRLEN];
-char *request, *response, *received, *transport_str;
-regex_t* regex;
+extern unsigned long address;
+extern unsigned int nonce_count, transport;
+extern int sleep_ms, processes, cseq_counter;
+extern int verbose, nameend, namebeg, expires_t, flood, warning_ext, invite, message;
+extern int maxforw, lport, rport, randtrash, trashchar, numeric, symmetric;
+extern int file_b, uri_b, trace, via_ins, usrloc, redirects, rand_rem, replace_b;
+extern int empty_contact, nagios_warn, fix_crlf, timing, outbound_proxy;
+extern int timer_t1, timer_t2, timer_final, sysl;
+extern char *username, *domainname, *password, *replace_str, *hostname, *contact_uri;
+extern char *mes_body, *con_dis, *auth_username, *from_uri, *headers, *authhash, *local_ip;
+extern char fqdn[FQDN_SIZE];
+extern char target_dot[INET_ADDRSTRLEN], source_dot[INET_ADDRSTRLEN];
+extern char *request, *response, *received, *transport_str;
+extern regex_t* regex;
 
 #endif
--- a/src/sipsak.c
+++ b/src/sipsak.c
@@ -61,6 +61,34 @@
 #include "shoot.h"
 #include "exit_code.h"
 
+/* Define the global variables. */
+#ifdef WITH_TLS_TRANSP
+char *cert_file, *ca_file;
+int ignore_ca_fail;
+# ifdef USE_GNUTLS
+//gnutls_anon_client_credentials_t anoncred;
+# else
+#  ifdef USE_OPENSSL
+SSL_CTX* ctx;
+SSL* ssl;
+#  endif
+# endif
+#endif
+
+unsigned long address;
+unsigned int nonce_count;
+int sleep_ms, processes, cseq_counter;
+int nameend, namebeg, expires_t, flood, warning_ext, invite, message;
+int maxforw, lport, rport, randtrash, trashchar, symmetric;
+int file_b, uri_b, trace, via_ins, usrloc, redirects, rand_rem, replace_b;
+int empty_contact, nagios_warn, fix_crlf, timing, outbound_proxy;
+int timer_t1, timer_t2, timer_final;
+char *username, *domainname, *password, *contact_uri;
+char *mes_body, *con_dis, *auth_username, *from_uri, *headers, *authhash, *local_ip;
+char target_dot[INET_ADDRSTRLEN], source_dot[INET_ADDRSTRLEN];
+char *response, *received, *transport_str;
+regex_t* regex;
+
 static void sigchld_handler(int signo)
 {
 	int chld_status;
--- a/src/shoot.c
+++ b/src/shoot.c
@@ -54,6 +54,8 @@
 #define DEFAULT_TIMEOUT 5000
 #endif
 
+int inv_trans;
+
 char *usern;
 
 enum usteps usrlocstep;
--- a/src/shoot.h
+++ b/src/shoot.h
@@ -44,7 +44,7 @@ enum usteps {
 	UNREG_REP
 };
 
-int inv_trans;
+extern int inv_trans;
 
 void shoot(char *buff, int buff_size);
 
--- a/src/exit_code.c
+++ b/src/exit_code.c
@@ -33,6 +33,15 @@
 
 #include "exit_code.h"
 
+#ifdef WITH_TLS_TRANSP
+# ifdef USE_GNUTLS
+gnutls_session_t tls_session;
+gnutls_certificate_credentials_t xcred;
+# endif
+#endif
+
+unsigned int transport;
+int sysl;
 enum exit_modes exit_mode = EM_DEFAULT;
 
 void log_message(const char *message) {
--- a/src/helper.c
+++ b/src/helper.c
@@ -63,6 +63,14 @@
 
 #endif // HAVE_CARES_H
 
+int verbose;
+int numeric;
+
+char fqdn[FQDN_SIZE];
+char *hostname;
+char *request;
+char *replace_str;
+
 #include "helper.h"
 #include "exit_code.h"
 

Reply via email to