Skip to content

Commit d4728b7

Browse files
author
James
committed
fix issue #127 and migrate functions to stricter prototype standards
1 parent c303094 commit d4728b7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+337
-295
lines changed

library/Makefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ CC := gcc
1919
LINKER := gcc
2020

2121
# general compiler flags
22-
WFLAGS := -Wall -Wextra -Werror=float-equal -Wuninitialized -Wunused-variable -Wdouble-promotion
22+
WFLAGS := -Wall -Wextra -Werror=float-equal -Wuninitialized \
23+
-Wunused-variable -Wdouble-promotion -pedantic -Wmissing-prototypes \
24+
-Wmissing-declarations -Werror=undef
2325
CFLAGS := -g -fPIC -I $(INCLUDEDIR)
2426
OPT_FLAGS := -O1
2527
LDFLAGS := -lm -lrt -pthread -shared -Wl,-soname,$(SONAME)

library/include/rc/adc.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extern "C" {
4343
*
4444
* @return 0 on success, -1 on failure.
4545
*/
46-
int rc_adc_init();
46+
int rc_adc_init(void);
4747

4848
/**
4949
* @brief Cleans up the ADC subsystem.
@@ -52,7 +52,7 @@ int rc_adc_init();
5252
*
5353
* @return 0 on success, -1 on failure.
5454
*/
55-
int rc_adc_cleanup();
55+
int rc_adc_cleanup(void);
5656

5757
/**
5858
* @brief reads the raw integer ADC value for a particular channel
@@ -77,14 +77,14 @@ double rc_adc_read_volt(int ch);
7777
*
7878
* @return voltage of battery or -1 on failure
7979
*/
80-
double rc_adc_batt();
80+
double rc_adc_batt(void);
8181

8282
/**
8383
* @brief Reads the voltage of the 9-18v DC jack
8484
*
8585
* @return Voltage at DC jack or -1 on failure
8686
*/
87-
double rc_adc_dc_jack();
87+
double rc_adc_dc_jack(void);
8888

8989

9090

library/include/rc/bmp.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ int rc_bmp_set_sea_level_pressure_pa(double pa);
9595
*
9696
* @return 0 on success, -1 on failure
9797
*/
98-
int rc_bmp_power_off();
98+
int rc_bmp_power_off(void);
9999

100100

101101
/**
@@ -116,4 +116,4 @@ int rc_bmp_read(rc_bmp_data_t* data);
116116

117117
#endif // RC_BMP_H
118118

119-
/** @} end group Barometer */
119+
/** @} end group Barometer */

library/include/rc/button.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ int rc_button_init(int chip, int pin, char polarity, int debounce_us);
5555
* @brief Closes all button handlers. Call at the end of your program
5656
* before returning.
5757
*/
58-
void rc_button_cleanup();
58+
void rc_button_cleanup(void);
5959

6060

6161
/**

library/include/rc/cpu.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ int rc_cpu_set_governor(rc_governor_t gov);
5353
*
5454
* @return frequency in hz
5555
*/
56-
int rc_cpu_get_freq();
56+
int rc_cpu_get_freq(void);
5757

5858
/**
5959
* @brief Prints the current frequency to the screen. For example "600mhz".
6060
*
6161
* @return 0 on success or -1 on failure.
6262
*/
63-
int rc_cpu_print_freq();
63+
int rc_cpu_print_freq(void);
6464

6565

6666

library/include/rc/deprecated.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ extern "C" {
2020

2121

2222

23-
int rc_initialize() __attribute__ ((deprecated));
23+
int rc_initialize(void) __attribute__ ((deprecated));
2424

25-
int rc_cleanup() __attribute__ ((deprecated));
25+
int rc_cleanup(void) __attribute__ ((deprecated));
2626

2727
typedef enum rc_button_state_t {
2828
RELEASED,
@@ -33,21 +33,21 @@ int rc_set_pause_pressed_func(void (*func)(void)) __attribute__ ((deprecated));
3333
int rc_set_pause_released_func(void (*func)(void)) __attribute__ ((deprecated));
3434
int rc_set_mode_pressed_func(void (*func)(void)) __attribute__ ((deprecated));
3535
int rc_set_mode_released_func(void (*func)(void)) __attribute__ ((deprecated));
36-
rc_button_state_t rc_get_pause_button() __attribute__ ((deprecated));
37-
rc_button_state_t rc_get_mode_button() __attribute__ ((deprecated));
36+
rc_button_state_t rc_get_pause_button(void) __attribute__ ((deprecated));
37+
rc_button_state_t rc_get_mode_button(void) __attribute__ ((deprecated));
3838

3939

4040
int rc_get_encoder_pos(int ch) __attribute__ ((deprecated));
4141
int rc_set_encoder_pos(int ch, int value) __attribute__ ((deprecated));
4242

43-
int rc_enable_motors() __attribute__ ((deprecated));
44-
int rc_disable_motors() __attribute__ ((deprecated));
43+
int rc_enable_motors(void) __attribute__ ((deprecated));
44+
int rc_disable_motors(void) __attribute__ ((deprecated));
4545
int rc_set_motor(int motor, float duty) __attribute__ ((deprecated));
4646
int rc_set_motor_all(float duty) __attribute__ ((deprecated));
4747
int rc_set_motor_free_spin(int motor) __attribute__ ((deprecated));
48-
int rc_set_motor_free_spin_all() __attribute__ ((deprecated));
48+
int rc_set_motor_free_spin_all(void) __attribute__ ((deprecated));
4949
int rc_set_motor_brake(int motor) __attribute__ ((deprecated));
50-
int rc_set_motor_brake_all() __attribute__ ((deprecated));
50+
int rc_set_motor_brake_all(void) __attribute__ ((deprecated));
5151

5252

5353

library/include/rc/dsm.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extern "C" {
3939
*
4040
* @return 0 on success, -1 on failure
4141
*/
42-
int rc_dsm_init();
42+
int rc_dsm_init(void);
4343

4444

4545
/**
@@ -48,7 +48,7 @@ int rc_dsm_init();
4848
* @return 0 on success, -1 on failure. 1 if there was a timeout due to user
4949
* callback function not returning.
5050
*/
51-
int rc_dsm_cleanup();
51+
int rc_dsm_cleanup(void);
5252

5353

5454
/**
@@ -94,7 +94,7 @@ double rc_dsm_ch_normalized(int ch);
9494
* @return returns 1 if new data is ready to be read by the user. otherwise
9595
* returns 0
9696
*/
97-
int rc_dsm_is_new_data();
97+
int rc_dsm_is_new_data(void);
9898

9999

100100
/**
@@ -122,7 +122,7 @@ void rc_dsm_set_disconnect_callback(void (*func)(void));
122122
* @return returns 1 if packets are arriving in good health without
123123
* timeouts. returns 0 otherwise.
124124
*/
125-
int rc_dsm_is_connection_active();
125+
int rc_dsm_is_connection_active(void);
126126

127127

128128
/**
@@ -131,7 +131,7 @@ int rc_dsm_is_connection_active();
131131
* @return Returns the number of nanoseconds since the last dsm packet was
132132
* received. Return -1 on error or if no packet has ever been received.
133133
*/
134-
int64_t rc_dsm_nanos_since_last_packet();
134+
int64_t rc_dsm_nanos_since_last_packet(void);
135135

136136

137137
/**
@@ -141,7 +141,7 @@ int64_t rc_dsm_nanos_since_last_packet();
141141
* @return returns 10 or 11 indicating 10-bit or 11-bit resolution returns a
142142
* 0 if no packet has been received yet or -1 on error
143143
*/
144-
int rc_dsm_resolution();
144+
int rc_dsm_resolution(void);
145145

146146

147147
/**
@@ -150,7 +150,7 @@ int rc_dsm_resolution();
150150
* @return Returns number of channels being received, 0 if no packet has
151151
* been received yet or -1 on error.
152152
*/
153-
int rc_dsm_channels();
153+
int rc_dsm_channels(void);
154154

155155

156156
/**
@@ -189,7 +189,7 @@ int rc_dsm_channels();
189189
*
190190
* @return 0 on success, -1 on failure
191191
*/
192-
int rc_dsm_bind_routine();
192+
int rc_dsm_bind_routine(void);
193193

194194

195195
/**
@@ -202,7 +202,7 @@ int rc_dsm_bind_routine();
202202
*
203203
* @return 0 on success, -1 on failure
204204
*/
205-
int rc_dsm_calibrate_routine();
205+
int rc_dsm_calibrate_routine(void);
206206

207207

208208
#ifdef __cplusplus

library/include/rc/encoder.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ extern "C" {
3333
*
3434
* @return 0 on success or -1 on failure
3535
*/
36-
int rc_encoder_init();
36+
int rc_encoder_init(void);
3737

3838
/**
3939
* @brief Stops the encoder counters and closes file descriptors. This is
@@ -42,7 +42,7 @@ int rc_encoder_init();
4242
*
4343
* @return 0 on success or -1 on failure.
4444
*/
45-
int rc_encoder_cleanup();
45+
int rc_encoder_cleanup(void);
4646

4747
/**
4848
* @brief Reads the current position of an encoder channel.

library/include/rc/encoder_eqep.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ extern "C" {
3434
*
3535
* @return 0 on success or -1 on failure
3636
*/
37-
int rc_encoder_eqep_init();
37+
int rc_encoder_eqep_init(void);
3838

3939
/**
4040
* @brief Stops the eQEP encoder counters and closes file descriptors. This
@@ -43,7 +43,7 @@ int rc_encoder_eqep_init();
4343
*
4444
* @return 0 on success or -1 on failure.
4545
*/
46-
int rc_encoder_eqep_cleanup();
46+
int rc_encoder_eqep_cleanup(void);
4747

4848
/**
4949
* @brief Reads the current position of an encoder channel.

library/include/rc/encoder_pru.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ extern "C" {
3535
*
3636
* @return 0 on success or -1 on failure
3737
*/
38-
int rc_encoder_pru_init();
38+
int rc_encoder_pru_init(void);
3939

4040
/**
4141
* @brief Stops the PRU encoder counter and closes file descriptors. This
4242
* is not strictly necessary but is recommended that the user calls this
4343
* function at the end of their program.
4444
*/
45-
void rc_encoder_pru_cleanup();
45+
void rc_encoder_pru_cleanup(void);
4646

4747
/**
4848
* @brief Reads the current position of encoder channel 4.
@@ -53,7 +53,7 @@ void rc_encoder_pru_cleanup();
5353
* @return The current position (signed 32-bit integer) or -1 and prints an
5454
* error message is there is a problem.
5555
*/
56-
int rc_encoder_pru_read();
56+
int rc_encoder_pru_read(void);
5757

5858
/**
5959
* @brief Sets the current position of encoder channel 4. Usually for

library/include/rc/led.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ int rc_led_set(rc_led_t led, int value);
6464
* This does NOT turn off the LEDs, it is up to the user to leave the LEDs in
6565
* the desired state before closing.
6666
*/
67-
void rc_led_cleanup();
67+
void rc_led_cleanup(void);
6868

6969

7070
/**
@@ -113,7 +113,7 @@ void rc_led_stop_blink(rc_led_t led);
113113
* rc_led_stop_blink from a separate thread or signal handler. This will cause
114114
* rc_led_blink to return 1 if blinking was stopped mid-way.
115115
*/
116-
void rc_led_stop_blink_all();
116+
void rc_led_stop_blink_all(void);
117117

118118

119119

library/include/rc/math/filter.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ typedef struct rc_filter_t{
9292
*
9393
* @return Empty zero-filled rc_filter_t struct
9494
*/
95-
rc_filter_t rc_filter_empty();
95+
rc_filter_t rc_filter_empty(void);
9696

9797
/**
9898
* @brief Allocate memory for a discrete-time filter & populates it with

library/include/rc/math/kalman.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ typedef struct rc_kalman_t {
123123
*
124124
* @return Empty zero-filled rc_kalman_t struct
125125
*/
126-
rc_kalman_t rc_kalman_empty();
126+
rc_kalman_t rc_kalman_empty(void);
127127

128128
/**
129129
* @brief Allocates memory for a Kalman filter of given dimensions

library/include/rc/math/matrix.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ typedef struct rc_matrix_t{
4949
*
5050
* @return Returns an empty rc_matrix_t
5151
*/
52-
rc_matrix_t rc_matrix_empty();
52+
rc_matrix_t rc_matrix_empty(void);
5353

5454
/**
5555
* @brief Allocates memory for matrix A to have size rows&cols.

library/include/rc/math/other.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern "C" {
2727
*
2828
* @return random floating point number between -1 and 1
2929
*/
30-
float rc_get_random_float();
30+
float rc_get_random_float(void);
3131

3232
/**
3333
* @brief Returns a random double-precision floating point number between
@@ -38,7 +38,7 @@ float rc_get_random_float();
3838
*
3939
* @return random double-precision floating point number between -1 and 1
4040
*/
41-
double rc_get_random_double();
41+
double rc_get_random_double(void);
4242

4343
/**
4444
* @brief Modifies val to be bounded between between min and max.

library/include/rc/math/ring_buffer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ typedef struct rc_ringbuf_t {
4949
*
5050
* @return empty and ready-to-allocate rc_ringbuf_t
5151
*/
52-
rc_ringbuf_t rc_ringbuf_empty();
52+
rc_ringbuf_t rc_ringbuf_empty(void);
5353

5454
/**
5555
* @brief Allocates memory for a ring buffer and initializes an

library/include/rc/math/vector.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ typedef struct rc_vector_t{
5858
* @return rc_vector_t with no allocated memory and the initialized flag set
5959
* to 0.
6060
*/
61-
rc_vector_t rc_vector_empty();
61+
rc_vector_t rc_vector_empty(void);
6262

6363
/**
6464
* @brief Allocates memory for vector v to have specified length.

library/include/rc/mavlink_udp.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ int rc_mav_set_system_id(uint8_t system_id);
103103
*
104104
* @return 0 on success, -1 on failure
105105
*/
106-
int rc_mav_cleanup();
106+
int rc_mav_cleanup(void);
107107

108108

109109
/**
@@ -201,7 +201,7 @@ int rc_mav_set_callback_connection_lost(void (*func)(void));
201201
*
202202
* @return Returns current connection state.
203203
*/
204-
rc_mav_connection_state_t rc_mav_get_connection_state();
204+
rc_mav_connection_state_t rc_mav_get_connection_state(void);
205205

206206

207207
/**
@@ -222,7 +222,7 @@ uint8_t rc_mav_get_sys_id_of_last_msg(int msg_id);
222222
* @return Returns the system ID on success. Returns -1 on failure, for
223223
* example if no message has been received.
224224
*/
225-
uint8_t rc_mav_get_sys_id_of_last_msg_any();
225+
uint8_t rc_mav_get_sys_id_of_last_msg_any(void);
226226

227227
/**
228228
* @brief Fetches the number of nanoseconds since the last message of type
@@ -243,15 +243,15 @@ int64_t rc_mav_ns_since_last_msg(int msg_id);
243243
* @return Returns the number of nanoseconds since any message has been
244244
* received. Returns -1 on failure, for example if no message has been received.
245245
*/
246-
int64_t rc_mav_ns_since_last_msg_any();
246+
int64_t rc_mav_ns_since_last_msg_any(void);
247247

248248
/**
249249
* @brief Returns the msg_id of the last received packet.
250250
*
251251
* @return Returns the msg_id of the last received packet. Returns -1 on
252252
* failure, for example if no message has been received.
253253
*/
254-
int rc_mav_msg_id_of_last_msg();
254+
int rc_mav_msg_id_of_last_msg(void);
255255

256256
/**
257257
* @brief Prints to stdout a human-readable name for a message type.

0 commit comments

Comments
 (0)