display: plugin: Add handling code to plugin getter/setter 94/293794/1
authorYunhee Seo <yuni.seo@samsung.com>
Fri, 2 Jun 2023 10:58:25 +0000 (19:58 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Mon, 5 Jun 2023 06:29:06 +0000 (15:29 +0900)
display_plugin_state_get_name() is changed to set NULL,
if there is no state name.
State timeout value can be 0, but getter/setter checks not proper value.
If the timeout value is 0, it should returned.

This patch is necessary because the value is not properly checked.

Change-Id: Ie053c1c31a1f2b70e9f0ce6790c3fa41eea603e8
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
src/display/display-plugin.c

index bbbb0da..1f8b80a 100644 (file)
@@ -184,12 +184,13 @@ int display_plugin_state_get_name(enum state_t state, const char **state_name)
                return 0;
        }
 
+       *state_name = NULL;
        return -EOPNOTSUPP;
 }
 
 int display_plugin_state_set_timeout(enum state_t state, int state_timeout)
 {
-       if (g_display_plugin.display_states[state] && g_display_plugin.display_states[state]->timeout) {
+       if (g_display_plugin.display_states[state]) {
                g_display_plugin.display_states[state]->timeout = state_timeout;
                return 0;
        }
@@ -202,7 +203,7 @@ int display_plugin_state_get_timeout(enum state_t state, int* state_timeout)
        if (!state_timeout)
                return -EINVAL;
 
-       if (g_display_plugin.display_states[state] && g_display_plugin.display_states[state]->timeout) {
+       if (g_display_plugin.display_states[state]) {
                *state_timeout = g_display_plugin.display_states[state]->timeout;
                return 0;
        }