diff --git a/docs/building.md b/docs/building.md index 1af4711..c73a912 100644 --- a/docs/building.md +++ b/docs/building.md @@ -102,6 +102,10 @@ Override build architecture (this is useful because on x86 ARM code is not compiled so use this flag to force the target arch) `-DBUILDARCH=arm` +You can also enable -Wall for gcc before running cmake by exporting your wanted +CC flags to the CC env var + `export CC="gcc -Wall"` + ## Dependencies continued You'll need at least SWIG version 3.0.2 and we recommend 3.0.5 to build the diff --git a/examples/cycle-pwm3.c b/examples/cycle-pwm3.c index d11e066..5924e23 100644 --- a/examples/cycle-pwm3.c +++ b/examples/cycle-pwm3.c @@ -49,6 +49,7 @@ main() value = 0.0f; } float output = mraa_pwm_read(pwm); + printf("PWM value is %f\n", output); } //! [Interesting] return 0; diff --git a/examples/iio_driver.c b/examples/iio_driver.c index 824e0b1..c5a0181 100644 --- a/examples/iio_driver.c +++ b/examples/iio_driver.c @@ -55,7 +55,7 @@ interrupt(char* data) mraa_iio_channel* channels = mraa_iio_get_channels(iio_device0); int i = 0; - for (i; i < mraa_iio_get_channel_count(iio_device0); i++) { + for (; i < mraa_iio_get_channel_count(iio_device0); i++) { if (channels[i].enabled) { printf("channel %d - bytes %d\n", channels[i].index, channels[i].bytes); switch (channels[i].bytes) { diff --git a/examples/mraa-i2c.c b/examples/mraa-i2c.c index 43047ed..a7d6584 100644 --- a/examples/mraa-i2c.c +++ b/examples/mraa-i2c.c @@ -144,7 +144,6 @@ i2c_set_exit: void i2c_detect_devices(int bus) { - mraa_result_t status = MRAA_SUCCESS; mraa_i2c_context i2c = mraa_i2c_init(bus); if (i2c == NULL) { return; diff --git a/examples/spi_mcp4261.c b/examples/spi_mcp4261.c index 1acd121..a2efa6c 100644 --- a/examples/spi_mcp4261.c +++ b/examples/spi_mcp4261.c @@ -33,7 +33,6 @@ main(int argc, char** argv) //! [Interesting] mraa_spi_context spi; spi = mraa_spi_init(0); - unsigned int response = 0; printf("Hello, SPI initialised\n"); uint8_t data[] = { 0x00, 100 }; uint8_t* recv; diff --git a/src/iio/iio.c b/src/iio/iio.c index ef2da55..9d90b67 100644 --- a/src/iio/iio.c +++ b/src/iio/iio.c @@ -309,7 +309,7 @@ mraa_iio_wait_event(int fd, char* data, int* read_size) // Wait for it forever or until pthread_cancel // poll is a cancelable point like sleep() - int x = poll(&pfd, 1, -1); + poll(&pfd, 1, -1); memset(data, 0, 100); *read_size = read(fd, data, 100); @@ -376,10 +376,7 @@ mraa_iio_get_event_data(mraa_iio_context dev) char buf[MAX_SIZE]; char readbuf[32]; int fd; - int ret = 0; - int padint = 0; - int curr_bytes = 0; - char shortbuf, signchar; + memset(buf, 0, MAX_SIZE); memset(readbuf, 0, 32); snprintf(buf, MAX_SIZE, IIO_SYSFS_DEVICE "%d/" IIO_EVENTS, dev->num); @@ -441,7 +438,7 @@ mraa_iio_event_poll_nonblock(int fd, struct iio_event_data* data) // Wait for it forever or until pthread_cancel // poll is a cancelable point like sleep() - int x = poll(&pfd, 1, -1); + poll(&pfd, 1, -1); read(fd, data, sizeof(struct iio_event_data)); @@ -573,9 +570,7 @@ mraa_result_t mraa_iio_create_trigger(mraa_iio_context dev, const char* trigger) { struct stat configfs_status; - struct stat trigger_status; char buf[MAX_SIZE]; - int ret; if (stat(IIO_CONFIGFS_TRIGGER, &configfs_status) == 0) { memset(buf, 0, MAX_SIZE); diff --git a/src/json/jsonplatform.c b/src/json/jsonplatform.c index bcdc00a..bfc74c6 100644 --- a/src/json/jsonplatform.c +++ b/src/json/jsonplatform.c @@ -80,7 +80,6 @@ mraa_init_json_platform_platform(json_object* jobj_platform, mraa_board_t* board { json_object* jobj_temp = NULL; const char* temp_string = NULL; - int temp_count = 0; int length = 0; mraa_result_t ret = MRAA_SUCCESS; @@ -600,8 +599,8 @@ mraa_init_json_platform(const char* platform_json) mraa_result_t ret = MRAA_SUCCESS; char* buffer = NULL; struct stat st; - int file_lock = 0, array_length = 0, i = 0; - json_object *jobj_platform = NULL, *jobj_temp = NULL; + int file_lock = 0, i = 0; + json_object *jobj_platform = NULL; mraa_board_t* board = NULL; // Try to lock the file for use diff --git a/src/mraa.c b/src/mraa.c index bc517bc..fa469b9 100644 --- a/src/mraa.c +++ b/src/mraa.c @@ -69,7 +69,6 @@ mraa_iio_info_t* plat_iio = NULL; mraa_lang_func_t* lang_func = NULL; char* platform_name = NULL; -static char* platform_long_name = NULL; static int num_i2c_devices = 0; static int num_iio_devices = 0; @@ -953,7 +952,7 @@ mraa_find_i2c_bus(const char* devname, int startfrom) // i2c devices are numbered numerically so 0 must exist otherwise there is // no i2c-dev loaded if (mraa_file_exist("/sys/class/i2c-dev/i2c-0")) { - for (i; i < num_i2c_devices; i++) { + for (;i < num_i2c_devices; i++) { off_t size, err; snprintf(path, 64, "/sys/class/i2c-dev/i2c-%u/name", i); fd = open(path, O_RDONLY); diff --git a/src/uart_ow/uart_ow.c b/src/uart_ow/uart_ow.c index 759ba2f..2b754d5 100644 --- a/src/uart_ow/uart_ow.c +++ b/src/uart_ow/uart_ow.c @@ -320,7 +320,7 @@ mraa_uart_ow_bit(mraa_uart_ow_context dev, uint8_t bit) /* return the bit present on the bus (0xff is a '1', anything else * (typically 0xfc or 0x00) is a 0 */ - if (_ow_read_byte(dev, &ch) == -1 || ret == -1) { + if (_ow_read_byte(dev, &ch) != MRAA_SUCCESS || ret == -1) { return -1; } return (ch == 0xff); diff --git a/src/x86/intel_minnow_byt_compatible.c b/src/x86/intel_minnow_byt_compatible.c index fa17655..b9f2577 100644 --- a/src/x86/intel_minnow_byt_compatible.c +++ b/src/x86/intel_minnow_byt_compatible.c @@ -89,7 +89,7 @@ mraa_intel_minnowboard_byt_compatible(mraa_boolean_t turbot) mraa_board_t* b = (mraa_board_t*) calloc(1, sizeof(mraa_board_t)); struct utsname running_uname; - int uname_major, uname_minor, max_pins[28]; + int uname_major, uname_minor; if (b == NULL) { return NULL; diff --git a/src/x86/up.c b/src/x86/up.c index 6ffe235..9dd8fd8 100644 --- a/src/x86/up.c +++ b/src/x86/up.c @@ -86,7 +86,7 @@ mraa_up_board() mraa_board_t* b = (mraa_board_t*) calloc(1, sizeof(mraa_board_t)); struct utsname running_uname; - int uname_major, uname_minor, max_pins[27]; + int uname_major, uname_minor; if (b == NULL) { return NULL;