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>