pass: parser: Distinguish mandatory property or optional with get_property 27/276927/9
authorChanwoo Choi <cw00.choi@samsung.com>
Fri, 24 Jun 2022 07:35:30 +0000 (16:35 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Tue, 5 Jul 2022 01:26:26 +0000 (10:26 +0900)
commit0f075751015ac14b483a031184d21a52dd23cf2a
treed2a2b5c5c549a9ba94430c0eb28077595b2468a8
parent58fcaddd66481930370da62e14944fc7705afe88
pass: parser: Distinguish mandatory property or optional with get_property

Actually, it is difficult and complicated to specify
whether some property is mandatory or optional even if
it is requied.

Specify either mandatory or optional status of each property
with get_property() function. If some property is mandatory,
just pass the true into 3rd argument of get_property.

In case of mandatory property, get_property returns error
if property is absent. On the other hand, get_property
returns non-zero with debug level log about absent property.

And also, should print the error for non-existent mandatory properteis
in same section at the same time. It helps user to fix
the configuration.

For example,
- 'device_type' and 'device_name' properties are mandatory
   and 'thermal_device_name' property is optional property.

ret += get_property(obj, "device_type", DATA_TYPE_STRING,
true, (void *)device_type);
ret += get_property(obj, "device_name", DATA_TYPE_STRING,
true, (void *)device_name);
ret += get_property(obj, "thermal_device_name", DATA_TYPE_STRING,
false, (void *)thermal_device_name);

if (ret < 0) {
    _E("Failed to get mandatory properties in device_list\n");
    return ret;
}

- result of error log
Failed to get property of 'device_type'    (log for mandatory property)
Failed to get property of 'device_name'    (log for mandatory property)
There is no property of 'thermal_priority' (log for optional property)
Failed to get mandatory properties in device_list
cannot parse of 0th resource in 'device_list' section

Change-Id: I2e8a87788eadb7550369378af4adfec0774bdc8a
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
src/pass/pass-parser.c