/* if stat fails, just try to read the file */
if (stat(path, &st) == 0) {
/* Don't re-read file if file is unchanged */
- if (last_read == st.st_mtime)
- return 0;
+ if (last_read == st.st_mtime) {
+ err = 0;
+ goto errout;
+ }
}
- if (!(fd = fopen(path, "r")))
- return -NLE_PKTLOC_FILE;
+ if (!(fd = fopen(path, "r"))) {
+ err = -NLE_PKTLOC_FILE;
+ goto errout;
+ }
for (i = 0; i < PKTLOC_NAME_HT_SIZ; i++) {
struct rtnl_pktloc *loc, *n;
nl_init_list_head(&pktloc_name_ht[i]);
}
- if ((err = pktloc_lex_init(&scanner)) < 0)
- return -NLE_FAILURE;
+ if ((err = pktloc_lex_init(&scanner)) < 0) {
+ err = -NLE_FAILURE;
+ goto errout_close;
+ }
buf = pktloc__create_buffer(fd, YY_BUF_SIZE, scanner);
pktloc__switch_to_buffer(buf, scanner);
- if ((err = pktloc_parse(scanner)) < 0)
- return -NLE_FAILURE;
+ if ((err = pktloc_parse(scanner)) < 0) {
+ err = -NLE_FAILURE;
+ goto errout_scanner;
+ }
+ last_read = st.st_mtime;
+
+errout_scanner:
if (scanner)
pktloc_lex_destroy(scanner);
-
+errout_close:
+ fclose(fd);
+errout:
free(path);
- last_read = st.st_mtime;
- return 0;
+ return err;
}
/**
for (i = 0; i < PKTLOC_NAME_HT_SIZ; i++)
nl_init_list_head(&pktloc_name_ht[i]);
-
+
return 0;
}