diff --git a/callbacks.c b/callbacks.c index 662223b..ba7e84b 100644 --- a/callbacks.c +++ b/callbacks.c @@ -82,10 +82,12 @@ cb_view_vadjustment_value_changed(GtkAdjustment *adjustment, gpointer data) } void -cb_pages_per_row_value_changed(girara_session_t* UNUSED(session), girara_setting_t* setting) +cb_pages_per_row_value_changed(girara_session_t* UNUSED(session), const char* UNUSED(name), girara_setting_type_t UNUSED(type), void* value, void* data) { - int pages_per_row = setting->value.i; - zathura_t* zathura = setting->data; + g_return_if_fail(value != NULL); + + int pages_per_row = *(int*) value; + zathura_t* zathura = data; if (pages_per_row < 1) { pages_per_row = 1; diff --git a/callbacks.h b/callbacks.h index cfa7e20..373443a 100644 --- a/callbacks.h +++ b/callbacks.h @@ -39,7 +39,7 @@ void cb_view_vadjustment_value_changed(GtkAdjustment *adjustment, gpointer data) * @param session The current girara session * @param setting The "pages-per-row" setting */ -void cb_pages_per_row_value_changed(girara_session_t* session, girara_setting_t* setting); +void cb_pages_per_row_value_changed(girara_session_t* UNUSED(session), const char* UNUSED(name), girara_setting_type_t UNUSED(type), void* value, void* data); /** * Called when an index element is activated (e.g.: double click) diff --git a/database-plain.c b/database-plain.c index 411646a..65ee461 100644 --- a/database-plain.c +++ b/database-plain.c @@ -1,5 +1,7 @@ /* See LICENSE file for license and copyright information */ +#define _POSIX_SOURCE + #include #include #include @@ -295,28 +297,26 @@ zathura_db_read_key_file_from_file(const char* path) } /* open file */ - int fd = open(path, O_RDWR); - if (fd == -1) { + FILE* file = fopen(path, "r"); + if (file == NULL) { return NULL; } GKeyFile* key_file = g_key_file_new(); if (key_file == NULL) { - close(fd); + fclose(file); return NULL; } /* read config file */ - file_lock_set(fd, F_WRLCK); - char* content = girara_file_read_from_fd(fd); + file_lock_set(fileno(file), F_WRLCK); + char* content = girara_file_read2(file); + file_lock_set(fileno(file), F_UNLCK); + fclose(file); if (content == NULL) { - file_lock_set(fd, F_UNLCK); - close(fd); + g_key_file_free(key_file); return NULL; } - file_lock_set(fd, F_UNLCK); - - close(fd); /* parse config file */ size_t contentlen = strlen(content); @@ -369,7 +369,9 @@ zathura_db_write_key_file_to_file(const char* file, GKeyFile* key_file) } file_lock_set(fd, F_WRLCK); - write(fd, content, strlen(content)); + if (write(fd, content, strlen(content)) == 0) { + girara_error("Failed to write to %s", file); + } file_lock_set(fd, F_UNLCK); close(fd); diff --git a/document.c b/document.c index f96e1dd..de7f0ab 100644 --- a/document.c +++ b/document.c @@ -42,6 +42,7 @@ zathura_document_plugins_load(zathura_t* zathura) DIR* dir = opendir(plugindir); if (dir == NULL) { girara_error("could not open plugin directory: %s", plugindir); + girara_list_iterator_next(iter); continue; } diff --git a/shortcuts.c b/shortcuts.c index 6c5675c..c9bbf0a 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -504,7 +504,7 @@ sc_toggle_fullscreen(girara_session_t* session, girara_argument_t* int* tmp = girara_setting_get(session, "pages-per-row"); if (tmp != NULL) { pages_per_row = *tmp; - free(tmp); + g_free(tmp); } /* set single view */ diff --git a/zathura.h b/zathura.h index cd8b7be..f0ae1b7 100644 --- a/zathura.h +++ b/zathura.h @@ -5,16 +5,10 @@ #include #include +#include #include -#ifdef UNUSED -#elif defined(__GNUC__) -# define UNUSED(x) UNUSED_ ## x __attribute__((unused)) -#elif defined(__LCINT__) -# define UNUSED(x) /*@unused@*/ x -#else -# define UNUSED(x) x -#endif +#define UNUSED(x) GIRARA_UNUSED(x) enum { NEXT, PREVIOUS, LEFT, RIGHT, UP, DOWN, BOTTOM, TOP, HIDE, HIGHLIGHT, DELETE_LAST_WORD, DELETE_LAST_CHAR, DEFAULT, ERROR, WARNING, NEXT_GROUP,