Skip to content

Commit

Permalink
config: fix const configfile
Browse files Browse the repository at this point in the history
  • Loading branch information
columbarius committed Mar 1, 2021
1 parent 4a35ce4 commit 7b347fe
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ struct xdpw_config {

void print_config(enum LOGLEVEL loglevel, struct xdpw_config *config);
void finish_config(struct xdpw_config *config);
void init_config(const char **configfile, struct xdpw_config *config);
void init_config(const char ** const configfile, struct xdpw_config *config);

#endif
4 changes: 2 additions & 2 deletions src/core/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static void config_parse_file(const char *configfile, struct xdpw_config *config
print_config(DEBUG, config);
}

static char *get_config_path(void) {
static const char *get_config_path(void) {
const char *home = getenv("HOME");
size_t size_fallback = 1 + strlen(home) + strlen("/.config");
char *config_home_fallback = calloc(size_fallback, sizeof(char));
Expand Down Expand Up @@ -109,7 +109,7 @@ static char *get_config_path(void) {
return NULL;
}

void init_config(const char **configfile, struct xdpw_config *config) {
void init_config(const char ** const configfile, struct xdpw_config *config) {
if (*configfile == NULL) {
*configfile = get_config_path();
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static int handle_name_lost(sd_bus_message *m, void *userdata, sd_bus_error *ret

int main(int argc, char *argv[]) {
struct xdpw_config config = {0};
const char *configfile = NULL;
char *configfile = NULL;
enum LOGLEVEL loglevel = DEFAULT_LOGLEVEL;
bool replace = false;

Expand Down Expand Up @@ -82,7 +82,7 @@ int main(int argc, char *argv[]) {
}

init_logger(stderr, loglevel);
init_config(&configfile, &config);
init_config((const char ** const)&configfile, &config);

int ret = 0;

Expand Down Expand Up @@ -227,7 +227,7 @@ int main(int argc, char *argv[]) {

// TODO: cleanup
finish_config(&config);
free((char *)configfile);
free(configfile);

return EXIT_SUCCESS;

Expand Down

0 comments on commit 7b347fe

Please sign in to comment.