aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--libinotifytools/src/Makefile.am2
-rw-r--r--libinotifytools/src/redblack.c1
-rw-r--r--libinotifytools/src/redblack.h2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/common.c19
-rw-r--r--src/inotifywatch.c27
7 files changed, 27 insertions, 27 deletions
diff --git a/README.md b/README.md
index f3b45dd..9d8d5d1 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
[![GitHub Build Status](https://github.com/inotify-tools/inotify-tools/workflows/build/badge.svg)](https://github.com/inotify-tools/inotify-tools/actions)
[![Travis Build Status](https://travis-ci.org/inotify-tools/inotify-tools.svg?branch=master)](https://travis-ci.org/inotify-tools/inotify-tools)
[![Cirrus Build Status](https://api.cirrus-ci.com/github/inotify-tools/inotify-tools.svg?branch=master)](https://cirrus-ci.com/github/inotify-tools/inotify-tools)
+[![Language Grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/inotify-tools/inotify-tools.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/inotify-tools/inotify-tools/context:cpp)
inotify-tools
=============
diff --git a/libinotifytools/src/Makefile.am b/libinotifytools/src/Makefile.am
index b5c7ff2..d7fa03a 100644
--- a/libinotifytools/src/Makefile.am
+++ b/libinotifytools/src/Makefile.am
@@ -14,7 +14,7 @@ EXTRA_DIST = example.c Doxyfile
nobase_include_HEADERS = inotifytools/inotifytools.h inotifytools/inotify-nosys.h inotifytools/inotify.h
-AM_CFLAGS = -std=c99 -Wall -Werror
+AM_CFLAGS = -std=c99 -Wall -Wshadow -Werror
if DOXYGEN_ENABLE
diff --git a/libinotifytools/src/redblack.c b/libinotifytools/src/redblack.c
index 677ae82..4f1e5f0 100644
--- a/libinotifytools/src/redblack.c
+++ b/libinotifytools/src/redblack.c
@@ -292,7 +292,6 @@ RB_ENTRY(_traverse)(int insert, const RB_ENTRY(data_t) *key, struct RB_ENTRY(tre
struct RB_ENTRY(node) *x,*y,*z;
int cmp;
int found=0;
- int cmpmods();
y=RBNULL; /* points to the parent of x */
x=rbinfo->rb_root;
diff --git a/libinotifytools/src/redblack.h b/libinotifytools/src/redblack.h
index 1a94da2..e836be0 100644
--- a/libinotifytools/src/redblack.h
+++ b/libinotifytools/src/redblack.h
@@ -27,6 +27,7 @@
/* Stop multiple includes */
#ifndef _REDBLACK_H
+#define _REDBLACK_H
#ifndef RB_CUSTOMIZE
/*
@@ -132,7 +133,6 @@ RB_STATIC void RB_ENTRY(closelist)(RBLIST *);
#define rbmin(rbinfo) RB_ENTRY(lookup)(RB_LUFIRST, NULL, (rbinfo))
#define rbmax(rbinfo) RB_ENTRY(lookup)(RB_LULAST, NULL, (rbinfo))
-#define _REDBLACK_H
#endif /* _REDBLACK_H */
/*
diff --git a/src/Makefile.am b/src/Makefile.am
index 7de3c45..0a53584 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,7 +2,7 @@ bin_PROGRAMS = inotifywait inotifywatch
inotifywait_SOURCES = inotifywait.c common.c common.h
inotifywatch_SOURCES = inotifywatch.c common.c common.h
-AM_CFLAGS = -Wall -Wextra -Wpointer-arith -Werror -std=c99 -I../libinotifytools/src
+AM_CFLAGS = -Wall -Wextra -Wshadow -Wpointer-arith -Werror -std=c99 -I../libinotifytools/src
AM_CPPFLAGS = -I$(top_srcdir)/libinotifytools/src
LDADD = ../libinotifytools/src/libinotifytools.la
diff --git a/src/common.c b/src/common.c
index 91c80a9..f203fbd 100644
--- a/src/common.c
+++ b/src/common.c
@@ -62,11 +62,12 @@ FileList construct_path_list(int argc, char **argv, char const *filename) {
list.exclude_files = 0;
FILE *file = 0;
- if (!filename) {
- } else if (!strcmp(filename, "-")) {
- file = stdin;
- } else {
- file = fopen(filename, "r");
+ if (filename) {
+ if (!strcmp(filename, "-")) {
+ file = stdin;
+ } else {
+ file = fopen(filename, "r");
+ }
}
int watch_len = LIST_CHUNK;
@@ -136,8 +137,8 @@ void warn_inotify_init_error() {
}
}
-bool is_timeout_option_valid(long int *timeout, char *optarg) {
- if ((optarg == NULL) || (*optarg == '\0')) {
+bool is_timeout_option_valid(long int *timeout, char *o) {
+ if ((o == NULL) || (*o == '\0')) {
fprintf(stderr, "The provided value is not a valid timeout value.\n"
"Please specify a long int value.\n");
return false;
@@ -145,7 +146,7 @@ bool is_timeout_option_valid(long int *timeout, char *optarg) {
char *timeout_end = NULL;
errno = 0;
- *timeout = strtol(optarg, &timeout_end, 10);
+ *timeout = strtol(o, &timeout_end, 10);
const int err = errno;
if (err != 0) {
@@ -172,7 +173,7 @@ bool is_timeout_option_valid(long int *timeout, char *optarg) {
if (*timeout_end != '\0') {
fprintf(stderr, "'%s' is not a valid timeout value.\n"
"Please specify a long int value.\n",
- optarg);
+ o);
return false;
}
diff --git a/src/inotifywatch.c b/src/inotifywatch.c
index 92b639f..8993554 100644
--- a/src/inotifywatch.c
+++ b/src/inotifywatch.c
@@ -1,4 +1,3 @@
-// FIXME this is cheating! Make this use only the public API.
#include "../config.h"
#include "../libinotifytools/src/inotifytools_p.h"
#include "common.h"
@@ -362,17 +361,17 @@ int print_info() {
return EXIT_SUCCESS;
}
-bool parse_opts(int *argc, char ***argv, int *events, long int *timeout,
- int *verbose, int *zero, int *sort, int *recursive,
+bool parse_opts(int *argc, char ***argv, int *e, long int *timeout,
+ int *verbose, int *z, int *s, int *recursive,
char **fromfile, char **exc_regex, char **exc_iregex,
char **inc_regex, char **inc_iregex) {
assert(argc);
assert(argv);
- assert(events);
+ assert(e);
assert(timeout);
assert(verbose);
- assert(zero);
- assert(sort);
+ assert(z);
+ assert(s);
assert(recursive);
assert(fromfile);
assert(exc_regex);
@@ -430,7 +429,7 @@ bool parse_opts(int *argc, char ***argv, int *events, long int *timeout,
// --zero or -z
case 'z':
- ++(*zero);
+ ++(*z);
break;
// --exclude
@@ -484,7 +483,7 @@ bool parse_opts(int *argc, char ***argv, int *events, long int *timeout,
}
// Add the new event to the event mask
- (*events) = ((*events) | new_event);
+ (*e) = ((*e) | new_event);
break;
@@ -495,7 +494,7 @@ bool parse_opts(int *argc, char ***argv, int *events, long int *timeout,
return false;
}
if (0 == strcasecmp(optarg, "total")) {
- (*sort) = 0;
+ (*s) = 0;
} else if (0 == strcasecmp(optarg, "move")) {
fprintf(stderr, "Cannot sort by `move' event; please use "
"`moved_from' or `moved_to'.\n");
@@ -515,7 +514,7 @@ bool parse_opts(int *argc, char ***argv, int *events, long int *timeout,
return false;
}
- (*sort) = event;
+ (*s) = event;
}
sort_set = true;
break;
@@ -527,7 +526,7 @@ bool parse_opts(int *argc, char ***argv, int *events, long int *timeout,
return false;
}
if (0 == strcasecmp(optarg, "total")) {
- (*sort) = -1;
+ (*s) = -1;
} else {
int event = inotifytools_str_to_event(optarg);
@@ -539,7 +538,7 @@ bool parse_opts(int *argc, char ***argv, int *events, long int *timeout,
return false;
}
- (*sort) = -event;
+ (*s) = -event;
}
break;
}
@@ -550,8 +549,8 @@ bool parse_opts(int *argc, char ***argv, int *events, long int *timeout,
(*argc) -= optind;
*argv = &(*argv)[optind];
- if ((*sort) != 0 && (*sort) != -1 &&
- !(abs(*sort) & ((*events) ? (*events) : IN_ALL_EVENTS))) {
+ if ((*s) != 0 && (*s) != -1 &&
+ !(abs(*s) & ((*e) ? (*e) : IN_ALL_EVENTS))) {
fprintf(stderr, "Can't sort by an event which isn't being watched "
"for!\n");
return false;