From e8225b273c63f81edb3255d79873eef71394fc8e Mon Sep 17 00:00:00 2001 From: Moses Turner <moses@collabora.com> Date: Sun, 18 Sep 2022 08:03:21 -0500 Subject: [PATCH] t/common: Switch SimulaVR builder to u_file_read_content_from_path --- src/xrt/targets/common/target_builder_simulavr.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/xrt/targets/common/target_builder_simulavr.c b/src/xrt/targets/common/target_builder_simulavr.c index eee14d09d..b71893b00 100644 --- a/src/xrt/targets/common/target_builder_simulavr.c +++ b/src/xrt/targets/common/target_builder_simulavr.c @@ -82,13 +82,11 @@ process_poly_values(const cJSON *values, struct svr_display_distortion_polynomia static bool process_config(const char *config_path, struct svr_two_displays_distortion *out_dist) { - FILE *file = fopen(config_path, "r"); - const char *file_content = u_file_read_content(file); - int ret = fclose(file); - if (ret != 0) { - // Apparently I have to handle this. I have no idea how this could happen or if it would be bad, so - // let's print and keep going. - U_LOG_E("Failed to close file?"); + char *file_content = u_file_read_content_from_path(config_path); + if (file_content == NULL) { + U_LOG_E("The file at \"%s\" was unable to load. Either there wasn't a file there or it was empty.", + config_path); + return false; } cJSON *config_json = cJSON_Parse(file_content);