From: Youngjae Cho Date: Mon, 21 Apr 2025 04:54:14 +0000 (+0900) Subject: init_db: Fix not to print warning log about no source file X-Git-Tag: accepted/tizen/9.0/unified/20250423.165355^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Ftizen_9.0;p=platform%2Fcore%2Fapi%2Fsystem-info.git init_db: Fix not to print warning log about no source file There might be no source files for the system info database. For example, when creating hal.img, there might be no /etc/info.ini and /etc/config/model-config.xml. - I/O warning : failed to load "/etc/config/model-config.xml": No such file or directory - iniparser: cannot open /etc/info.ini To prevent printing warning log about no such files, check their existance before parsing them. In addition, fixed log when there is no given --release argument for the system_info_update_db(). Previously, it just printed null buffer after the 'and', making the entire message end with just 'and'. - Make system info db(/hal/etc/system_info_db) by /hal/etc/config/model-config.xml and And it made the following line seem like continued message from the trailing 'and'. So fixed not to print 'and' when there is no given --release argument. Change-Id: Ic7bce9b46f3578b40fb3b07f54d43a36df37cf2f Signed-off-by: Youngjae Cho (cherry picked from commit 7849fa13fdc71621fecb8d589ecf7a021be95b7a) --- diff --git a/src/init_db/system_info_db_init.c b/src/init_db/system_info_db_init.c index c02958f..5e61711 100644 --- a/src/init_db/system_info_db_init.c +++ b/src/init_db/system_info_db_init.c @@ -462,13 +462,13 @@ static int system_info_create_db(const char *conf_path, const char *release_path fclose(fp); } - if (conf_path && conf_path[0]) { + if (conf_path && conf_path[0] && (access(conf_path, F_OK) == 0)) { ret = system_info_get_values_config_xml(db_path, conf_path); if (ret < 0) _E("Failed to get keys and values from xml(%d)", ret); } - if (release_path && release_path[0]) { + if (release_path && release_path[0] && (access(release_path, F_OK) == 0)) { ret = system_info_get_values_ini(db_path, release_path); if (ret < 0) _E("Failed to get keys and values from ini(%d)", ret); @@ -568,7 +568,10 @@ static int system_info_update_db(int argc, char *argv[]) } if (conf_path[0] != '\0' && db_path[0] != '\0') { - printf("Make system info db(%s) by %s and %s\n", db_path, conf_path, release_path); + if (release_path[0]) + printf("Make system info db(%s) by %s and %s\n", db_path, conf_path, release_path); + else + printf("Make system info db(%s) by %s\n", db_path, conf_path); return system_info_create_db(conf_path, release_path, db_path); }