From af8e79c39eab9a7993e331a07e664112a6d07715 Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Sun, 13 Apr 2014 20:41:46 +0100 Subject: [PATCH] settings: return NULL if no settings path is set --- src/epggrab/module.c | 3 +-- src/settings.c | 2 +- src/timeshift/timeshift_filemgr.c | 18 ++++++++++-------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/epggrab/module.c b/src/epggrab/module.c index da0ac173..a0de9011 100644 --- a/src/epggrab/module.c +++ b/src/epggrab/module.c @@ -428,8 +428,7 @@ epggrab_module_ext_t *epggrab_module_ext_create if (!skel) skel = calloc(1, sizeof(epggrab_module_ext_t)); /* Pass through */ - snprintf(path, 512, "%s/epggrab/%s.sock", - hts_settings_get_root(), sockid); + hts_settings_buildpath(path, sizeof(path), "epggrab/%s.sock", sockid); epggrab_module_int_create((epggrab_module_int_t*)skel, id, name, priority, path, NULL, parse, trans, diff --git a/src/settings.c b/src/settings.c index 651d9190..6b1b6b40 100644 --- a/src/settings.c +++ b/src/settings.c @@ -41,7 +41,7 @@ static char *settingspath = NULL; const char * hts_settings_get_root(void) { - return settingspath ?: "No settings dir"; + return settingspath; } /** diff --git a/src/timeshift/timeshift_filemgr.c b/src/timeshift/timeshift_filemgr.c index aa55c8e4..ee6ebcc9 100644 --- a/src/timeshift/timeshift_filemgr.c +++ b/src/timeshift/timeshift_filemgr.c @@ -110,15 +110,16 @@ static void timeshift_reaper_remove ( timeshift_file_t *tsf ) * * TODO: should this be fixed on startup? */ -static void timeshift_filemgr_get_root ( char *buf, size_t len ) +static int +timeshift_filemgr_get_root ( char *buf, size_t len ) { const char *path = timeshift_path; if (!path || !*path) { - path = hts_settings_get_root(); - snprintf(buf, len, "%s/timeshift/buffer", path); + return hts_settings_buildpath(buf, len, "timeshift/buffer"); } else { snprintf(buf, len, "%s/buffer", path); } + return 0; } /* @@ -126,7 +127,8 @@ static void timeshift_filemgr_get_root ( char *buf, size_t len ) */ int timeshift_filemgr_makedirs ( int index, char *buf, size_t len ) { - timeshift_filemgr_get_root(buf, len); + if (timeshift_filemgr_get_root(buf, len)) + return 1; snprintf(buf+strlen(buf), len-strlen(buf), "/%d", index); return makedirs(buf, 0700); } @@ -333,8 +335,8 @@ void timeshift_filemgr_init ( void ) char path[512]; /* Try to remove any rubbish left from last run */ - timeshift_filemgr_get_root(path, sizeof(path)); - rmtree(path); + if(!timeshift_filemgr_get_root(path, sizeof(path))) + rmtree(path); /* Size processing */ timeshift_total_size = 0; @@ -363,8 +365,8 @@ void timeshift_filemgr_term ( void ) pthread_join(timeshift_reaper_thread, NULL); /* Remove the lot */ - timeshift_filemgr_get_root(path, sizeof(path)); - rmtree(path); + if (!timeshift_filemgr_get_root(path, sizeof(path))) + rmtree(path); }