Cleanup (fsnotifier/Linux compilation warnings)

GitOrigin-RevId: d1c36b2ce855af75ed33f7e08dfaeb2444ef09f5
This commit is contained in:
Roman Shevchenko
2023-01-12 14:59:30 +01:00
committed by intellij-monorepo-bot
parent c7da24cd84
commit f93937d167
4 changed files with 29 additions and 27 deletions

2
native/fsNotifier/linux/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/.idea/
/fsnotifier

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
#pragma once
@@ -56,14 +56,14 @@ enum {
ERR_MISSING = -4
};
bool init_inotify();
bool init_inotify(void);
void set_inotify_callback(void (*callback)(const char *, uint32_t));
int get_inotify_fd();
int get_inotify_fd(void);
int watch(const char* root, array* mounts);
void unwatch(int id);
bool process_inotify_input();
void close_inotify();
bool process_inotify_input(void);
void close_inotify(void);
// reads one line from stream, trims trailing carriage return if any

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
#include "fsnotifier.h"
@@ -37,11 +37,11 @@ static char event_buf[EVENT_BUF_LEN];
static char path_buf[2 * PATH_MAX];
static void read_watch_descriptors_count();
static void watch_limit_reached();
static void read_watch_descriptors_count(void);
static void watch_limit_reached(void);
bool init_inotify() {
bool init_inotify(void) {
inotify_fd = inotify_init();
if (inotify_fd < 0) {
int e = errno;
@@ -71,7 +71,7 @@ bool init_inotify() {
return true;
}
static void read_watch_descriptors_count() {
static void read_watch_descriptors_count(void) {
FILE* f = fopen(WATCH_COUNT_NAME, "r");
if (f == NULL) {
userlog(LOG_ERR, "can't open %s: %s", WATCH_COUNT_NAME, strerror(errno));
@@ -95,7 +95,7 @@ void set_inotify_callback(void (* _callback)(const char*, uint32_t)) {
}
int get_inotify_fd() {
int get_inotify_fd(void) {
return inotify_fd;
}
@@ -170,7 +170,7 @@ static int add_watch(unsigned int path_len, watch_node* parent) {
return wd;
}
static void watch_limit_reached() {
static void watch_limit_reached(void) {
if (!limit_reached) {
limit_reached = true;
message("inotify.watch.limit");
@@ -372,7 +372,7 @@ static bool process_inotify_event(struct inotify_event* event) {
}
bool process_inotify_input() {
bool process_inotify_input(void) {
ssize_t len = read(inotify_fd, event_buf, EVENT_BUF_LEN);
if (len < 0) {
userlog(LOG_ERR, "read: %s", strerror(errno));
@@ -401,7 +401,7 @@ bool process_inotify_input() {
}
void close_inotify() {
void close_inotify(void) {
if (watches != NULL) {
table_delete(watches);
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
#include "fsnotifier.h"
@@ -35,17 +35,17 @@ static array* roots = NULL;
static bool self_test = false;
static void run_self_test();
static bool main_loop();
static int read_input();
static void run_self_test(void);
static bool main_loop(void);
static int read_input(void);
static bool update_roots(array* new_roots);
static void unregister_roots();
static void unregister_roots(void);
static bool register_roots(array* new_roots, array* unwatchable, array* mounts);
static array* unwatchable_mounts();
static array* unwatchable_mounts(void);
static void inotify_callback(const char* path, uint32_t event);
static void report_event(const char* event, const char* path);
static void output(const char* line, bool flush);
static void check_missing_roots();
static void check_missing_roots(void);
static void check_root_removal(const char*);
@@ -123,7 +123,7 @@ void userlog(int level, const char* format, ...) {
}
static void run_self_test() {
static void run_self_test(void) {
array* test_roots = array_create(1);
char* cwd = malloc(PATH_MAX);
if (getcwd(cwd, PATH_MAX) == NULL) {
@@ -134,7 +134,7 @@ static void run_self_test() {
}
static bool main_loop() {
static bool main_loop(void) {
int input_fd = fileno(stdin), inotify_fd = get_inotify_fd();
int nfds = (inotify_fd > input_fd ? inotify_fd : input_fd) + 1;
fd_set rfds;
@@ -169,7 +169,7 @@ static bool main_loop() {
}
static int read_input() {
static int read_input(void) {
char* line = read_line(stdin);
if (line == NULL || strcmp(line, "EXIT") == 0) {
return 0;
@@ -242,7 +242,7 @@ static bool update_roots(array* new_roots) {
}
static void unregister_roots() {
static void unregister_roots(void) {
watch_root* root;
while ((root = array_pop(roots)) != NULL) {
userlog(LOG_INFO, "unregistering root: %s", root->path);
@@ -318,7 +318,7 @@ static bool is_watchable(const char* fs) {
(strncmp(fs, "fuse", 4) == 0 && strcmp(fs + 4, "blk") != 0 && strcmp(fs + 4, ".osxfs") != 0));
}
static array* unwatchable_mounts() {
static array* unwatchable_mounts(void) {
FILE* mtab = setmntent(_PATH_MOUNTED, "r");
if (mtab == NULL && errno == ENOENT) {
mtab = setmntent("/proc/mounts", "r");
@@ -402,7 +402,7 @@ static void output(const char* line, bool flush) {
}
static void check_missing_roots() {
static void check_missing_roots(void) {
struct stat st;
for (int i = 0; i < array_size(roots); i++) {
watch_root* root = array_get(roots, i);