init_db: Fix not to print warning log about no source file 90/322990/2 accepted/tizen_unified accepted/tizen_unified_x tizen accepted/tizen/unified/20250429.071338 accepted/tizen/unified/x/20250429.203611
authorYoungjae Cho <y0.cho@samsung.com>
Mon, 21 Apr 2025 04:54:14 +0000 (13:54 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Mon, 21 Apr 2025 10:48:50 +0000 (19:48 +0900)
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 <y0.cho@samsung.com>
src/init_db/system_info_db_init.c

index c02958fcace60a055411c6b4e5b231bfbcd20798..5e617119f7a515b78a54dae2c6432b9b4432cd07 100644 (file)
@@ -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);
        }