refactor: Add clang-tidy checks and simplify codebase

This commit is contained in:
Utkarsh Verma
2023-11-16 09:08:29 +05:30
parent f18100c2ee
commit c166ffe0b4
17 changed files with 130 additions and 78 deletions

View File

@@ -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