Skip to content

Commit

Permalink
move globals from headers and make static
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
samek-h committed Oct 25, 2020
1 parent 2193f50 commit 3f9ecf2
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions dpcmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions usbdriver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 0 additions & 3 deletions usbdriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
Expand Down

0 comments on commit 3f9ecf2

Please sign in to comment.