Checking return value
authordyamy-lee <dyamy.lee@samsung.com>
Mon, 26 Apr 2021 06:13:30 +0000 (15:13 +0900)
committerduna.oh <duna.oh@samsung.com>
Fri, 27 Jan 2023 05:46:39 +0000 (14:46 +0900)
When using return value from other function, it is usually checked for it.

Change-Id: I071942d9885500ce37adf08f89788d59d031d458

haltests/test_hal_libinput_info.cpp

index b39f3dc..5ddbe48 100644 (file)
@@ -29,6 +29,7 @@ int handle_device_notify(struct libinput_event *ev)
        struct udev_device *udev_device = libinput_device_get_udev_device(dev);
        enum libinput_event_type type;
        const char *devnode;
+       const char *test = NULL;
        errno = 0;
 
        switch(libinput_event_get_type(ev)) {
@@ -42,7 +43,8 @@ int handle_device_notify(struct libinput_event *ev)
                abort();
        }
 
-       if(strstr(udev_device_get_property_value(udev_device, "DEVPATH"), "virtual")){
+       test = udev_device_get_property_value(udev_device, "DEVPATH");
+       if(test && strstr(test, "virtual")){
                LOG("It's contain virtual. No Check.\n");
                return 0;
        }
@@ -50,7 +52,6 @@ int handle_device_notify(struct libinput_event *ev)
        if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_KEYBOARD)) {
                devnode = udev_device_get_devnode(libinput_device_get_udev_device(dev));
                if(type == LIBINPUT_EVENT_DEVICE_ADDED) { // TODO. save using linked list
-                       const char *test = NULL;
                        test = udev_device_get_property_value(udev_device, "ID_INPUT_KEYBOARD");
                        LOG("devnode = %s\n", devnode);
                        if(test && (test[0] == '1')){