From 4dba2d36d847d3736accf912ae302e91007c6fbf Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Thu, 1 Aug 2019 16:52:55 +0900 Subject: [PATCH] Add exception handle, fix log format specifier Change-Id: I0f3f230501ba46c345dcd20d2b737fbb5722dfa1 Signed-off-by: Youngjae Cho --- src/board/board-info.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/board/board-info.c b/src/board/board-info.c index 2af9fd9..6f72ca8 100644 --- a/src/board/board-info.c +++ b/src/board/board-info.c @@ -43,7 +43,7 @@ static GVariant *dbus_revision_handler(GDBusConnection *conn, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret; - if (!board_dev->get_device_revision) { + if (!board_dev || !board_dev->get_device_revision) { _E("GetHWRev not supported."); ret = -ENOTSUP; goto revision_fail; @@ -65,7 +65,7 @@ static GVariant *dbus_serial_handler(GDBusConnection *conn, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret; - if (!board_dev->get_device_serial) { + if (!board_dev || !board_dev->get_device_serial) { _E("GetSerial not supported."); ret = -ENOTSUP; goto serial_out; @@ -75,7 +75,7 @@ static GVariant *dbus_serial_handler(GDBusConnection *conn, _E("Failed to get serial."); goto serial_out; } - _D("Serial(%s) len(%d).", info.serial, strlen(info.serial)); + _D("Serial(%s) len(%zu).", info.serial, strlen(info.serial)); serial_out: return g_variant_new("(si)", info.serial, ret); @@ -87,7 +87,7 @@ static GVariant *dbus_num_handler(GDBusConnection *conn, { int ret; char *p; - if (!board_dev->get_device_serial) { + if (!board_dev || !board_dev->get_device_serial) { _E("GetNum not supported."); ret = -ENOTSUP; goto num_out; @@ -103,7 +103,7 @@ static GVariant *dbus_num_handler(GDBusConnection *conn, ++p; strcpy(info.num, p); } - _D("Num(%s) len(%d).", info.num, strlen(info.num)); + _D("Num(%s) len(%zu).", info.num, strlen(info.num)); num_out: return g_variant_new("(si)", info.num, ret); @@ -159,9 +159,6 @@ static void board_init(void *data) ret = dbus_handle_add_dbus_object(NULL, DEVICED_PATH_BOARD, &dbus_interface); if (ret < 0) _E("Failed to init dbus method: %d", ret); - ret = board_dev->get_device_serial(&info.serial); - if (ret < 0) - _E("Failed to get serial info: %d", ret); } static const struct device_ops board_device_ops = { -- 2.7.4