mirror of
https://github.com/optim-enterprises-bv/nDPId.git
synced 2025-10-28 17:02:24 +00:00
Warn about unused return values that are quite important.
* CI: ArchLinux build should now instrument `-Werror` * CI: Increased OpenWrt build verbosity Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
This commit is contained in:
2
.github/workflows/build-archlinux.yml
vendored
2
.github/workflows/build-archlinux.yml
vendored
@@ -15,6 +15,8 @@ on:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
CMAKE_C_FLAGS: -Werror
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
|
||||
1
.github/workflows/build-openwrt.yml
vendored
1
.github/workflows/build-openwrt.yml
vendored
@@ -57,6 +57,7 @@ jobs:
|
||||
FEED_DIR: ${{ github.workspace }}/packages/openwrt
|
||||
FEEDNAME: ndpid_openwrt_packages_ci
|
||||
PACKAGES: nDPId-testing
|
||||
V: s
|
||||
|
||||
- name: Store packages
|
||||
uses: actions/upload-artifact@v3
|
||||
|
||||
@@ -1557,7 +1557,11 @@ static int nio_selftest()
|
||||
|
||||
char const wbuf[] = "AAAA";
|
||||
size_t const wlen = strnlen(wbuf, sizeof(wbuf));
|
||||
write(pipefds[1], wbuf, wlen);
|
||||
if (write(pipefds[1], wbuf, wlen) < 0)
|
||||
{
|
||||
logger(1, "Write '%s' (%zu bytes) to pipe failed with: %s", wbuf, wlen, strerror(errno));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (nio_run(&io, 1000) != NIO_SUCCESS)
|
||||
{
|
||||
|
||||
9
nDPId.c
9
nDPId.c
@@ -89,6 +89,8 @@
|
||||
name.var = value; \
|
||||
pthread_mutex_init(&name.var_mutex, NULL); \
|
||||
} while (0)
|
||||
|
||||
WARN_UNUSED
|
||||
static inline uint64_t mt_pt_get_and_add(volatile uint64_t * value, uint64_t add, pthread_mutex_t * mutex)
|
||||
{
|
||||
uint64_t result;
|
||||
@@ -98,7 +100,10 @@ static inline uint64_t mt_pt_get_and_add(volatile uint64_t * value, uint64_t add
|
||||
pthread_mutex_unlock(mutex);
|
||||
return result;
|
||||
}
|
||||
|
||||
#define MT_GET_AND_ADD(name, value) mt_pt_get_and_add(&name.var, value, &name.var_mutex)
|
||||
|
||||
WARN_UNUSED
|
||||
static inline uint64_t mt_pt_get_and_sub(volatile uint64_t * value, uint64_t sub, pthread_mutex_t * mutex)
|
||||
{
|
||||
uint64_t result;
|
||||
@@ -591,7 +596,7 @@ static char * const subopt_token[] = {[MAX_FLOWS_PER_THREAD] = "max-flows-per-th
|
||||
NULL};
|
||||
|
||||
static void sighandler(int signum);
|
||||
static int processing_threads_error_or_eof(void);
|
||||
static WARN_UNUSED int processing_threads_error_or_eof(void);
|
||||
static void free_workflow(struct nDPId_workflow ** const workflow);
|
||||
static void serialize_and_send(struct nDPId_reader_thread * const reader_thread);
|
||||
static void jsonize_flow_event(struct nDPId_reader_thread * const reader_thread,
|
||||
@@ -4622,7 +4627,7 @@ static void * processing_thread(void * const ndpi_thread_arg)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int processing_threads_error_or_eof(void)
|
||||
static WARN_UNUSED int processing_threads_error_or_eof(void)
|
||||
{
|
||||
for (unsigned long long int i = 0; i < nDPId_options.reader_thread_count; ++i)
|
||||
{
|
||||
|
||||
16
nio.h
16
nio.h
@@ -3,6 +3,8 @@
|
||||
|
||||
#include <poll.h>
|
||||
|
||||
#define WARN_UNUSED __attribute__((__warn_unused_result__))
|
||||
|
||||
enum
|
||||
{
|
||||
NIO_SUCCESS = 0,
|
||||
@@ -34,41 +36,55 @@ struct nio
|
||||
|
||||
void nio_init(struct nio * io);
|
||||
|
||||
WARN_UNUSED
|
||||
int nio_use_poll(struct nio * io, nfds_t max_fds);
|
||||
|
||||
WARN_UNUSED
|
||||
int nio_use_epoll(struct nio * io, int max_events);
|
||||
|
||||
WARN_UNUSED
|
||||
int nio_add_fd(struct nio * io, int fd, int event_flags, void * ptr);
|
||||
|
||||
WARN_UNUSED
|
||||
int nio_mod_fd(struct nio * io, int fd, int event_flags, void * ptr);
|
||||
|
||||
WARN_UNUSED
|
||||
int nio_del_fd(struct nio * io, int fd);
|
||||
|
||||
WARN_UNUSED
|
||||
int nio_run(struct nio * io, int timeout);
|
||||
|
||||
WARN_UNUSED
|
||||
static inline int nio_get_nready(struct nio const * const io)
|
||||
{
|
||||
return io->nready;
|
||||
}
|
||||
|
||||
WARN_UNUSED
|
||||
int nio_check(struct nio * io, int index, int events);
|
||||
|
||||
WARN_UNUSED
|
||||
int nio_is_valid(struct nio const * const io, int index);
|
||||
|
||||
WARN_UNUSED
|
||||
int nio_get_fd(struct nio * io, int index);
|
||||
|
||||
WARN_UNUSED
|
||||
void * nio_get_ptr(struct nio * io, int index);
|
||||
|
||||
WARN_UNUSED
|
||||
static inline int nio_has_input(struct nio * io, int index)
|
||||
{
|
||||
return nio_check(io, index, NIO_EVENT_INPUT);
|
||||
}
|
||||
|
||||
WARN_UNUSED
|
||||
static inline int nio_can_output(struct nio * io, int index)
|
||||
{
|
||||
return nio_check(io, index, NIO_EVENT_OUTPUT);
|
||||
}
|
||||
|
||||
WARN_UNUSED
|
||||
static inline int nio_has_error(struct nio * io, int index)
|
||||
{
|
||||
return nio_check(io, index, NIO_EVENT_ERROR);
|
||||
|
||||
13
utils.h
13
utils.h
@@ -3,6 +3,8 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#define WARN_UNUSED __attribute__((__warn_unused_result__))
|
||||
|
||||
#define CMDARG(_default_value) \
|
||||
{ \
|
||||
.value = NULL, .default_value = (_default_value) \
|
||||
@@ -16,20 +18,26 @@ struct cmdarg
|
||||
|
||||
void set_cmdarg(struct cmdarg * const ca, char const * const val);
|
||||
|
||||
WARN_UNUSED
|
||||
char const * get_cmdarg(struct cmdarg const * const ca);
|
||||
|
||||
WARN_UNUSED
|
||||
int is_cmdarg_set(struct cmdarg const * const ca);
|
||||
|
||||
WARN_UNUSED
|
||||
int is_path_absolute(char const * const prefix, char const * const path);
|
||||
|
||||
void daemonize_enable(void);
|
||||
|
||||
WARN_UNUSED
|
||||
int is_daemonize_enabled(void);
|
||||
|
||||
WARN_UNUSED
|
||||
int daemonize_with_pidfile(char const * const pidfile);
|
||||
|
||||
int daemonize_shutdown(char const * const pidfile);
|
||||
|
||||
WARN_UNUSED
|
||||
int change_user_group(char const * const user,
|
||||
char const * const group,
|
||||
char const * const pidfile,
|
||||
@@ -42,12 +50,15 @@ void log_app_info(void);
|
||||
|
||||
void shutdown_logging(void);
|
||||
|
||||
WARN_UNUSED
|
||||
int enable_file_logger(char const * const log_file);
|
||||
|
||||
WARN_UNUSED
|
||||
int get_log_file_fd(void);
|
||||
|
||||
void enable_console_logger(void);
|
||||
|
||||
WARN_UNUSED
|
||||
int is_console_logger_enabled(void);
|
||||
|
||||
void vlogger(int is_error, char const * const format, va_list ap);
|
||||
@@ -56,8 +67,10 @@ __attribute__((format(printf, 2, 3))) void logger(int is_error, char const * con
|
||||
|
||||
__attribute__((format(printf, 2, 3))) void logger_early(int is_error, char const * const format, ...);
|
||||
|
||||
WARN_UNUSED
|
||||
int set_fd_cloexec(int fd);
|
||||
|
||||
WARN_UNUSED
|
||||
char const * get_nDPId_version(void);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user