Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build everything with -Werror #1100

Merged
merged 12 commits into from
Dec 11, 2023
Merged
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ if (MSVC)
# Azure Pipelines: TF_BUILD=True
if(COMPILE_WARNING_AS_ERROR)
message(STATUS "Setting -Werror")
target_compile_options(iio PRIVATE /WX)
target_compile_options(iio PUBLIC /WX)
endif()
elseif (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
option(WITH_GCOV "Build with gcov profiling flags" OFF)
Expand All @@ -318,7 +318,7 @@ elseif (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
endif()
if(COMPILE_WARNING_AS_ERROR)
message(STATUS "Setting -Werror")
target_compile_options(iio PRIVATE -Werror)
target_compile_options(iio PUBLIC -Werror)
endif()
else()
message(STATUS "Unknown compiler ${CMAKE_C_COMPILER_ID}")
Expand Down Expand Up @@ -602,6 +602,9 @@ if (IIOD_CLIENT OR WITH_IIOD)
# Link against exported symbols of Libiio and not the
# DLL-exported symbols
target_compile_definitions(iiod-responder PRIVATE LIBIIO_STATIC)

# Use the same compile options as Libiio
target_compile_options(iiod-responder PUBLIC $<TARGET_PROPERTY:iio,INTERFACE_COMPILE_OPTIONS>)
endif()

if (IIOD_CLIENT)
Expand Down
12 changes: 7 additions & 5 deletions iiod-responder.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,13 +455,15 @@ static int iiod_io_cond_wait(const struct iiod_io *io)

diff_ms = (read_counter_us() - io->r_io.start_time) / 1000;

if (diff_ms < timeout_ms)
return iio_cond_wait(io->cond, io->lock, timeout_ms - diff_ms);
if (diff_ms < timeout_ms) {
return iio_cond_wait(io->cond, io->lock,
(unsigned int)(timeout_ms - diff_ms));
}

return -ETIMEDOUT;
}

intptr_t iiod_io_wait_for_response(struct iiod_io *io)
int32_t iiod_io_wait_for_response(struct iiod_io *io)
{
struct iiod_responder *priv = io->responder;
int ret = 0;
Expand Down Expand Up @@ -509,13 +511,13 @@ int iiod_io_send_command(struct iiod_io *io,
return iiod_io_wait_for_command_done(io);
}

int iiod_io_send_response_async(struct iiod_io *io, intptr_t code,
int iiod_io_send_response_async(struct iiod_io *io, int32_t code,
const struct iiod_buf *buf, size_t nb)
{
return iiod_enqueue_command(io, IIOD_OP_RESPONSE, 0, code, buf, nb);
}

int iiod_io_send_response(struct iiod_io *io, intptr_t code,
int iiod_io_send_response(struct iiod_io *io, int32_t code,
const struct iiod_buf *buf, size_t nb)
{
int ret;
Expand Down
8 changes: 4 additions & 4 deletions iiod-responder.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ int iiod_command_data_read(struct iiod_command_data *data,
int iiod_io_send_command(struct iiod_io *io,
const struct iiod_command *cmd,
const struct iiod_buf *buf, size_t nb);
int iiod_io_send_response(struct iiod_io *io, intptr_t code,
int iiod_io_send_response(struct iiod_io *io, int32_t code,
const struct iiod_buf *buf, size_t nb);

/* Send command, then read the response. */
Expand All @@ -148,7 +148,7 @@ iiod_io_exec_simple_command(struct iiod_io *io,
int iiod_io_send_command_async(struct iiod_io *io,
const struct iiod_command *cmd,
const struct iiod_buf *buf, size_t nb);
int iiod_io_send_response_async(struct iiod_io *io, intptr_t code,
int iiod_io_send_response_async(struct iiod_io *io, int32_t code,
const struct iiod_buf *buf, size_t nb);

/* Wait for an async. command or response to be done sending */
Expand All @@ -158,7 +158,7 @@ _Bool iiod_io_command_is_done(struct iiod_io *io);

/* Simplified version of iiod_io_send_response, to just send a code. */
static inline int
iiod_io_send_response_code(struct iiod_io *io, intptr_t code)
iiod_io_send_response_code(struct iiod_io *io, int32_t code)
{
return iiod_io_send_response(io, code, NULL, 0);
}
Expand All @@ -168,7 +168,7 @@ int iiod_io_get_response_async(struct iiod_io *io,
const struct iiod_buf *buf, size_t nb);

/* Wait for iiod_io_get_response_async to be done. */
intptr_t iiod_io_wait_for_response(struct iiod_io *io);
int32_t iiod_io_wait_for_response(struct iiod_io *io);

_Bool iiod_io_has_response(struct iiod_io *io);

Expand Down
3 changes: 2 additions & 1 deletion iiod/dns-sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ static void start_avahi_thd(struct thread_pool *pool, void *d)
if (avahi.client)
break;
again:
IIO_INFO("Avahi didn't start, try again in %d seconds later\n", ts.tv_sec);
IIO_INFO("Avahi didn't start, try again in %ld seconds later\n",
(long)ts.tv_sec);
nanosleep(&ts, NULL);
ts.tv_sec++;
/* If it hasn't started in 20 times over 210 seconds (3.5 min),
Expand Down
4 changes: 3 additions & 1 deletion iiod/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ typedef void *yyscan_t;
#include <stdbool.h>
#include <sys/socket.h>

int yylex();
union YYSTYPE;

int yylex(union YYSTYPE *type, yyscan_t scanner);
int yylex_init_extra(void *d, yyscan_t *scanner);
int yylex_destroy(yyscan_t yyscanner);

Expand Down
4 changes: 2 additions & 2 deletions utils/iio_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ unsigned long int sanitize_clamp(const char *name, const char *argv,
return (unsigned long int) val;
}

char ** dup_argv(char * name, int argc, char * argv[])
char ** dup_argv(char * name, unsigned int argc, char * argv[])
{
unsigned int i;
char** new_argv;
Expand Down Expand Up @@ -179,7 +179,7 @@ char ** dup_argv(char * name, int argc, char * argv[])
exit(0);
}

void free_argw(int argc, char * argw[])
void free_argw(unsigned int argc, char * argw[])
{
unsigned int i;

Expand Down
4 changes: 2 additions & 2 deletions utils/iio_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ struct option * add_common_options(const struct option * longopts);
void usage(char *name, const struct option *options, const char *options_descriptions[]);
void version(char *name);

char ** dup_argv(char * name, int argc, char * argv[]);
void free_argw(int argc, char * argw[]);
char ** dup_argv(char * name, unsigned int argc, char * argv[]);
void free_argw(unsigned int argc, char * argw[]);

uint64_t get_time_us(void);

Expand Down
4 changes: 2 additions & 2 deletions utils/iio_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <getopt.h>
#include <iio/iio.h>
#include <iio/iio-debug.h>
#include <inttypes.h>
#include <signal.h>
#include <stdio.h>

Expand Down Expand Up @@ -63,7 +64,7 @@ static void print_event(const struct iio_device *dev,
enum iio_event_type type = iio_event_get_type(event);
enum iio_event_direction dir = iio_event_get_direction(event);

printf("Event: time: %lld", event->timestamp);
printf("Event: time: %"PRId64, event->timestamp); /* Flawfinder: ignore */

chn = iio_event_get_channel(event, dev, false);
if (chn)
Expand Down Expand Up @@ -175,7 +176,6 @@ int main(int argc, char **argv)
out_ctx_destroy:
if (ctx)
iio_context_destroy(ctx);
out_free_argw:
free_argw(argc, argw);
return ret;
}
1 change: 0 additions & 1 deletion utils/iio_genxml.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ int main(int argc, char **argv)
char **argw, *uri;
const char *xml;
struct iio_context *ctx;
size_t xml_len;
struct option *opts;
size_t buf_len;
int c, ret = EXIT_FAILURE;
Expand Down
15 changes: 12 additions & 3 deletions utils/iio_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,19 @@ static int dev_is_buffer_capable(const struct iio_device *dev)

static bool colors;

#ifndef _MSC_BUILD
#define FMT_ERR "\e[1;31mERROR: %s\e[0m"
#define FMT_DEV "\e[1;32m%s\e[0m"
#define FMT_CHN "\e[0;33m%s\e[0m"
#define FMT_ATTR "\e[1;34m%s\e[0m"
#else
/* MSVC doesn't like escape codes. But those will never be used anyway,
* as color support is disabled when building with MSVC. */
#define FMT_ERR "%s"
#define FMT_DEV "%s"
#define FMT_CHN "%s"
#define FMT_ATTR "%s"
#endif

/* Keeps Codacy happy */
#define print_fmt(fmt, ...) printf(fmt, __VA_ARGS__) /* Flawfinder: ignore */
Expand All @@ -81,7 +90,7 @@ static void print_attr(const struct iio_attr *attr,
if (!value) {
ret = iio_attr_read_raw(attr, buf, sizeof(buf) - 1);
if (ret < 0)
iio_strerror(ret, buf, sizeof(buf));
iio_strerror((int)ret, buf, sizeof(buf));
value = buf;
}

Expand Down Expand Up @@ -161,10 +170,10 @@ static void print_channel(const struct iio_channel *chn)

int main(int argc, char **argv)
{
char **argw, *buf;
char **argw;
const struct iio_device *dev, *trig;
const struct iio_channel *ch;
const char *key, *value, *name, *label, *type_name;
const char *name, *label;
unsigned int i, j, k, nb_devices, nb_channels, nb_ctx_attrs, nb_attrs;
struct iio_channels_mask *mask;
const struct iio_attr *attr;
Expand Down