refactor: Add clang-tidy checks and simplify codebase
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef BLOCK_H
|
||||
#define BLOCK_H
|
||||
|
||||
#include <bits/stdint-uintn.h>
|
||||
#include <stdbool.h>
|
||||
@@ -24,3 +25,5 @@ int block_deinit(block *const block);
|
||||
int block_execute(block *const block, const uint8_t button);
|
||||
int block_update(block *const block);
|
||||
bool block_must_run(const block *const block, const unsigned int time);
|
||||
|
||||
#endif // BLOCK_H
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef CLI_H
|
||||
#define CLI_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
@@ -8,3 +9,5 @@ typedef struct {
|
||||
|
||||
int cli_init(cli_arguments* const args, const char* const argv[],
|
||||
const int argc);
|
||||
|
||||
#endif // CLI_H
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef MAIN_H
|
||||
#define MAIN_H
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
@@ -11,3 +12,5 @@
|
||||
#define X(...) "."
|
||||
enum { BLOCK_COUNT = LEN(BLOCKS(X)) - 1 };
|
||||
#undef X
|
||||
|
||||
#endif // MAIN_H
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef SIGNAL_HANDLER_H
|
||||
#define SIGNAL_HANDLER_H
|
||||
|
||||
#include <bits/types/sigset_t.h>
|
||||
|
||||
@@ -28,3 +29,5 @@ signal_handler signal_handler_new(
|
||||
int signal_handler_init(signal_handler* const handler);
|
||||
int signal_handler_deinit(signal_handler* const handler);
|
||||
int signal_handler_process(signal_handler* const handler, timer* const timer);
|
||||
|
||||
#endif // SIGNAL_HANDLER_H
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef STATUS_H
|
||||
#define STATUS_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
@@ -26,3 +27,5 @@ status status_new(const block* const blocks, const unsigned short block_count);
|
||||
bool status_update(status* const status);
|
||||
int status_write(const status* const status, const bool is_debug_mode,
|
||||
x11_connection* const connection);
|
||||
|
||||
#endif // STATUS_H
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef TIMER_H
|
||||
#define TIMER_H
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
@@ -14,3 +15,5 @@ typedef struct {
|
||||
|
||||
timer timer_new(const block *const blocks, const unsigned short block_count);
|
||||
int timer_arm(timer *const timer);
|
||||
|
||||
#endif // TIMER_H
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
#pragma once
|
||||
#ifndef UTIL_H
|
||||
#define UTIL_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define LEN(arr) (sizeof(arr) / sizeof(arr[0]))
|
||||
#define BIT(n) (1 << (n))
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define LEN(arr) (sizeof(arr) / sizeof((arr)[0]))
|
||||
#define BIT(n) (1 << (n))
|
||||
|
||||
// NOLINTBEGIN(bugprone-macro-parentheses)
|
||||
#define MEMBER_SIZE(type, member) sizeof(((type*)NULL)->member)
|
||||
#define MEMBER_LENGTH(type, member) \
|
||||
(MEMBER_SIZE(type, member) / MEMBER_SIZE(type, member[0]))
|
||||
// NOLINTEND(bugprone-macro-parentheses)
|
||||
|
||||
#define UTF8_MAX_BYTE_COUNT 4
|
||||
|
||||
@@ -20,3 +24,5 @@ enum pipe_fd_index {
|
||||
unsigned int gcd(unsigned int a, unsigned int b);
|
||||
size_t truncate_utf8_string(char* const buffer, const size_t size,
|
||||
const size_t char_limit);
|
||||
|
||||
#endif // UTIL_H
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef WATCHER_H
|
||||
#define WATCHER_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <sys/poll.h>
|
||||
@@ -6,22 +7,22 @@
|
||||
#include "block.h"
|
||||
#include "main.h"
|
||||
|
||||
typedef enum {
|
||||
enum watcher_fd_index {
|
||||
SIGNAL_FD = BLOCK_COUNT,
|
||||
WATCHER_FD_COUNT,
|
||||
} watcher_fd_index;
|
||||
};
|
||||
|
||||
typedef struct pollfd watcher_fd;
|
||||
|
||||
typedef struct {
|
||||
watcher_fd fds[WATCHER_FD_COUNT];
|
||||
|
||||
const block *const blocks;
|
||||
const unsigned short block_count;
|
||||
unsigned short active_blocks[BLOCK_COUNT];
|
||||
unsigned short active_block_count;
|
||||
bool got_signal;
|
||||
} watcher;
|
||||
|
||||
watcher watcher_new(const block *const blocks,
|
||||
const unsigned short block_count);
|
||||
int watcher_init(watcher *const watcher, const int signal_fd);
|
||||
int watcher_init(watcher *const watcher, const block *const blocks,
|
||||
const unsigned short block_count, const int signal_fd);
|
||||
int watcher_poll(watcher *const watcher, const int timeout_ms);
|
||||
bool watcher_fd_is_readable(const watcher_fd *const watcher_fd);
|
||||
|
||||
#endif // WATCHER_H
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef X11_H
|
||||
#define X11_H
|
||||
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
@@ -8,3 +9,5 @@ x11_connection* x11_connection_open(void);
|
||||
void x11_connection_close(x11_connection* const connection);
|
||||
int x11_set_root_name(x11_connection* const connection,
|
||||
const char* const name);
|
||||
|
||||
#endif // X11_H
|
||||
|
||||
Reference in New Issue
Block a user