mraa: Fix compiler warnings unused vars and useless statements
Should have 0 functionality effect, just cleans up a few things. Fixes #577 Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
@@ -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)
|
compiled so use this flag to force the target arch)
|
||||||
`-DBUILDARCH=arm`
|
`-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
|
## Dependencies continued
|
||||||
|
|
||||||
You'll need at least SWIG version 3.0.2 and we recommend 3.0.5 to build the
|
You'll need at least SWIG version 3.0.2 and we recommend 3.0.5 to build the
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ main()
|
|||||||
value = 0.0f;
|
value = 0.0f;
|
||||||
}
|
}
|
||||||
float output = mraa_pwm_read(pwm);
|
float output = mraa_pwm_read(pwm);
|
||||||
|
printf("PWM value is %f\n", output);
|
||||||
}
|
}
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ interrupt(char* data)
|
|||||||
mraa_iio_channel* channels = mraa_iio_get_channels(iio_device0);
|
mraa_iio_channel* channels = mraa_iio_get_channels(iio_device0);
|
||||||
int i = 0;
|
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) {
|
if (channels[i].enabled) {
|
||||||
printf("channel %d - bytes %d\n", channels[i].index, channels[i].bytes);
|
printf("channel %d - bytes %d\n", channels[i].index, channels[i].bytes);
|
||||||
switch (channels[i].bytes) {
|
switch (channels[i].bytes) {
|
||||||
|
|||||||
@@ -144,7 +144,6 @@ i2c_set_exit:
|
|||||||
void
|
void
|
||||||
i2c_detect_devices(int bus)
|
i2c_detect_devices(int bus)
|
||||||
{
|
{
|
||||||
mraa_result_t status = MRAA_SUCCESS;
|
|
||||||
mraa_i2c_context i2c = mraa_i2c_init(bus);
|
mraa_i2c_context i2c = mraa_i2c_init(bus);
|
||||||
if (i2c == NULL) {
|
if (i2c == NULL) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ main(int argc, char** argv)
|
|||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
mraa_spi_context spi;
|
mraa_spi_context spi;
|
||||||
spi = mraa_spi_init(0);
|
spi = mraa_spi_init(0);
|
||||||
unsigned int response = 0;
|
|
||||||
printf("Hello, SPI initialised\n");
|
printf("Hello, SPI initialised\n");
|
||||||
uint8_t data[] = { 0x00, 100 };
|
uint8_t data[] = { 0x00, 100 };
|
||||||
uint8_t* recv;
|
uint8_t* recv;
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ mraa_iio_wait_event(int fd, char* data, int* read_size)
|
|||||||
|
|
||||||
// Wait for it forever or until pthread_cancel
|
// Wait for it forever or until pthread_cancel
|
||||||
// poll is a cancelable point like sleep()
|
// poll is a cancelable point like sleep()
|
||||||
int x = poll(&pfd, 1, -1);
|
poll(&pfd, 1, -1);
|
||||||
|
|
||||||
memset(data, 0, 100);
|
memset(data, 0, 100);
|
||||||
*read_size = read(fd, data, 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 buf[MAX_SIZE];
|
||||||
char readbuf[32];
|
char readbuf[32];
|
||||||
int fd;
|
int fd;
|
||||||
int ret = 0;
|
|
||||||
int padint = 0;
|
|
||||||
int curr_bytes = 0;
|
|
||||||
char shortbuf, signchar;
|
|
||||||
memset(buf, 0, MAX_SIZE);
|
memset(buf, 0, MAX_SIZE);
|
||||||
memset(readbuf, 0, 32);
|
memset(readbuf, 0, 32);
|
||||||
snprintf(buf, MAX_SIZE, IIO_SYSFS_DEVICE "%d/" IIO_EVENTS, dev->num);
|
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
|
// Wait for it forever or until pthread_cancel
|
||||||
// poll is a cancelable point like sleep()
|
// 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));
|
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)
|
mraa_iio_create_trigger(mraa_iio_context dev, const char* trigger)
|
||||||
{
|
{
|
||||||
struct stat configfs_status;
|
struct stat configfs_status;
|
||||||
struct stat trigger_status;
|
|
||||||
char buf[MAX_SIZE];
|
char buf[MAX_SIZE];
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (stat(IIO_CONFIGFS_TRIGGER, &configfs_status) == 0) {
|
if (stat(IIO_CONFIGFS_TRIGGER, &configfs_status) == 0) {
|
||||||
memset(buf, 0, MAX_SIZE);
|
memset(buf, 0, MAX_SIZE);
|
||||||
|
|||||||
@@ -80,7 +80,6 @@ mraa_init_json_platform_platform(json_object* jobj_platform, mraa_board_t* board
|
|||||||
{
|
{
|
||||||
json_object* jobj_temp = NULL;
|
json_object* jobj_temp = NULL;
|
||||||
const char* temp_string = NULL;
|
const char* temp_string = NULL;
|
||||||
int temp_count = 0;
|
|
||||||
int length = 0;
|
int length = 0;
|
||||||
mraa_result_t ret = MRAA_SUCCESS;
|
mraa_result_t ret = MRAA_SUCCESS;
|
||||||
|
|
||||||
@@ -600,8 +599,8 @@ mraa_init_json_platform(const char* platform_json)
|
|||||||
mraa_result_t ret = MRAA_SUCCESS;
|
mraa_result_t ret = MRAA_SUCCESS;
|
||||||
char* buffer = NULL;
|
char* buffer = NULL;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int file_lock = 0, array_length = 0, i = 0;
|
int file_lock = 0, i = 0;
|
||||||
json_object *jobj_platform = NULL, *jobj_temp = NULL;
|
json_object *jobj_platform = NULL;
|
||||||
mraa_board_t* board = NULL;
|
mraa_board_t* board = NULL;
|
||||||
|
|
||||||
// Try to lock the file for use
|
// Try to lock the file for use
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ mraa_iio_info_t* plat_iio = NULL;
|
|||||||
mraa_lang_func_t* lang_func = NULL;
|
mraa_lang_func_t* lang_func = NULL;
|
||||||
|
|
||||||
char* platform_name = NULL;
|
char* platform_name = NULL;
|
||||||
static char* platform_long_name = NULL;
|
|
||||||
|
|
||||||
static int num_i2c_devices = 0;
|
static int num_i2c_devices = 0;
|
||||||
static int num_iio_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
|
// i2c devices are numbered numerically so 0 must exist otherwise there is
|
||||||
// no i2c-dev loaded
|
// no i2c-dev loaded
|
||||||
if (mraa_file_exist("/sys/class/i2c-dev/i2c-0")) {
|
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;
|
off_t size, err;
|
||||||
snprintf(path, 64, "/sys/class/i2c-dev/i2c-%u/name", i);
|
snprintf(path, 64, "/sys/class/i2c-dev/i2c-%u/name", i);
|
||||||
fd = open(path, O_RDONLY);
|
fd = open(path, O_RDONLY);
|
||||||
|
|||||||
@@ -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
|
/* return the bit present on the bus (0xff is a '1', anything else
|
||||||
* (typically 0xfc or 0x00) is a 0
|
* (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 -1;
|
||||||
}
|
}
|
||||||
return (ch == 0xff);
|
return (ch == 0xff);
|
||||||
|
|||||||
@@ -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));
|
mraa_board_t* b = (mraa_board_t*) calloc(1, sizeof(mraa_board_t));
|
||||||
|
|
||||||
struct utsname running_uname;
|
struct utsname running_uname;
|
||||||
int uname_major, uname_minor, max_pins[28];
|
int uname_major, uname_minor;
|
||||||
|
|
||||||
if (b == NULL) {
|
if (b == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ mraa_up_board()
|
|||||||
mraa_board_t* b = (mraa_board_t*) calloc(1, sizeof(mraa_board_t));
|
mraa_board_t* b = (mraa_board_t*) calloc(1, sizeof(mraa_board_t));
|
||||||
|
|
||||||
struct utsname running_uname;
|
struct utsname running_uname;
|
||||||
int uname_major, uname_minor, max_pins[27];
|
int uname_major, uname_minor;
|
||||||
|
|
||||||
if (b == NULL) {
|
if (b == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user