diff options
author | Jiyoung Yun <jy910.yun@samsung.com> | 2015-01-02 11:10:39 +0900 |
---|---|---|
committer | Lukasz Stelmach <l.stelmach@samsung.com> | 2015-01-13 22:52:06 -0800 |
commit | 4d16440882cdff9a2a73346a2de2a1d2d1bddd36 (patch) | |
tree | 6d4e55c0beca19705b3890c0cac145faea8596f3 /include | |
parent | 032b4a930fed8679f32f7300b5fe747c5ca4e6b0 (diff) | |
download | libdevice-node-4d16440882cdff9a2a73346a2de2a1d2d1bddd36.tar.gz libdevice-node-4d16440882cdff9a2a73346a2de2a1d2d1bddd36.tar.bz2 libdevice-node-4d16440882cdff9a2a73346a2de2a1d2d1bddd36.zip |
device-node: Add null check operation of interface function
If there is no interface for something to do,
it will return -ENOTSUP error instead of segfault.
Bug-Tizen: TC-1932
Signed-off-by: Jiyoung Yun <jy910.yun@samsung.com>
Change-Id: If9dfdaecf53c88e14879dc66986e12cdcd1c2355
Diffstat (limited to 'include')
-rw-r--r-- | include/device-internal.h | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/include/device-internal.h b/include/device-internal.h index d093283..63a9db5 100644 --- a/include/device-internal.h +++ b/include/device-internal.h @@ -19,6 +19,7 @@ #ifndef __DEVICE_INTERNAL_H__ #define __DEVICE_INTERNAL_H__ +#include <errno.h> #include "device-node.h" #ifndef __CONSTRUCTOR__ @@ -44,12 +45,23 @@ #define DEVMAN_PLUGIN_PATH "/usr/lib/libslp_devman_plugin.so" -#ifndef PLUGIN_DEFINE -#define PLUGIN_DEFINE -#define PLUGIN_SYS(node) plugin_intf->OEM_sys_##node -#define PLUGIN_GET(node) plugin_intf->OEM_sys_get_##node -#define PLUGIN_SET(node) plugin_intf->OEM_sys_set_##node -#endif +#define DEF_SYS(node) default_plugin.OEM_sys_##node +#define DEF_GET(node) default_plugin.OEM_sys_get_##node +#define DEF_SET(node) default_plugin.OEM_sys_set_##node + +#define OEM_SYS(node) oem_intf->OEM_sys_##node +#define OEM_GET(node) oem_intf->OEM_sys_get_##node +#define OEM_SET(node) oem_intf->OEM_sys_set_##node + +#define PLUGIN_SYS(node, ...) \ + (oem_intf && OEM_SYS(node) ? OEM_SYS(node)(__VA_ARGS__) : \ + DEF_SYS(node) ? DEF_SYS(node)(__VA_ARGS__) : -ENOTSUP) +#define PLUGIN_GET(node, ...) \ + (oem_intf && OEM_GET(node) ? OEM_GET(node)(__VA_ARGS__) : \ + DEF_GET(node) ? DEF_GET(node)(__VA_ARGS__) : -ENOTSUP) +#define PLUGIN_SET(node, ...) \ + (oem_intf && OEM_SET(node) ? OEM_SET(node)(__VA_ARGS__) : \ + DEF_SET(node) ? DEF_SET(node)(__VA_ARGS__) : -ENOTSUP) struct device { enum device_type type; @@ -61,7 +73,7 @@ struct device { void add_device(const enum device_type *devtype); void remove_device(const enum device_type *devtype); -extern const OEM_sys_devman_plugin_interface *plugin_intf; +extern const OEM_sys_devman_plugin_interface *oem_intf; extern const OEM_sys_devman_plugin_interface default_plugin; #endif /* __DEVICE_INTERNAL_H__ */ |