From a8ce860b4462fbb22634c34a5d30cd0d482acb22 Mon Sep 17 00:00:00 2001
From: Lee Duncan <lduncan@suse.com>
Date: Tue, 28 Jan 2020 16:36:56 -0800
Subject: [PATCH] Updates to support gcc -fno-common option.

This meant cleaning up the definition of some
global variables, so that they were only defined
in one place and refered to as external elsewhere.
---
 include/iscsi_err.h    | 6 ++++--
 iscsiuio/configure     | 2 +-
 iscsiuio/configure.ac  | 2 +-
 iscsiuio/src/uip/uip.h | 4 ++--
 usr/iscsi_err.c        | 2 ++
 usr/log.c              | 1 +
 usr/log.h              | 2 +-
 7 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/include/iscsi_err.h b/include/iscsi_err.h
index 125f443a2f25..a08f0fbfcea6 100644
--- a/include/iscsi_err.h
+++ b/include/iscsi_err.h
@@ -4,7 +4,7 @@
 #ifndef _ISCSI_ERR_
 #define _ISCSI_ERR_
 
-enum {
+enum iscsi_error_list {
 	ISCSI_SUCCESS			= 0,
 	/* Generic error */
 	ISCSI_ERR			= 1,
@@ -69,7 +69,9 @@ enum {
 
 	/* Always last. Indicates end of error code space */
 	ISCSI_MAX_ERR_VAL,
-} iscsi_err;
+};
+
+extern enum iscsi_error_list iscsi_err;
 
 extern void iscsi_err_print_msg(int err);
 extern char *iscsi_err_to_str(int err);
diff --git a/iscsiuio/configure b/iscsiuio/configure
index 2740598f5f87..e799c377b4ab 100755
--- a/iscsiuio/configure
+++ b/iscsiuio/configure
@@ -22729,7 +22729,7 @@ echo "$as_me: error: cannot create directory $dirpart/$fdir" >&2;}
   done
 done
  ;;
-    default )  echo 'char *build_date = "'`date`'";' > src/unix/build_date.c  && echo 'char *build_date;'> src/unix/build_date.h ;;
+    default )  echo 'char *build_date = "'`date`'";' > src/unix/build_date.c  && echo 'extern char *build_date;'> src/unix/build_date.h ;;
   esac
 done
 _ACEOF
diff --git a/iscsiuio/configure.ac b/iscsiuio/configure.ac
index e9a5e32399ea..f51687bf56b5 100644
--- a/iscsiuio/configure.ac
+++ b/iscsiuio/configure.ac
@@ -62,7 +62,7 @@ AC_ARG_ENABLE(debug,
     fi])
 AM_CONDITIONAL([DEBUG], [test x$debug = xtrue])
 
-AC_CONFIG_COMMANDS([default],[[ echo 'char *build_date = "'`date`'";' > src/unix/build_date.c  && echo 'char *build_date;'> src/unix/build_date.h]],[[]])
+AC_CONFIG_COMMANDS([default],[[ echo 'char *build_date = "'`date`'";' > src/unix/build_date.c  && echo 'extern char *build_date;'> src/unix/build_date.h]],[[]])
 
 AC_PREFIX_DEFAULT()
 
diff --git a/iscsiuio/src/uip/uip.h b/iscsiuio/src/uip/uip.h
index 0225f6a456f5..d8e2220bf357 100644
--- a/iscsiuio/src/uip/uip.h
+++ b/iscsiuio/src/uip/uip.h
@@ -70,8 +70,8 @@ struct uip_stack;
 typedef u16_t uip_ip4addr_t[2];
 typedef u16_t uip_ip6addr_t[8];
 
-const uip_ip6addr_t all_zeroes_addr6;
-const uip_ip4addr_t all_zeroes_addr4;
+extern const uip_ip6addr_t all_zeroes_addr6;
+extern const uip_ip4addr_t all_zeroes_addr4;
 
 #define ETH_BUF(buf) ((struct uip_eth_hdr *)buf)
 #define VLAN_ETH_BUF(buf) ((struct uip_vlan_eth_hdr *)buf)
diff --git a/usr/iscsi_err.c b/usr/iscsi_err.c
index 4fe1c53adce0..6b6a4124458a 100644
--- a/usr/iscsi_err.c
+++ b/usr/iscsi_err.c
@@ -21,6 +21,8 @@
 #include "iscsi_err.h"
 #include "log.h"
 
+enum iscsi_error_list iscsi_err;
+
 static char *iscsi_err_msgs[] = {
 	/* 0 */ "",
 	/* 1 */ "unknown error",
diff --git a/usr/log.c b/usr/log.c
index 26c61d847793..f7c542eeb191 100644
--- a/usr/log.c
+++ b/usr/log.c
@@ -33,6 +33,7 @@
 
 char *log_name;
 int log_level = 0;
+struct logarea *la = NULL;
 
 static int log_stop_daemon = 0;
 static void (*log_func)(int prio, void *priv, const char *fmt, va_list ap);
diff --git a/usr/log.h b/usr/log.h
index 486a08ea08b2..c548791e73a1 100644
--- a/usr/log.h
+++ b/usr/log.h
@@ -64,7 +64,7 @@ struct logarea {
 	union semun semarg;
 };
 
-struct logarea *la;
+extern struct logarea *la;
 
 extern int log_init(char *program_name, int size,
 	void (*func)(int prio, void *priv, const char *fmt, va_list ap),
-- 
2.27.0

