[vfs] minor fsnotifier (Linux) cleanup/optimization

This commit is contained in:
Roman Shevchenko
2016-02-18 14:04:55 +01:00
parent f5a354fdae
commit b3e2ed3518
7 changed files with 22 additions and 24 deletions
Binary file not shown.
Binary file not shown.
+4 -6
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,8 +14,9 @@
* limitations under the License.
*/
#ifndef __FSNOTIFIER_H
#define __FSNOTIFIER_H
#pragma once
#define VERSION "20160218.1348"
#include <stdbool.h>
#include <stdio.h>
@@ -82,6 +83,3 @@ char* read_line(FILE* stream);
// path comparison
bool is_parent_path(const char* parent_path, const char* child_path);
#endif
+7 -7
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
#include <dirent.h>
#include <errno.h>
#include <linux/limits.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -27,9 +27,9 @@
#include <syslog.h>
#include <unistd.h>
#if defined __i386__
#if defined(__i386__)
__asm__(".symver memcpy,memcpy@GLIBC_2.0");
#elif defined __amd64__
#elif defined(__amd64__)
__asm__(".symver memcpy,memcpy@GLIBC_2.2.5");
#endif
@@ -43,7 +43,7 @@ typedef struct __watch_node {
struct __watch_node* parent;
array* kids;
int path_len;
char path[0];
char path[];
} watch_node;
static int inotify_fd = -1;
@@ -112,12 +112,12 @@ static void read_watch_descriptors_count() {
}
inline void set_inotify_callback(void (* _callback)(const char*, int)) {
void set_inotify_callback(void (* _callback)(const char*, int)) {
callback = _callback;
}
inline int get_inotify_fd() {
int get_inotify_fd() {
return inotify_fd;
}
+2 -4
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,8 +36,6 @@
#define LOG_ENV_ERROR "error"
#define LOG_ENV_OFF "off"
#define VERSION "20130715.1353"
#define VERSION_MSG "fsnotifier " VERSION "\n"
#define USAGE_MSG \
"fsnotifier - IntelliJ IDEA companion program for watching and reporting file and directory structure modifications.\n\n" \
@@ -93,7 +91,7 @@ int main(int argc, char** argv) {
return 0;
}
else if (strcmp(argv[1], "--version") == 0) {
printf(VERSION_MSG);
printf("fsnotifier " VERSION "\n");
return 0;
}
else if (strcmp(argv[1], "--selftest") == 0) {
+4 -1
View File
@@ -1,6 +1,9 @@
#!/bin/sh
CC_FLAGS="-O3 -Wall -std=c99 -D_DEFAULT_SOURCE"
CC_FLAGS="-O2 -Wall -Wextra -Wpedantic -std=c11 -D_DEFAULT_SOURCE"
VER=$(date "+%Y%m%d.%H%M")
sed -i.bak "s/#define VERSION .*/#define VERSION \"${VER}\"/" fsnotifier.h && rm fsnotifier.h.bak
if [ -f "/usr/include/gnu/stubs-32.h" ] ; then
echo "compiling 32-bit version"
+5 -6
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,12 +43,12 @@ static bool array_realloc(array* a) {
}
array* array_create(int initial_capacity) {
array* a = (array*) malloc(sizeof(array));
array* a = calloc(1, sizeof(array));
if (a == NULL) {
return NULL;
}
a->data = calloc(sizeof(void*), initial_capacity);
a->data = calloc(initial_capacity, sizeof(void*));
if (a->data == NULL) {
free(a);
return NULL;
@@ -131,17 +131,16 @@ struct __table {
};
table* table_create(int capacity) {
table* t = malloc(sizeof(table));
table* t = calloc(1, sizeof(table));
if (t == NULL) {
return NULL;
}
t->data = calloc(sizeof(void*), capacity);
t->data = calloc(capacity, sizeof(void*));
if (t->data == NULL) {
free(t);
return NULL;
}
memset(t->data, 0, sizeof(void*) * capacity);
t->capacity = capacity;