{
char *sdir;
struct uci_element *e, *tmp;
- bool exists = false;
+ volatile bool exists = false;
UCI_HANDLE_ERR(ctx);
UCI_ASSERT(ctx, dir != NULL);
case UCI_CMD_LIST_ADD:
if (!ptr->option)
goto error;
+ /* fall through */
case UCI_CMD_LIST_DEL:
if (!ptr->option)
goto error;
static int uci_parse_delta(struct uci_context *ctx, FILE *stream, struct uci_package *p)
{
struct uci_parse_context *pctx;
- int changes = 0;
+ volatile int changes = 0;
/* make sure no memory from previous parse attempts is leaked */
uci_cleanup(ctx);
}
/* returns the number of changes that were successfully parsed */
-static int uci_load_delta_file(struct uci_context *ctx, struct uci_package *p, char *filename, FILE **f, bool flush)
+static int uci_load_delta_file(struct uci_context *ctx, struct uci_package *p, char *filename, FILE *volatile *f, bool flush)
{
- FILE *stream = NULL;
- int changes = 0;
+ FILE *volatile stream = NULL;
+ volatile int changes = 0;
UCI_TRAP_SAVE(ctx, done);
stream = uci_open_stream(ctx, filename, NULL, SEEK_SET, flush, false);
{
struct uci_element *e;
char *filename = NULL;
- FILE *f = NULL;
- int changes = 0;
+ FILE *volatile f = NULL;
+ volatile int changes = 0;
if (!p->has_delta)
return 0;
if ((asprintf(&filename, "%s/%s", ctx->savedir, p->e.name) < 0) || !filename)
UCI_THROW(ctx, UCI_ERR_MEM);
- UCI_TRAP_SAVE(ctx, done);
- f = uci_open_stream(ctx, filename, NULL, SEEK_SET, flush, false);
- UCI_TRAP_RESTORE(ctx);
+ uci_load_delta_file(ctx, NULL, filename, &f, flush);
if (flush && f && (changes > 0)) {
if (ftruncate(fileno(f), 0) < 0) {
}
}
-done:
free(filename);
uci_close_stream(f);
ctx->err = 0;
match = false;
}
- if (!match) {
+ if (!match && ptr.section) {
uci_add_delta(ctx, &list, c,
ptr.section, ptr.option, ptr.value);
}
int uci_revert(struct uci_context *ctx, struct uci_ptr *ptr)
{
- char *package = NULL;
- char *section = NULL;
- char *option = NULL;
+ char *volatile package = NULL;
+ char *volatile section = NULL;
+ char *volatile option = NULL;
UCI_HANDLE_ERR(ctx);
uci_expand_ptr(ctx, ptr, false);
int uci_save(struct uci_context *ctx, struct uci_package *p)
{
- FILE *f = NULL;
+ FILE *volatile f = NULL;
char *filename = NULL;
struct uci_element *e, *tmp;
struct stat statbuf;