#include <sys/inotify.h>
#endif
-#include "../src/guestfs_protocol.h"
+#include "guestfs_protocol.h"
#include "daemon.h"
#include "actions.h"
#include "optgroups.h"
#ifdef HAVE_SYS_INOTIFY_H
FILE *fp;
- NEED_ROOT (return -1);
+ NEED_ROOT (, return -1);
if (max_events < 0) {
reply_with_error ("max_events < 0");
char **ret = NULL;
int size = 0, alloc = 0;
unsigned int i;
- FILE *fp;
+ FILE *fp = NULL;
guestfs_int_inotify_event_list *events;
char buf[PATH_MAX];
if (len > 0 && buf[len-1] == '\n')
buf[len-1] = '\0';
- if (add_string (&ret, &size, &alloc, buf) == -1) {
- fclose (fp);
+ if (add_string (&ret, &size, &alloc, buf) == -1)
goto error;
- }
}
fclose (fp);
+ fp = NULL;
if (add_string (&ret, &size, &alloc, NULL) == -1)
goto error;
return ret;
error:
+ if (fp != NULL)
+ fclose (fp);
+
unlink ("/tmp/inotify");
return NULL;
#else