From: Youngjae Cho Date: Tue, 25 Jun 2024 02:31:08 +0000 (+0900) Subject: halcc: Add module name info to error log X-Git-Tag: accepted/tizen/unified/20240625.163203~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8b4139c1043eb310a473528833d6067d37a4bbeb;p=platform%2Fhal%2Fapi%2Fcommon.git halcc: Add module name info to error log Change-Id: Ic1c1992dfc913f205f651c40005240700f9f6c07 Signed-off-by: Youngjae Cho --- diff --git a/src/hal-api-compatibility-checker.c b/src/hal-api-compatibility-checker.c index fef9463..efe1841 100644 --- a/src/hal-api-compatibility-checker.c +++ b/src/hal-api-compatibility-checker.c @@ -243,7 +243,7 @@ static void convert_hal_to_info_skip_version_check(void *data_hal, void *data_in __convert_hal_to_info(data_hal, data_info, true); } -static bool is_system_generator_context(void) +static bool is_system_generator_context(const char *module_name) { char *systemd_scope = NULL; @@ -256,14 +256,14 @@ static bool is_system_generator_context(void) systemd_scope = getenv("SYSTEMD_SCOPE"); if (!systemd_scope) { - _E("Reject to create %s, not a generator context", - compatibility_result_path); + _E("%s: Reject to create %s, not a generator context", + module_name, compatibility_result_path); return false; } if (strncmp(systemd_scope, "system", sizeof("system")) != 0) { - _E("Reject to create %s, only system servie manager is allowed to do it", - compatibility_result_path); + _E("%s: Reject to create %s, only system servie manager is allowed to do it", + module_name, compatibility_result_path); return false; } @@ -320,7 +320,7 @@ static int create_directory(const char *path) } -static int open_result_file(const char *path, int *fd_out, bool reset) +static int open_result_file(const char *path, int *fd_out, bool reset, const char *module_name) { int ret; int fd; @@ -334,7 +334,7 @@ static int open_result_file(const char *path, int *fd_out, bool reset) ret = create_directory(path); if (ret < 0) { errno = -ret; - _E("Failed to create directory for %s, %m", path); + _E("%s: Failed to create directory for %s, %m", module_name, path); return ret; } @@ -351,7 +351,7 @@ static int open_result_file(const char *path, int *fd_out, bool reset) } ret = -errno; - _E("Failed to create %s, %m", path); + _E("%s: Failed to create %s, %m", module_name, path); return ret; } @@ -360,7 +360,7 @@ static int open_result_file(const char *path, int *fd_out, bool reset) ret = ftruncate(fd, sizeof(struct compatibility_info) * HAL_MODULE_END); if (ret < 0) { ret = -errno; - _E("Failed to ftruncate %s, %m", path); + _E("%s: Failed to ftruncate %s, %m", module_name, path); close(fd); return ret; } @@ -369,7 +369,7 @@ static int open_result_file(const char *path, int *fd_out, bool reset) ret = set_owner(fd); if (ret < 0) { errno = -ret; - _E("Failed to set owner, ret=%d, %m\n", ret); + _E("%s: Failed to set owner, ret=%d, %m\n", module_name, ret); close(fd); return ret; } @@ -387,7 +387,7 @@ static int write_module_comaptibility_info(enum hal_module module, ssize_t n_write; off_t offset; - ret = open_result_file(compatibility_result_path, &fd, false); + ret = open_result_file(compatibility_result_path, &fd, false, info->module_name); if (ret < 0) { _E("Failed to create open result file %s", compatibility_result_path); return ret; @@ -397,7 +397,7 @@ static int write_module_comaptibility_info(enum hal_module module, n_write = pwrite(fd, info, sizeof(*info), offset); if (n_write == -1) { ret = -errno; - _E("Failed to write info, %m"); + _E("%s: Failed to write info, %m", info->module_name); close(fd); return ret; } @@ -484,7 +484,7 @@ static int load_module_compatibility_info_fallback(enum hal_module module, manifest = NULL; /* Writing result is only allowed on system generator context */ - if (!is_system_generator_context()) + if (!is_system_generator_context(info->module_name)) return 0; /* Incomplete data, no versions. Don't write it */