Skip to content

Commit

Permalink
Add -Wextra -Wno-unused-parameter compilation flags and fix a lot of
Browse files Browse the repository at this point in the history
issues.
  • Loading branch information
Matlo committed Oct 12, 2015
1 parent aa72a22 commit 77eeede
Show file tree
Hide file tree
Showing 40 changed files with 126 additions and 119 deletions.
8 changes: 4 additions & 4 deletions Makedefs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

LD = $(CXX)

CFLAGS += -Wall -s -O3
CXXFLAGS += -Wall -s -O3
CFLAGS += -Wall -Wextra -Wno-unused-parameter -s -O3
CXXFLAGS += -Wall -Wextra -Wno-unused-parameter -s -O3
#Comment the above two lines and uncomment the below two lines to compile with debug symbols.
#CFLAGS += -Wall -O0 -g
#CXXFLAGS += -Wall -O0 -g
#CFLAGS += -Wall -Wextra -Wno-unused-parameter -O0 -g
#CXXFLAGS += -Wall -Wextra -Wno-unused-parameter -O0 -g

ifeq ($(OS),Windows_NT)
CC = gcc
Expand Down
2 changes: 1 addition & 1 deletion config/configApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static const wxCmdLineEntryDesc g_cmdLineDesc [] =
{ wxCMD_LINE_OPTION, wxT("f"), _("file"), _("specifies a file to open"),
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },

{ wxCMD_LINE_NONE }
{ wxCMD_LINE_NONE, NULL, NULL, NULL, wxCMD_LINE_VAL_NONE, 0 }
};

#endif // CONFIGAPP_H
13 changes: 8 additions & 5 deletions core/adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ static int is_logitech_wheel(unsigned short vendor, unsigned short product) {
{
return 0;
}
int i;
unsigned int i;
for(i = 0; i < sizeof(lg_wheel_products) / sizeof(*lg_wheel_products); ++i)
{
if(lg_wheel_products[i] == product)
Expand Down Expand Up @@ -675,7 +675,8 @@ static int adapter_send_short_command(int device, unsigned char type)
}
};

if(serialasync_write_timeout(device, &packet.header, sizeof(packet.header), SERIAL_TIMEOUT) < sizeof(packet.header))
int ret = serialasync_write_timeout(device, &packet.header, sizeof(packet.header), SERIAL_TIMEOUT);
if(ret < 0 || (unsigned int)ret < sizeof(packet.header))
{
fprintf(stderr, "serial_send\n");
return -1;
Expand All @@ -687,13 +688,15 @@ static int adapter_send_short_command(int device, unsigned char type)
*/
while(1)
{
if(serialasync_read_timeout(device, &packet.header, sizeof(packet.header), SERIAL_TIMEOUT) < sizeof(packet.header))
ret = serialasync_read_timeout(device, &packet.header, sizeof(packet.header), SERIAL_TIMEOUT);
if(ret < 0 || (unsigned int)ret < sizeof(packet.header))
{
fprintf(stderr, "can't read packet header\n");
return -1;
}

if(serialasync_read_timeout(device, &packet.value, packet.header.length, SERIAL_TIMEOUT) < packet.header.length)
ret = serialasync_read_timeout(device, &packet.value, packet.header.length, SERIAL_TIMEOUT);
if(ret < 0 || (unsigned int)ret < packet.header.length)
{
fprintf(stderr, "can't read packet data\n");
return -1;
Expand Down Expand Up @@ -780,7 +783,7 @@ int adapter_detect()
{
adapter->ctype = rtype;
}
else if(adapter->ctype != rtype)
else if(adapter->ctype != (e_controller_type) rtype)
{
fprintf(stderr, _("Wrong controller type.\n"));
ret = -1;
Expand Down
2 changes: 1 addition & 1 deletion core/args.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static int read_ip(char* optarg, in_addr_t* ip, unsigned short* port)
*sep = ' ';//Temporarily separate the address and the port
*ip = inet_addr(optarg);//parse the IP
//parse the port
if(sscanf(sep + 1, "%hu%n", port, &pos) != 1 || pos != (len - (sep + 1 - optarg)))
if(sscanf(sep + 1, "%hu%n", port, &pos) != 1 || (unsigned int)pos != (len - (sep + 1 - optarg)))
{
ret = -1;
}
Expand Down
12 changes: 2 additions & 10 deletions core/calibration.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,26 +659,18 @@ void cal_button(int which, int button)
}
break;
case DZX:
if (mcal->dzx)
if (mcal->dzx && *mcal->dzx > 0)
{
*mcal->dzx -= 1;
if (*mcal->dzx < 0)
{
*mcal->dzx = 0;
}
mc->merge_x[mc->index] = -1;
mc->merge_y[mc->index] = 0;
mc->change = 1;
}
break;
case DZY:
if (mcal->dzy)
if (mcal->dzy && *mcal->dzy > 0)
{
*mcal->dzy -= 1;
if (*mcal->dzy < 0)
{
*mcal->dzy = 0;
}
mc->merge_x[mc->index] = 0;
mc->merge_y[mc->index] = -1;
mc->change = 1;
Expand Down
5 changes: 3 additions & 2 deletions core/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@ void cfg_process_motion_event(GE_Event* event)

void cfg_process_motion()
{
int i, j, k;
int i, k;
unsigned int j;
int weight;
int divider;
s_mouse_control* mc;
Expand Down Expand Up @@ -589,7 +590,7 @@ void cfg_trigger_init()

static inline s_event get_event(GE_Event * event)
{
s_event e = {};
s_event e = { 0, 0, 0 };

e.device_id = GE_GetDeviceId(event);

Expand Down
2 changes: 1 addition & 1 deletion core/connectors/bt_device_abs.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void bt_device_abs_register(e_bt_abs index, s_bt_device_abs * value)
void bt_device_abs_init(void) __attribute__((constructor (102)));
void bt_device_abs_init(void)
{
int index;
unsigned int index;
for(index = 0; index < sizeof(bt_device_abs) / sizeof(*bt_device_abs); ++index)
{
if(!bt_device_abs[index])
Expand Down
8 changes: 4 additions & 4 deletions core/connectors/btds4.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ static int ds4_interrupt_rumble(int joystick, unsigned short weak, unsigned shor

int ret = 0;

int i;
unsigned int i;
for(i = 0; i < sizeof(states)/sizeof(*states); ++i)
{
if(states[i].joystick_id == joystick)
Expand Down Expand Up @@ -680,7 +680,7 @@ static int listen_accept_sdp(int channel, bdaddr_t * src)
{
bdaddr_t cmp;

int i;
unsigned int i;
for(i=0; i<sizeof(states)/sizeof(*states); ++i)
{
/*
Expand Down Expand Up @@ -751,7 +751,7 @@ static int listen_accept_sdp(int channel, bdaddr_t * src)
static int listen_accept_control(int channel, bdaddr_t * src)
{
bdaddr_t cmp;
int i;
unsigned int i;
for(i=0; i<sizeof(states)/sizeof(*states); ++i)
{
/*
Expand Down Expand Up @@ -783,7 +783,7 @@ static int listen_accept_control(int channel, bdaddr_t * src)
static int listen_accept_interrupt(int channel, bdaddr_t * src)
{
bdaddr_t cmp;
int i;
unsigned int i;
for(i=0; i<sizeof(states)/sizeof(*states); ++i)
{
/*
Expand Down
4 changes: 2 additions & 2 deletions core/connectors/btstack/bt_device_btstack.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define ACL_MTU 1024
#define L2CAP_MTU 1024

static recv_data_t recv_data = {};
static recv_data_t recv_data = { {}, 0, 0 };

int bt_device_btstack_device_init()
{
Expand Down Expand Up @@ -51,7 +51,7 @@ int bt_device_btstack_get_device_bdaddr(int ignored, bdaddr_t* bdaddr)
{
if (COMMAND_COMPLETE_EVENT(packet, btstack_hci_read_bd_addr))
{
int i;
unsigned int i;
for(i=0; i<sizeof(bdaddr->b); ++i)
{
bdaddr->b[i] = packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE + 1 + i];
Expand Down
2 changes: 1 addition & 1 deletion core/connectors/btstack/btstack_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

static int btstack_fd = -1;

static recv_data_t recv_data = {};
static recv_data_t recv_data = { {}, 0, 0 };

static uint8_t hci_cmd_buffer[HCI_ACL_BUFFER_SIZE];

Expand Down
8 changes: 4 additions & 4 deletions core/connectors/btstack/l2cap_btstack.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static struct
{
unsigned int nb;
s_channel entries[L2CAP_ABS_MAX_PEERS*L2CAP_ABS_MAX_CHANNELS];
} channels = {};
} channels = { 0, { } };

typedef struct
{
Expand All @@ -60,7 +60,7 @@ static int l2cap_btstack_connect_channel(bdaddr_t event_addr, uint16_t psm, uint
{
int result = -1;

int channel;
unsigned int channel;
for(channel = 0; channel < channels.nb; ++channel)
{
if(!bacmp(&channels.entries[channel].ba, &event_addr) && channels.entries[channel].psm == psm)
Expand Down Expand Up @@ -89,7 +89,7 @@ static int l2cap_btstack_process_packet(uint16_t cid, unsigned char * packet, in
{
int result = -1;

int channel;
unsigned int channel;
for(channel = 0; channel < channels.nb; ++channel)
{
if(channels.entries[channel].cid == cid)
Expand All @@ -104,7 +104,7 @@ static int l2cap_btstack_process_packet(uint16_t cid, unsigned char * packet, in

static int packet_handler(int unused)
{
static recv_data_t recv_data = {};
static recv_data_t recv_data = { {}, 0, 0 };

bdaddr_t event_addr;
uint16_t psm = 0, cid, handle;
Expand Down
2 changes: 1 addition & 1 deletion core/connectors/l2cap_abs.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void l2cap_abs_register(e_bt_abs index, s_l2cap_abs * value)
void l2cap_abs_init(void) __attribute__((constructor (102)));
void l2cap_abs_init(void)
{
int index;
unsigned int index;
for(index = 0; index < sizeof(l2cap_abs) / sizeof(*l2cap_abs); ++index)
{
if(!l2cap_abs[index])
Expand Down
12 changes: 6 additions & 6 deletions core/connectors/linux/bluetooth/l2cap_bluez.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static struct
{
unsigned int nb;
s_channel channels[L2CAP_ABS_MAX_PEERS*L2CAP_ABS_MAX_CHANNELS];
} channels = {};
} channels = { 0, { } };

typedef struct
{
Expand All @@ -63,7 +63,7 @@ static struct
{
unsigned int nb;
s_listen_channel channels[L2CAP_ABS_MAX_CHANNELS];
} listen_channels = {};
} listen_channels = { 0, { } };

#if 0
static int l2cap_bluez_set_flush_timeout(int channel, int timeout_ms)
Expand Down Expand Up @@ -225,7 +225,7 @@ static int l2cap_bluez_acl_send_data (int channel, unsigned char *data, unsigned

static int l2cap_bluez_setsockopt(int fd, int link_mode)
{
struct l2cap_options l2o = {};
struct l2cap_options l2o = { 0 };
socklen_t len = sizeof(l2o);

int lm = 0;
Expand Down Expand Up @@ -280,7 +280,7 @@ static int l2cap_bluez_setsockopt(int fd, int link_mode)
static int l2cap_bluez_get_devid(bdaddr_t * ba_dst, int * devid)
{
*devid = hci_get_route(ba_dst);
if(devid < 0)
if(*devid < 0)
{
fprintf(stderr, "can't get device id for destination\n");
return -1;
Expand Down Expand Up @@ -312,7 +312,7 @@ static int l2cap_bluez_get_handle(int fd, uint16_t * handle)
{
int result = 0;

struct l2cap_conninfo l2ci = {};
struct l2cap_conninfo l2ci = { 0 };
socklen_t len = sizeof(l2ci);

if(getsockopt(fd, SOL_L2CAP, L2CAP_CONNINFO, &l2ci, &len) < 0)
Expand All @@ -332,7 +332,7 @@ static int l2cap_bluez_get_outgoing_mtu(int fd, uint16_t * omtu)
{
int result = 0;

struct l2cap_options l2o = {};
struct l2cap_options l2o = { 0 };
socklen_t len = sizeof(l2o);

if(getsockopt(fd, SOL_L2CAP, L2CAP_OPTIONS, &l2o, &len) < 0)
Expand Down
4 changes: 2 additions & 2 deletions core/connectors/linux/uhid/uhid_joystick.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static int is_logitech_wheel(unsigned short vendor, unsigned short product) {
if(vendor != USB_VENDOR_ID_LOGITECH) {
return 0;
}
int i;
unsigned int i;
for(i = 0; i < sizeof(lg_wheel_products) / sizeof(*lg_wheel_products); ++i) {
if(lg_wheel_products[i] == product) {
return 1;
Expand Down Expand Up @@ -155,7 +155,7 @@ static int set_evdev_correction(int uhid) {
{
if(pid == getpid() && id == uhid)
{
struct input_absinfo absinfo = {};
struct input_absinfo absinfo = { 0 };
if(ioctl(fd, EVIOCGABS(ABS_X), &absinfo) != -1)
{
absinfo.flat = 0;
Expand Down
2 changes: 1 addition & 1 deletion core/connectors/report2event/360Pad2event.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static inline void button2event(int (*callback)(GE_Event*), GE_Event* event, uns
void _360Pad2event(int adapter_id, s_report* current, s_report* previous,
int joystick_id, int (*callback)(GE_Event*))
{
GE_Event event = { .jbutton.which = joystick_id };
GE_Event event = { .jbutton = { .which = joystick_id } };

s_report_x360* x360_current = &current->x360;
s_report_x360* x360_previous = &previous->x360;
Expand Down
2 changes: 1 addition & 1 deletion core/connectors/report2event/ds42event.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static inline void button2event(int (*callback)(GE_Event*), GE_Event* event, uns
void ds42event(int adapter_id, s_report* current, s_report* previous,
int joystick_id, int (*callback)(GE_Event*))
{
GE_Event event = { .jbutton.which = joystick_id };
GE_Event event = { .jbutton = { .which = joystick_id } };

s_report_ds4* ds4_current = &current->ds4;
s_report_ds4* ds4_previous = &previous->ds4;
Expand Down
2 changes: 1 addition & 1 deletion core/connectors/report2event/xOnePad2event.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static inline void button2event(int (*callback)(GE_Event*), GE_Event* event, uns
void xOnePad2event(int adapter_id, s_report* current, s_report* previous,
int joystick_id, int (*callback)(GE_Event*))
{
GE_Event event = { .jbutton.which = joystick_id };
GE_Event event = { .jbutton = { .which = joystick_id } };

if(current->xone.input.type == XONE_USB_HID_IN_REPORT_ID)
{
Expand Down
4 changes: 2 additions & 2 deletions core/connectors/sixaxis.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ static void sixaxis_init(int sixaxis_number)
/* Main input report from Sixaxis -- assemble it */
static int assemble_input_01(uint8_t *buf, int maxlen, struct sixaxis_state *state)
{
if (maxlen < sizeof(s_report_ds3) - 1)
if ((unsigned int)maxlen < sizeof(s_report_ds3) - 1)
return -1;

memcpy(buf, ((uint8_t*) &state->user) + 1, sizeof(s_report_ds3) - 1);
Expand All @@ -138,7 +138,7 @@ static int assemble_input_01(uint8_t *buf, int maxlen, struct sixaxis_state *sta
/* Main input report from Sixaxis -- decode it */
static int process_input_01(const uint8_t *buf, int len, struct sixaxis_state *state)
{
if (len < sizeof(s_report_ds3))
if ((unsigned int) len < sizeof(s_report_ds3))
return -1;

memcpy(&state->user, buf, sizeof(s_report_ds3));
Expand Down
2 changes: 1 addition & 1 deletion core/connectors/usb_con.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ int usb_handle_events(int unused)
#else
if(ctx != NULL)
{
struct timeval tv = {};
struct timeval tv = { 0 };
return libusb_handle_events_timeout(ctx, &tv);
}
else
Expand Down
2 changes: 1 addition & 1 deletion core/ffb_logitech.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static struct {
};

static const char * get_ext_cmd_name(unsigned char ext) {
int i;
unsigned int i;
for (i = 0; i < sizeof(ext_cmd_names) / sizeof(*ext_cmd_names); ++i) {
if(ext_cmd_names[i].value == ext) {
return ext_cmd_names[i].name;
Expand Down
2 changes: 1 addition & 1 deletion core/gimx.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ int main(int argc, char *argv[])
#ifndef WIN32
int ffb = 0;
#endif
GE_Event kgevent = {.type = GE_KEYDOWN};
GE_Event kgevent = { .key = { .type = GE_KEYDOWN } };

(void) signal(SIGINT, terminate);
(void) signal(SIGTERM, terminate);
Expand Down
Loading

0 comments on commit 77eeede

Please sign in to comment.