Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions cfgpath.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static inline void get_user_config_file(char *out, unsigned int maxlen, const ch
#ifdef CFGPATH_LINUX
const char *out_orig = out;
char *home = getenv("XDG_CONFIG_HOME");
unsigned int config_len = 0;
size_t config_len = 0;
if (!home) {
home = getenv("HOME");
if (!home) {
Expand All @@ -109,9 +109,9 @@ static inline void get_user_config_file(char *out, unsigned int maxlen, const ch
config_len = strlen(".config/");
}

unsigned int home_len = strlen(home);
unsigned int appname_len = strlen(appname);
const int ext_len = strlen(".conf");
size_t home_len = strlen(home);
size_t appname_len = strlen(appname);
size_t ext_len = strlen(".conf");

/* first +1 is "/", second is terminating null */
if (home_len + 1 + config_len + appname_len + ext_len + 1 > maxlen) {
Expand Down Expand Up @@ -145,7 +145,7 @@ static inline void get_user_config_file(char *out, unsigned int maxlen, const ch
return;
}
/* We don't try to create the AppData folder as it always exists already */
unsigned int appname_len = strlen(appname);
size_t appname_len = strlen(appname);
if (strlen(out) + 1 + appname_len + strlen(".ini") + 1 > maxlen) {
out[0] = 0;
return;
Expand Down Expand Up @@ -205,7 +205,7 @@ static inline void get_user_config_folder(char *out, unsigned int maxlen, const
#ifdef CFGPATH_LINUX
const char *out_orig = out;
char *home = getenv("XDG_CONFIG_HOME");
unsigned int config_len = 0;
size_t config_len = 0;
if (!home) {
home = getenv("HOME");
if (!home) {
Expand All @@ -216,8 +216,8 @@ static inline void get_user_config_folder(char *out, unsigned int maxlen, const
config_len = strlen(".config/");
}

unsigned int home_len = strlen(home);
unsigned int appname_len = strlen(appname);
size_t home_len = strlen(home);
size_t appname_len = strlen(appname);

/* first +1 is "/", second is trailing "/", third is terminating null */
if (home_len + 1 + config_len + appname_len + 1 + 1 > maxlen) {
Expand Down Expand Up @@ -254,7 +254,7 @@ static inline void get_user_config_folder(char *out, unsigned int maxlen, const
return;
}
/* We don't try to create the AppData folder as it always exists already */
unsigned int appname_len = strlen(appname);
size_t appname_len = strlen(appname);
if (strlen(out) + 1 + appname_len + 1 + 1 > maxlen) {
out[0] = 0;
return;
Expand Down Expand Up @@ -322,7 +322,7 @@ static inline void get_user_data_folder(char *out, unsigned int maxlen, const ch
#ifdef CFGPATH_LINUX
const char *out_orig = out;
char *home = getenv("XDG_DATA_HOME");
unsigned int config_len = 0;
size_t config_len = 0;
if (!home) {
home = getenv("HOME");
if (!home) {
Expand All @@ -333,8 +333,8 @@ static inline void get_user_data_folder(char *out, unsigned int maxlen, const ch
config_len = strlen(".local/share/");
}

unsigned int home_len = strlen(home);
unsigned int appname_len = strlen(appname);
size_t home_len = strlen(home);
size_t appname_len = strlen(appname);

/* first +1 is "/", second is trailing "/", third is terminating null */
if (home_len + 1 + config_len + appname_len + 1 + 1 > maxlen) {
Expand Down Expand Up @@ -407,7 +407,7 @@ static inline void get_user_cache_folder(char *out, unsigned int maxlen, const c
#ifdef CFGPATH_LINUX
const char *out_orig = out;
char *home = getenv("XDG_CACHE_HOME");
unsigned int config_len = 0;
size_t config_len = 0;
if (!home) {
home = getenv("HOME");
if (!home) {
Expand All @@ -418,8 +418,8 @@ static inline void get_user_cache_folder(char *out, unsigned int maxlen, const c
config_len = strlen(".cache/");
}

unsigned int home_len = strlen(home);
unsigned int appname_len = strlen(appname);
size_t home_len = strlen(home);
size_t appname_len = strlen(appname);

/* first +1 is "/", second is trailing "/", third is terminating null */
if (home_len + 1 + config_len + appname_len + 1 + 1 > maxlen) {
Expand Down Expand Up @@ -456,7 +456,7 @@ static inline void get_user_cache_folder(char *out, unsigned int maxlen, const c
return;
}
/* We don't try to create the AppData folder as it always exists already */
unsigned int appname_len = strlen(appname);
size_t appname_len = strlen(appname);
if (strlen(out) + 1 + appname_len + 1 + 1 > maxlen) {
out[0] = 0;
return;
Expand Down