time_t *end_seconds = (time_t *) (uint64_t *)&end; /* STFU, gcc */
char start_str[200], end_str[200];
- if (!localtime_r(start_seconds, &start_tm)) {
- make_err_msg("%lli", (long long)start);
+ if (!localtime_r(start_seconds, &start_tm))
return -E_LOCALTIME;
- }
- if (!localtime_r(end_seconds, &end_tm)) {
- make_err_msg("%lli", (long long)end);
+ if (!localtime_r(end_seconds, &end_tm))
return -E_LOCALTIME;
- }
- if (!strftime(start_str, sizeof(start_str), "%a_%b_%d_%Y_%H_%M_%S", &start_tm)) {
- make_err_msg("%lli", (long long)start);
+ if (!strftime(start_str, sizeof(start_str), "%a_%b_%d_%Y_%H_%M_%S", &start_tm))
return -E_STRFTIME;
- }
- if (!strftime(end_str, sizeof(end_str), "%a_%b_%d_%Y_%H_%M_%S", &end_tm)) {
- make_err_msg("%lli", (long long)end);
+ if (!strftime(end_str, sizeof(end_str), "%a_%b_%d_%Y_%H_%M_%S", &end_tm))
return -E_STRFTIME;
- }
*result = make_message("%lli-%lli.%s-%s", (long long) start, (long long) end,
start_str, end_str);
return 1;
kill(pid, SIGTERM);
}
if (ret < 0)
- make_err_msg("failed to wait for process %d", (int)pid);
+ DSS_ERROR_LOG("failed to wait for process %d\n", (int)pid);
else
log_termination_msg(pid, *status);
return ret;
int handle_rm_exit(int status)
{
- int es, ret;
-
- if (!WIFEXITED(status)) {
- make_err_msg("rm process %d died involuntary", (int)rm_pid);
- ret = -E_INVOLUNTARY_EXIT;
- goto out;
- }
- es = WEXITSTATUS(status);
- if (es) {
- make_err_msg("rm process %d returned %d", (int)rm_pid, es);
- ret = -E_BAD_EXIT_CODE;
- goto out;
- }
- ret = 1;
rm_pid = 0;
-out:
- return ret;
+ if (!WIFEXITED(status))
+ return -E_INVOLUNTARY_EXIT;
+ if (WEXITSTATUS(status))
+ return -E_BAD_EXIT_CODE;
+ return 1;
}
int wait_for_rm_process(void)
int check_config(void)
{
if (conf.unit_interval_arg <= 0) {
- make_err_msg("bad unit interval: %i", conf.unit_interval_arg);
+ DSS_ERROR_LOG("bad unit interval: %i\n", conf.unit_interval_arg);
return -E_INVALID_NUMBER;
}
DSS_DEBUG_LOG("unit interval: %i day(s)\n", conf.unit_interval_arg);
if (conf.num_intervals_arg <= 0) {
- make_err_msg("bad number of intervals %i", conf.num_intervals_arg);
+ DSS_ERROR_LOG("bad number of intervals %i\n", conf.num_intervals_arg);
return -E_INVALID_NUMBER;
}
DSS_DEBUG_LOG("number of intervals: %i\n", conf.num_intervals_arg);
ret = stat(config_file, &statbuf);
if (ret && conf.config_file_given) {
ret = -ERRNO_TO_DSS_ERROR(errno);
- make_err_msg("failed to stat config file %s", config_file);
+ DSS_ERROR_LOG("failed to stat config file %s\n", config_file);
goto out;
}
if (!ret) {
free(config_file);
if (ret >= 0)
return;
- log_err_msg(EMERG, -ret);
+ DSS_EMERG_LOG("%s\n", dss_strerror(-ret));
exit(EXIT_FAILURE);
}
int es, ret;
if (!WIFEXITED(status)) {
- make_err_msg("rsync process %d died involuntary", (int)rsync_pid);
+ DSS_ERROR_LOG("rsync process %d died involuntary\n", (int)rsync_pid);
ret = -E_INVOLUNTARY_EXIT;
snapshot_creation_status = SCS_READY;
compute_next_snapshot_time();
}
es = WEXITSTATUS(status);
if (es != 0 && es != 23 && es != 24) {
- make_err_msg("rsync process %d returned %d", (int)rsync_pid, es);
+ DSS_ERROR_LOG("rsync process %d returned %d\n", (int)rsync_pid, es);
ret = -E_BAD_EXIT_CODE;
snapshot_creation_status = SCS_READY;
compute_next_snapshot_time();
int es, ret;
if (!WIFEXITED(status)) {
- make_err_msg("pre-create-hook %d died involuntary",
- (int)pre_create_hook_pid);
snapshot_creation_status = SCS_READY;
compute_next_snapshot_time();
ret = -E_INVOLUNTARY_EXIT;
}
es = WEXITSTATUS(status);
if (es) {
- make_err_msg("pre-create-hook %d returned %d",
- (int)pre_create_hook_pid, es);
snapshot_creation_status = SCS_READY;
compute_next_snapshot_time();
ret = -E_BAD_EXIT_CODE;
}
out:
if (ret < 0)
- log_err_msg(ERROR, -ret);
+ DSS_ERROR_LOG("%s\n", dss_strerror(-ret));
}
int get_oldest(const char *dirname, void *private)
ret = remove_oldest_snapshot();
if (ret)
goto out;
- make_err_msg("uhuhu: not enough disk space for a single snapshot");
+ DSS_CRIT_LOG("uhuhu: not enough disk space for a single snapshot\n");
ret= -ENOSPC;
out:
free_snapshot_list(&sl);
int ret;
if (conf.dry_run_given) {
- make_err_msg("dry_run not supported by this command");
+ DSS_ERROR_LOG("dry_run not supported by this command\n");
return -E_SYNTAX;
}
ret = install_sighandler(SIGHUP);
return 1;
}
-__noreturn void clean_exit(int status)
-{
- free(dss_error_txt);
- exit(status);
-}
static void setup_signal_handling(void)
{
int ret;
setup_signal_handling();
ret = call_command_handler();
if (ret < 0)
- log_err_msg(EMERG, -ret);
- clean_exit(ret >= 0? EXIT_SUCCESS : EXIT_FAILURE);
+ DSS_EMERG_LOG("%s\n", dss_strerror(-ret));
+ exit(ret >= 0? EXIT_SUCCESS : EXIT_FAILURE);
}
#include "error.h"
#include "string.h"
-__noreturn void clean_exit(int status);
-
/**
* Write a message to a dynamically allocated string.
*
if (!(p = realloc(p, size))) {
DSS_EMERG_LOG("realloc failed (size = %zu), aborting\n",
size);
- clean_exit(EXIT_FAILURE);
+ exit(EXIT_FAILURE);
}
return p;
}
if (!p) {
DSS_EMERG_LOG("malloc failed (size = %zu), aborting\n",
size);
- clean_exit(EXIT_FAILURE);
+ exit(EXIT_FAILURE);
}
return p;
}
if ((ret = strdup(s? s: "")))
return ret;
DSS_EMERG_LOG("strdup failed, aborting\n");
- clean_exit(EXIT_FAILURE);
+ exit(EXIT_FAILURE);
}
/**
return msg;
}
-__printf_1_2 void make_err_msg(const char* fmt,...)
-{
- free(dss_error_txt);
- VSPRINTF(fmt, dss_error_txt);
-}
-
/**
* Get the home directory of the current user.
*
errno = 0; /* To distinguish success/failure after call */
tmp = strtoll(str, &endptr, 10);
- if (errno == ERANGE && (tmp == LLONG_MAX || tmp == LLONG_MIN)) {
- make_err_msg("%s", str);
+ if (errno == ERANGE && (tmp == LLONG_MAX || tmp == LLONG_MIN))
return -E_ATOI_OVERFLOW;
- }
- if (errno != 0 && tmp == 0) { /* other error */
- make_err_msg("%s", str);
+ if (errno != 0 && tmp == 0) /* other error */
return -E_STRTOLL;
- }
- if (endptr == str) {
- make_err_msg("%s", str);
+ if (endptr == str)
return -E_ATOI_NO_DIGITS;
- }
- if (*endptr != '\0') { /* Further characters after number */
- make_err_msg("%s", str);
+ if (*endptr != '\0') /* Further characters after number */
return -E_ATOI_JUNK_AT_END;
- }
*value = tmp;
return 1;
}