Skip to content

Commit

Permalink
Quiet some -Wstringop-overflow warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusor committed Apr 28, 2024
1 parent 4f5815e commit 5683582
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
1 change: 0 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ c_args = [
'-fstack-clash-protection',
'-Wformat',
'-Wstrict-overflow',
'-Wstringop-overflow',
'-Wsuggest-attribute=const',
'-Wno-unused-function', # not even go goes this far
'-Wno-alloc-zero', # stb arrfree uses realloc with 0 bytes
Expand Down
19 changes: 14 additions & 5 deletions src/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,10 @@ static void set_cache_file(const struct configuration *config, const char *file_
file_name = "";
}

snprintf((char*)config->cache_path, FILE_PATH_MAX, TOKENIZED_CACHE_PATH, config->env.xdg_cache_home, config->name, file_name);
const int wrote = snprintf((char*)config->cache_path, FILE_PATH_MAX, TOKENIZED_CACHE_PATH, config->env.xdg_cache_home, config->name, file_name);
if (wrote == 0) {
_trace2("path::error: unable build cache path");
}
}

static void set_cache_path(const struct configuration *config)
Expand All @@ -258,7 +261,10 @@ static void set_credentials_file(const struct configuration *config, const char
file_name = "";
}

snprintf((char*)config->credentials_path, FILE_PATH_MAX, TOKENIZED_CREDENTIALS_PATH, config->env.xdg_data_home, config->name, file_name);
const int wrote = snprintf((char*)config->credentials_path, FILE_PATH_MAX, TOKENIZED_CREDENTIALS_PATH, config->env.xdg_data_home, config->name, file_name);
if (wrote == 0) {
_trace2("path::error: unable build credentials path");
}
}

static void set_credentials_path(const struct configuration *config)
Expand All @@ -274,7 +280,10 @@ static void set_config_file(const struct configuration *config, const char *file
file_name = "config";
}

snprintf((char*)config->config_path, FILE_PATH_MAX+1, TOKENIZED_CONFIG_PATH, config->env.xdg_config_home, config->name, file_name);
const int wrote = snprintf((char*)config->config_path, FILE_PATH_MAX+1, TOKENIZED_CONFIG_PATH, config->env.xdg_config_home, config->name, file_name);
if (wrote == 0) {
_trace2("path::error: unable build config path");
}
}

static void set_config_path(const struct configuration *config)
Expand Down Expand Up @@ -314,10 +323,10 @@ static bool load_credentials_from_ini_group (struct ini_group *group, struct api
const size_t count = arrlen(group->values);
for (size_t i = 0; i < count; i++) {
struct ini_value *setting = group->values[i];
string key = setting->key;
const string key = setting->key;
if (NULL == key) { continue; }

string value = setting->value;
const string value = setting->value;
if (NULL == value) { continue; }

if (value->len == 0) { continue; }
Expand Down

0 comments on commit 5683582

Please sign in to comment.