The open source OpenXR runtime

a/util: return int type for function returning the return value of snprintf

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2465>

authored by

Simon Zeni and committed by
Marge Bot
a5221e1e 2bde9fe0

+19 -20
+12 -12
src/xrt/auxiliary/util/u_file.c
··· 66 66 } 67 67 } 68 68 69 - ssize_t 69 + int 70 70 u_file_get_config_dir(char *out_path, size_t out_path_size) 71 71 { 72 72 const char *xdg_home = getenv("XDG_CONFIG_HOME"); ··· 80 80 return -1; 81 81 } 82 82 83 - ssize_t 83 + int 84 84 u_file_get_path_in_config_dir(const char *suffix, char *out_path, size_t out_path_size) 85 85 { 86 86 char tmp[PATH_MAX]; 87 - ssize_t i = u_file_get_config_dir(tmp, sizeof(tmp)); 87 + int i = u_file_get_config_dir(tmp, sizeof(tmp)); 88 88 if (i <= 0) { 89 - return -1; 89 + return i; 90 90 } 91 91 92 92 return snprintf(out_path, out_path_size, "%s/%s", tmp, suffix); ··· 96 96 u_file_open_file_in_config_dir(const char *filename, const char *mode) 97 97 { 98 98 char tmp[PATH_MAX]; 99 - ssize_t i = u_file_get_config_dir(tmp, sizeof(tmp)); 99 + int i = u_file_get_config_dir(tmp, sizeof(tmp)); 100 100 if (i <= 0) { 101 101 return NULL; 102 102 } ··· 152 152 return fopen(file_str, mode); 153 153 } 154 154 155 - ssize_t 155 + int 156 156 u_file_get_hand_tracking_models_dir(char *out_path, size_t out_path_size) 157 157 { 158 158 const char *suffix = "/monado/hand-tracking-models"; 159 159 const char *xdg_data_home = getenv("XDG_DATA_HOME"); 160 160 const char *home = getenv("HOME"); 161 - ssize_t ret = 0; 161 + int ret = 0; 162 162 163 163 if (xdg_data_home != NULL) { 164 164 ret = snprintf(out_path, out_path_size, "%s%s", xdg_data_home, suffix); ··· 188 188 out_path[0] = '\0'; 189 189 } 190 190 191 - return -1; 191 + return ret; 192 192 } 193 193 194 194 #endif /* XRT_OS_LINUX */ 195 195 196 - ssize_t 196 + int 197 197 u_file_get_runtime_dir(char *out_path, size_t out_path_size) 198 198 { 199 199 const char *xgd_rt = getenv("XDG_RUNTIME_DIR"); ··· 205 205 return snprintf(out_path, out_path_size, "%s", tmp); 206 206 } 207 207 208 - ssize_t 208 + int 209 209 u_file_get_path_in_runtime_dir(const char *suffix, char *out_path, size_t out_path_size) 210 210 { 211 211 char tmp[PATH_MAX]; 212 - ssize_t i = u_file_get_runtime_dir(tmp, sizeof(tmp)); 212 + int i = u_file_get_runtime_dir(tmp, sizeof(tmp)); 213 213 if (i <= 0) { 214 - return -1; 214 + return i; 215 215 } 216 216 217 217 return snprintf(out_path, out_path_size, "%s/%s", tmp, suffix);
+2 -2
src/xrt/auxiliary/util/u_file.cpp
··· 55 55 #endif 56 56 } 57 57 58 - ssize_t 58 + int 59 59 u_file_get_config_dir(char *out_path, size_t out_path_size) 60 60 { 61 61 auto config_path = get_config_path(); ··· 66 66 return snprintf(out_path, out_path_size, "%s", config_path_string.c_str()); 67 67 } 68 68 69 - ssize_t 69 + int 70 70 u_file_get_path_in_config_dir(const char *filename, char *out_path, size_t out_path_size) 71 71 { 72 72 auto config_path = get_config_path();
+5 -6
src/xrt/auxiliary/util/u_file.h
··· 18 18 extern "C" { 19 19 #endif 20 20 21 - 22 - ssize_t 21 + int 23 22 u_file_get_config_dir(char *out_path, size_t out_path_size); 24 23 25 - ssize_t 24 + int 26 25 u_file_get_path_in_config_dir(const char *suffix, char *out_path, size_t out_path_size); 27 26 28 27 FILE * ··· 31 30 FILE * 32 31 u_file_open_file_in_config_dir_subpath(const char *subpath, const char *filename, const char *mode); 33 32 34 - ssize_t 33 + int 35 34 u_file_get_hand_tracking_models_dir(char *out_path, size_t out_path_size); 36 35 37 - ssize_t 36 + int 38 37 u_file_get_runtime_dir(char *out_path, size_t out_path_size); 39 38 40 39 char * ··· 43 42 char * 44 43 u_file_read_content_from_path(const char *path, size_t *out_file_size); 45 44 46 - ssize_t 45 + int 47 46 u_file_get_path_in_runtime_dir(const char *suffix, char *out_path, size_t out_path_size); 48 47 49 48 #ifdef __cplusplus