From 2193f504a9484f5c0390e881ee552a12a8b1ff04 Mon Sep 17 00:00:00 2001 From: Jan Samek Date: Thu, 22 Oct 2020 19:28:00 +0200 Subject: [PATCH 1/2] Makefile: wokaround for GCC 10 - use -fcommon CFLAG As written in https://gcc.gnu.org/gcc-10/porting_to.html, GCC 10 now defaults to -fno-common compiler. This collides with the fact that variables in the headers are defined without extern. Hence the -fcommon flag in CFLAGS so the compilation works as before GCC 10. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3bc87eb..def5931 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ PROGRAM = dpcmd CC = gcc -CFLAGS = -O2 -Wall -lpthread -std=gnu99 +CFLAGS = -O2 -Wall -lpthread -std=gnu99 -fcommon PREFIX ?= /usr/local UNAME_OS := $(shell which lsb_release 2>/dev/null && lsb_release -si) From 3f9ecf207ea546f2cb74040a761f5e73d520690e Mon Sep 17 00:00:00 2001 From: Jan Samek Date: Sun, 25 Oct 2020 21:21:23 +0100 Subject: [PATCH 2/2] move globals from headers and make static Two global variables were declared as non-extern in the `usb_driver.h` header file which caused the linker to complain about multiple definiton errors when GCC 10+ was used. (See https://gcc.gnu.org/gcc-10/porting_to.html for details.) Instead of marking these variables extern, which was possible and worked, they were moved to the source files because they were only used in `usb_driver.c` where `usb_driver.h` was included. Three other variables in dpcmd.h causing the linker errors were removed because they were not used anywhere at all. --- Makefile | 2 +- dpcmd.h | 3 --- usbdriver.c | 3 +++ usbdriver.h | 3 --- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index def5931..3bc87eb 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ PROGRAM = dpcmd CC = gcc -CFLAGS = -O2 -Wall -lpthread -std=gnu99 -fcommon +CFLAGS = -O2 -Wall -lpthread -std=gnu99 PREFIX ?= /usr/local UNAME_OS := $(shell which lsb_release 2>/dev/null && lsb_release -si) diff --git a/dpcmd.h b/dpcmd.h index 745ed7f..7b0da1a 100644 --- a/dpcmd.h +++ b/dpcmd.h @@ -78,8 +78,5 @@ bool Wait(const char* strOK,const char* strFail); void ExitProgram(void); int FirmwareUpdate(); void sin_handler(int sig); -int ctrlCCount; -long int tvSec; -long int tvUsec; #endif diff --git a/usbdriver.c b/usbdriver.c index 69d0fe2..e1f6f9c 100644 --- a/usbdriver.c +++ b/usbdriver.c @@ -17,8 +17,11 @@ extern bool isSendFFsequence; #define SerialFlash_FALSE -1 #define SerialFlash_TRUE 1 +static int dev_index; +static usb_device_entry_t usb_device_entry[MAX_Dev_Index]; static usb_dev_handle *dediprog_handle[MAX_Dev_Index]; + bool Is_NewUSBCommand(int Index) { if(is_SF100nBoardVersionGreaterThan_5_5_0(Index) || is_SF600nBoardVersionGreaterThan_6_9_0(Index)) diff --git a/usbdriver.h b/usbdriver.h index 7131617..91f7a4a 100644 --- a/usbdriver.h +++ b/usbdriver.h @@ -44,8 +44,6 @@ typedef struct { unsigned long Length; } CNTRPIPE_RQ, *PCNTRPIPE_RQ; -usb_device_entry_t usb_device_entry[MAX_Dev_Index]; - /* Set/clear LEDs on dediprog */ #define PASS_ON (0 << 0) #define PASS_OFF (1 << 0) @@ -54,7 +52,6 @@ usb_device_entry_t usb_device_entry[MAX_Dev_Index]; #define ERROR_ON (0 << 2) #define ERROR_OFF (1 << 2) -int dev_index; int usb_driver_init(void); int get_usb_dev_cnt(void); int usb_driver_release(void);