diff options
author | lokilee73 <changjoo.lee@samsung.com> | 2021-02-17 14:34:05 +0900 |
---|---|---|
committer | lokilee73 <changjoo.lee@samsung.com> | 2021-02-17 14:37:57 +0900 |
commit | 412e5d315325d0b3247df31bf24e1e495226c5dc (patch) | |
tree | 27e7e2a8ec262f087ddeb16c1929a1a26560699c | |
parent | 3294e2d04708ce91ce4bcb94dc2aee34490eb91b (diff) | |
download | device-emulator-412e5d315325d0b3247df31bf24e1e495226c5dc.tar.gz device-emulator-412e5d315325d0b3247df31bf24e1e495226c5dc.tar.bz2 device-emulator-412e5d315325d0b3247df31bf24e1e495226c5dc.zip |
Change error and reset conditions for signal_id
Change-Id: I731836c82b3348d76d97ac005d1ce4b2cd8fe95e
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
-rw-r--r-- | hw/battery/battery.c | 9 | ||||
-rw-r--r-- | hw/external_connection/external_connection.c | 5 |
2 files changed, 7 insertions, 7 deletions
diff --git a/hw/battery/battery.c b/hw/battery/battery.c index fa45c73..d3b3ca6 100644 --- a/hw/battery/battery.c +++ b/hw/battery/battery.c @@ -128,8 +128,6 @@ out: static int battery_register_changed_event( BatteryUpdated updated_cb, void *data) { - int ret; - if (sdata.updated_cb) { _E("update callback is already registered"); return -EEXIST; @@ -138,7 +136,7 @@ static int battery_register_changed_event( signal_id = subscribe_dbus_signal(NULL, BATTERY_OBJECT, BATTERY_IFACE, BATTERY_SIGNAL, signal_delivered, &sdata, NULL); - if (signal_id < 0) { + if (signal_id <= 0) { _E("Failed to register signal"); return -ENOMEM; } @@ -146,14 +144,15 @@ static int battery_register_changed_event( sdata.updated_cb = updated_cb; sdata.data = data; - return ret; + return 0; } static void battery_unregister_changed_event( BatteryUpdated updated_cb) { unsubscribe_dbus_signal(NULL, signal_id); - signal_id = 0; + if (signal_id > 0) + signal_id = 0; sdata.updated_cb = NULL; sdata.data = NULL; } diff --git a/hw/external_connection/external_connection.c b/hw/external_connection/external_connection.c index e1a09e0..aca4ac2 100644 --- a/hw/external_connection/external_connection.c +++ b/hw/external_connection/external_connection.c @@ -124,7 +124,7 @@ static int external_connection_register_changed_event( signal_id = subscribe_dbus_signal(NULL, EXTCON_OBJECT, EXTCON_IFACE, EXTCON_SIGNAL, signal_delivered, &sdata, NULL); - if (signal_id < 0) { + if (signal_id <= 0) { _E("Failed to register signal"); return -ENOMEM; } @@ -139,7 +139,8 @@ static void external_connection_unregister_changed_event( ConnectionUpdated updated_cb) { unsubscribe_dbus_signal(NULL, signal_id); - signal_id = 0; + if (signal_id > 0) + signal_id = 0; sdata.updated_cb = NULL; sdata.data = NULL; } |