summaryrefslogtreecommitdiff
path: root/common/inotify_helpers.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/inotify_helpers.c')
-rw-r--r--common/inotify_helpers.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/common/inotify_helpers.c b/common/inotify_helpers.c
index 781843e..1b4b930 100644
--- a/common/inotify_helpers.c
+++ b/common/inotify_helpers.c
@@ -1,5 +1,6 @@
+#include <string.h> /* for strlen(3), memcpy(3) */
#include <stdio.h> /* for printf(3) */
-#include <stdlib.h> /* for realloc(3), memcpy(3) */
+#include <stdlib.h> /* for realloc(3) */
#include <unistd.h> /* for read(2) */
#include "inotify_helpers.h"
@@ -75,7 +76,7 @@ inotify_mask2str(uint32_t mask) {
if (mask & (1 << i)) {
if (out.len > 0)
strbufcat(&out, " | ");
- strbufcat(&out, in_bits[i]);
+ strbufcat(&out, in_mask_bits[i]);
}
}
return out.str;
@@ -85,16 +86,19 @@ inotify_mask2str(uint32_t mask) {
int
inotify_print_event(struct inotify_event *event) {
- return printf("wd:%d\n"
- "\tmask:[%s]\n"
- "\tcookie:%u\n"
- "\tlen:%u\n"
- "\tname:%s\n",
- event->wd,
- mask2str(event->mask),
- event->cookie,
- event->len,
- event->len > 0 ? event->name : "");
+ char *mask = inotify_mask2str(event->mask);
+ int ret = printf("wd:%d\n"
+ "\tmask:[%s]\n"
+ "\tcookie:%u\n"
+ "\tlen:%u\n"
+ "\tname:%s\n",
+ event->wd,
+ mask,
+ event->cookie,
+ event->len,
+ event->len > 0 ? event->name : "");
+ free(mask);
+ return ret;
}