Add Makefile with strict options

This commit is contained in:
olemorud
2023-03-20 11:32:51 +01:00
parent 9295a9445c
commit 7fbe0d2047
2 changed files with 25 additions and 4 deletions

14
Makefile Normal file
View File

@@ -0,0 +1,14 @@
CC = gcc
CFLAGS = -O3 -g -Wall -Wextra -Werror -std=gnu99 -pedantic
all: bin/exec_tracker
clean: bin
rm -f 'bin/exec_tracker'
bin/exec_tracker: exec_tracker.c bin
$(CC) -o $@ $(CFLAGS) $<
bin:
mkdir bin

View File

@@ -316,7 +316,7 @@ static void handle_event(int inotify_instance, int *watched, char **filenames,
p += sizeof(struct inotify_event) + event->len) {
event = (struct inotify_event *)p;
for (int i = 0; i < watched_len; i++) {
for (size_t i = 0; i < watched_len; i++) {
if (watched[i] == event->wd) {
fprintf(stderr, "%s ", filenames[i]);
counter[i] += 1;
@@ -326,9 +326,14 @@ static void handle_event(int inotify_instance, int *watched, char **filenames,
}
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
/* Prints event mask values in a human-readable format */
static void print_event(uint32_t event)
{
UNUSED(print_event);
if (event & IN_ACCESS) {
fprintf(stderr, "IN_ACCESS ");
}
@@ -363,9 +368,11 @@ static void print_event(uint32_t event)
fprintf(stderr, "IN_OPEN ");
}
}
#pragma GCC diagnostic pop
/* Saves number of recorded events for each
executable t 'uses.log' */
executable to 'uses.log' */
static void save_result(char **filenames, int *counter, size_t arr_len)
{
FILE *savefile;
@@ -381,8 +388,8 @@ static void save_result(char **filenames, int *counter, size_t arr_len)
if (counter[i] == 0)
continue;
// fprintf(stdout, "%d %s\n", counter[i], filenames[i]);
fprintf(savefile, "%d %s\n", counter[i], filenames[i]);
}
fclose(savefile);
}
}