Clang-Tidy: clean-up unused parameters.

This commit is contained in:
imi415 2021-07-29 00:11:32 +08:00
parent 780baa4f78
commit 4595018f48
Signed by: imi415
GPG Key ID: 17F01E106F9F5E0A
19 changed files with 106 additions and 13 deletions

View File

@ -0,0 +1,20 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(BUILDROOT_VARIANT "buildroot")
set(CMAKE_SYSROOT $ENV{BUILDROOT_SDK_PATH}/aarch64-${BUILDROOT_VARIANT}-linux-gnu/sysroot)
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_C_FLAGS "--target=aarch64-linux-gnueabihf -mcpu=cortex-a53")
set(CMAKE_CXX_FLAGS "--target=aarch64-linux-gnueabihf -mcpu=cortex-a53")
set(CMAKE_EXE_LINKER_FLAGS "-fuse-ld=lld")
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

View File

@ -0,0 +1,20 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(BUILDROOT_VARIANT "buildroot")
set(CMAKE_SYSROOT $ENV{BUILDROOT_SDK_PATH}/aarch64-${BUILDROOT_VARIANT}-linux-gnu/sysroot)
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_C_FLAGS "--target=aarch64-linux-gnueabihf -mcpu=cortex-a72")
set(CMAKE_CXX_FLAGS "--target=aarch64-linux-gnueabihf -mcpu=cortex-a72")
set(CMAKE_EXE_LINKER_FLAGS "-fuse-ld=lld")
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

View File

@ -8,6 +8,7 @@
typedef struct {
struct mosquitto *mosq;
char topic[32];
} user_mqtt_impl_t;
int user_mqtt_impl_init(user_mqtt_impl_t *handle);

6
include/user_common.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef USER_COMMON_H
#define USER_COMMON_H
#define UNUSED(x) (void)(x)
#endif

@ -1 +1 @@
Subproject commit e4ea2560c14255e1525068419fd1206fe395fa5c
Subproject commit 34da07424c1a6da262cf4e711850c6cfe1b592a1

View File

@ -5,10 +5,9 @@
#include <errno.h>
#include <string.h>
#include "user_common.h"
#include "drivers/user_config_driver.h"
#include "utils/user_log_util.h"
#include "impl/user_bme280_impl.h"
extern user_config_t g_config;
@ -79,6 +78,7 @@ bme280_ret_t user_bme280_impl_write_register_cb(user_bme280_impl_t *impl,
}
bme280_ret_t user_bme280_impl_delay_cb(user_bme280_impl_t *impl, uint32_t delay_ms) {
UNUSED(impl);
usleep(delay_ms * 1000);
return BME_OK;
}

View File

@ -6,10 +6,9 @@
#include <errno.h>
#include <string.h>
#include "user_common.h"
#include "drivers/user_config_driver.h"
#include "utils/user_log_util.h"
#include "impl/user_ccs811_impl.h"
extern user_config_t g_config;
@ -83,6 +82,7 @@ int user_ccs811_impl_deinit(user_ccs811_impl_t *impl) {
}
ccs811_ret_t user_ccs811_impl_delay_ms_cb(user_ccs811_impl_t *impl, uint32_t delay_ms) {
UNUSED(impl);
usleep(delay_ms * 1000);
return CCS_OK;
}

View File

@ -2,12 +2,11 @@
#include <sys/stat.h>
#include <unistd.h>
#include "user_common.h"
#include "drivers/user_config_driver.h"
#include "impl/user_lvgl_impl.h"
#include "impl/user_st7789_impl.h"
#include "impl/user_stick_impl.h"
#include "utils/user_log_util.h"
extern user_config_t g_config;
@ -68,6 +67,8 @@ void user_lvgl_impl_flush_cb(lv_disp_drv_t *disp_drv, const lv_area_t *area,
}
void user_lvgl_impl_indev_read_cb(lv_indev_drv_t *drv, lv_indev_data_t *data) {
UNUSED(drv);
user_stick_key_t key = user_stick_impl_read(&g_stick_impl);
user_stick_key_t key_to_determine = USER_STICK_NONE;
if(key != s_previous_key) { // Key state changed
@ -110,6 +111,8 @@ void user_lvgl_impl_log_cb(const char *buf) {
void *user_lvgl_impl_fs_open_cb(lv_fs_drv_t *drv, const char *path,
lv_fs_mode_t mode) {
UNUSED(drv);
char canonical_path[256];
char *fs_base_dir =
user_config_lookup_string(&g_config, "agent.libraries.lvgl.fs_base");
@ -136,6 +139,8 @@ void *user_lvgl_impl_fs_open_cb(lv_fs_drv_t *drv, const char *path,
}
lv_fs_res_t user_lvgl_impl_fs_close_cb(lv_fs_drv_t *drv, void *file_p) {
UNUSED(drv);
int fd = *(int *)file_p;
if(fd > 0) {
@ -154,6 +159,8 @@ lv_fs_res_t user_lvgl_impl_fs_close_cb(lv_fs_drv_t *drv, void *file_p) {
lv_fs_res_t user_lvgl_impl_fs_read_cb(lv_fs_drv_t *drv, void *file_p, void *buf,
uint32_t btr, uint32_t *br) {
UNUSED(drv);
int fd = *(int *)file_p;
if(fd > 0) {
@ -172,6 +179,8 @@ lv_fs_res_t user_lvgl_impl_fs_read_cb(lv_fs_drv_t *drv, void *file_p, void *buf,
lv_fs_res_t user_lvgl_impl_fs_write_cb(lv_fs_drv_t *drv, void *file_p,
const void *buf, uint32_t btw,
uint32_t *bw) {
UNUSED(drv);
int fd = *(int *)file_p;
if(fd > 0) {
@ -185,6 +194,8 @@ lv_fs_res_t user_lvgl_impl_fs_write_cb(lv_fs_drv_t *drv, void *file_p,
lv_fs_res_t user_lvgl_impl_fs_seek_cb(lv_fs_drv_t *drv, void *file_p,
uint32_t pos, lv_fs_whence_t whence) {
UNUSED(drv);
int fd = *(int *)file_p;
int l_whence = SEEK_SET;
@ -215,6 +226,8 @@ lv_fs_res_t user_lvgl_impl_fs_seek_cb(lv_fs_drv_t *drv, void *file_p,
lv_fs_res_t user_lvgl_impl_fs_tell_cb(lv_fs_drv_t *drv, void *file_p,
uint32_t *pos_p) {
UNUSED(drv);
int fd = *(int *)file_p;
if(fd > 0) {

View File

@ -1,9 +1,10 @@
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#include "user_common.h"
#include "impl/user_mqtt_impl.h"
#include "utils/user_log_util.h"
// TODO: Add callbacks here as static functions.
@ -16,12 +17,21 @@ int user_mqtt_impl_init(user_mqtt_impl_t *handle) {
USER_LOG(USER_LOG_INFO, "libmosquitto library version %d.%d rev. %d.", mosq_major, mosq_minor, mosq_revision);
// Init mosquitto instance.
//handle->mosq = mosquitto_new();
handle->mosq = mosquitto_new("ID", false, handle);
if(handle->mosq == NULL) {
int err = errno;
USER_LOG(USER_LOG_ERROR, "mosquitto client creation failed, reason: (%s).", strerror(err));
return -1;
}
// Enable multi-thread support.
mosquitto_threaded_set(handle->mosq, true);
return 0;
}
int user_mqtt_impl_deinit(user_mqtt_impl_t *handle) {
mosquitto_destroy(handle->mosq);
mosquitto_lib_cleanup();
return 0;
@ -32,6 +42,7 @@ int user_mqtt_network_loop(user_mqtt_impl_t *handle) {
}
mqtt_influx_ret_t user_mqtt_get_nsec_timestamp_cb(user_mqtt_impl_t *handle, char *timestamp_string) {
UNUSED(handle);
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
uint64_t ts_int = ts.tv_sec * 1e9 + ts.tv_nsec;
@ -42,5 +53,8 @@ mqtt_influx_ret_t user_mqtt_get_nsec_timestamp_cb(user_mqtt_impl_t *handle, char
mqtt_influx_ret_t user_mqtt_publish_message_cb(user_mqtt_impl_t *handle, char *data) {
USER_LOG(USER_LOG_DEBUG, "MQTT message: %s", data);
// TODO: Exception handling required.
mosquitto_publish(handle->mosq, NULL, handle->topic, strlen(data), data, 1, false);
return MQTT_INFLUX_OK;
}

View File

@ -6,6 +6,7 @@
#include <signal.h>
#include <string.h>
#include "user_common.h"
#include "drivers/user_config_driver.h"
#include "drivers/user_spi_driver.h"
#include "utils/user_log_util.h"
@ -25,6 +26,9 @@ static void signal_handler(int signo) {
}
int main(int argc, const char *argv[]) {
UNUSED(argc);
UNUSED(argv);
USER_LOG(USER_LOG_INFO, "Application started.");
int signal_arr[] = { SIGINT, SIGTERM };

View File

@ -1,3 +1,4 @@
#include "user_common.h"
#include "tasks/user_task_lvgl_common.h"
pthread_t user_base_task_thread;
@ -40,6 +41,8 @@ static void event_handler(lv_event_t * e)
}
void *user_base_task(void *arguments) {
UNUSED(arguments);
while(g_running && !g_lvgl_ready) {
sleep(1);
}

View File

@ -1,5 +1,6 @@
#include <stdint.h>
#include "user_common.h"
#include "tasks/user_task_lvgl_common.h"
pthread_t user_clock_task_thread;
@ -32,6 +33,8 @@ int user_clock_task_deinit(void) {
}
void *user_clock_task(void *arguments) {
UNUSED(arguments);
while(g_running && !g_lvgl_ready) {
sleep(1);
}

View File

@ -1,5 +1,6 @@
#include <stdint.h>
#include "user_common.h"
#include "impl/user_bme280_impl.h"
#include "tasks/user_task_lvgl_common.h"
#include "tasks/user_task_mqtt_common.h"
@ -25,6 +26,8 @@ int user_dht_task_deinit(void) {
}
void *user_dht_task(void *arguments) {
UNUSED(arguments);
while(g_running && !g_lvgl_ready) {
sleep(1);
}

View File

@ -1,5 +1,5 @@
#include "user_common.h"
#include "tasks/user_task_lvgl_common.h"
#include "impl/user_lvgl_impl.h"
#define PIXBUF_SIZE 320 * 20
@ -92,6 +92,7 @@ int user_lvgl_task_deinit(void) {
}
void *user_lv_task(void *arguments) {
UNUSED(arguments);
while(g_running) {
usleep(30 * 1000);
@ -104,6 +105,8 @@ void *user_lv_task(void *arguments) {
}
void *user_lv_tick(void *arguments) {
UNUSED(arguments);
while(g_running) {
usleep(30 * 1000);
pthread_mutex_lock(&g_lvgl_mutex);

View File

@ -1,5 +1,5 @@
#include "user_common.h"
#include "tasks/user_task_lvgl_common.h"
#include "impl/user_mqtt_impl.h"
static user_mqtt_impl_t s_mqtt_impl;
@ -41,6 +41,8 @@ int user_mqtt_task_deinit(void) {
}
void *user_mqtt_task(void *arguments) {
UNUSED(arguments);
user_mqtt_impl_init(&s_mqtt_impl);
mqtt_influx_init(&g_mqtt_influx);

View File

@ -1,7 +1,7 @@
#include <stdint.h>
#include "user_common.h"
#include "impl/user_ccs811_impl.h"
#include "tasks/user_task_lvgl_common.h"
void *user_tvoc_task(void *arguments);
@ -25,6 +25,7 @@ int user_tvoc_task_deinit(void) {
}
void *user_tvoc_task(void *arguments) {
UNUSED(arguments);
user_ccs811_impl_t impl;

View File

@ -15,4 +15,4 @@ int user_system_get_systemd_unique_id(char *uuid) {
close(machid_fd);
return 0;
}
}