Skip to content

Check if getWindowCommand() failed or not

Avinash Sonawane requested to merge wm_command_count into master
  1. Currently, we are ignoring the return value of `getWindowCommand()` so check if `XGetCommand()` (called by getWindowCommand) succeeded or not

  2. This MR also fixes these clang warnings:

    session.c:619:21: warning: variable 'wm_command_count' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
                    if (client_id)
                        ^~~~~~~~~
    session.c:678:10: note: uninitialized use occurs here
        if ((wm_command_count > 0) && (wm_command))
             ^~~~~~~~~~~~~~~~
    session.c:619:17: note: remove the 'if' if its condition is always false
                    if (client_id)
                    ^~~~~~~~~~~~~~
    session.c:614:17: warning: variable 'wm_command_count' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
                if (xstreq (c->class.res_name, m->res_name)
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    session.c:568:21: note: expanded from macro 'xstreq'
    #define xstreq(a,b) ((!a && !b) || (a && b && (strcmp(a,b)==0)))
                        ^
    session.c:678:10: note: uninitialized use occurs here
        if ((wm_command_count > 0) && (wm_command))
             ^~~~~~~~~~~~~~~~
    session.c:614:13: note: remove the 'if' if its condition is always true
                if (xstreq (c->class.res_name, m->res_name)
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    session.c:617:32: warning: variable 'wm_command_count' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]
                        || xstreq (c->name, m->wm_name)))
                           ~~~~~~~~^~~~~~~~~~~~~~~~~~~~
    session.c:568:37: note: expanded from macro 'xstreq'
    #define xstreq(a,b) ((!a && !b) || (a && b && (strcmp(a,b)==0)))
                                        ^~~~~~
    session.c:678:10: note: uninitialized use occurs here
        if ((wm_command_count > 0) && (wm_command))
             ^~~~~~~~~~~~~~~~
    session.c:617:32: note: remove the '&&' if its condition is always true
                        || xstreq (c->name, m->wm_name)))
                                   ^
    session.c:617:32: warning: variable 'wm_command_count' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]
                        || xstreq (c->name, m->wm_name)))
                                   ^~~~~~~
    session.c:568:37: note: expanded from macro 'xstreq'
    #define xstreq(a,b) ((!a && !b) || (a && b && (strcmp(a,b)==0)))
                                        ^
    session.c:678:10: note: uninitialized use occurs here
        if ((wm_command_count > 0) && (wm_command))
             ^~~~~~~~~~~~~~~~
    session.c:617:32: note: remove the '&&' if its condition is always true
                        || xstreq (c->name, m->wm_name)))
                                   ^
    session.c:614:17: warning: variable 'wm_command_count' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]
                if (xstreq (c->class.res_name, m->res_name)
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    session.c:568:21: note: expanded from macro 'xstreq'
    #define xstreq(a,b) ((!a && !b) || (a && b && (strcmp(a,b)==0)))
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    session.c:678:10: note: uninitialized use occurs here
        if ((wm_command_count > 0) && (wm_command))
             ^~~~~~~~~~~~~~~~
    session.c:614:17: note: remove the '&&' if its condition is always true
                if (xstreq (c->class.res_name, m->res_name)
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    session.c:568:21: note: expanded from macro 'xstreq'
    #define xstreq(a,b) ((!a && !b) || (a && b && (strcmp(a,b)==0)))
                        ^
    session.c:614:25: warning: variable 'wm_command_count' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]
                if (xstreq (c->class.res_name, m->res_name)
                    ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    session.c:568:37: note: expanded from macro 'xstreq'
    #define xstreq(a,b) ((!a && !b) || (a && b && (strcmp(a,b)==0)))
                                        ^~~~~~
    session.c:678:10: note: uninitialized use occurs here
        if ((wm_command_count > 0) && (wm_command))
             ^~~~~~~~~~~~~~~~
    session.c:614:25: note: remove the '&&' if its condition is always true
                if (xstreq (c->class.res_name, m->res_name)
                            ^
    session.c:614:25: warning: variable 'wm_command_count' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]
                if (xstreq (c->class.res_name, m->res_name)
                            ^~~~~~~~~~~~~~~~~
    session.c:568:37: note: expanded from macro 'xstreq'
    #define xstreq(a,b) ((!a && !b) || (a && b && (strcmp(a,b)==0)))
                                        ^
    session.c:678:10: note: uninitialized use occurs here
        if ((wm_command_count > 0) && (wm_command))
             ^~~~~~~~~~~~~~~~
    session.c:614:25: note: remove the '&&' if its condition is always true
                if (xstreq (c->class.res_name, m->res_name)
                            ^
    session.c:603:13: warning: variable 'wm_command_count' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
            if ((window_role) || (m->window_role))
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    session.c:678:10: note: uninitialized use occurs here
        if ((wm_command_count > 0) && (wm_command))
             ^~~~~~~~~~~~~~~~
    session.c:603:9: note: remove the 'if' if its condition is always false
            if ((window_role) || (m->window_role))
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    session.c:603:13: warning: variable 'wm_command_count' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized]
            if ((window_role) || (m->window_role))
                ^~~~~~~~~~~~~
    session.c:678:10: note: uninitialized use occurs here
        if ((wm_command_count > 0) && (wm_command))
             ^~~~~~~~~~~~~~~~
    session.c:603:13: note: remove the '||' if its condition is always false
            if ((window_role) || (m->window_role))
                ^~~~~~~~~~~~~~~~
    session.c:592:9: warning: variable 'wm_command_count' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
        if (xstreq (client_id, m->client_id))
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    session.c:568:21: note: expanded from macro 'xstreq'
    #define xstreq(a,b) ((!a && !b) || (a && b && (strcmp(a,b)==0)))
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    session.c:678:10: note: uninitialized use occurs here
        if ((wm_command_count > 0) && (wm_command))
             ^~~~~~~~~~~~~~~~
    session.c:592:5: note: remove the 'if' if its condition is always true
        if (xstreq (client_id, m->client_id))
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    session.c:592:17: warning: variable 'wm_command_count' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]
        if (xstreq (client_id, m->client_id))
            ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
    session.c:568:37: note: expanded from macro 'xstreq'
    #define xstreq(a,b) ((!a && !b) || (a && b && (strcmp(a,b)==0)))
                                        ^~~~~~
    session.c:678:10: note: uninitialized use occurs here
        if ((wm_command_count > 0) && (wm_command))
             ^~~~~~~~~~~~~~~~
    session.c:592:17: note: remove the '&&' if its condition is always true
        if (xstreq (client_id, m->client_id))
                    ^
    session.c:592:17: warning: variable 'wm_command_count' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]
        if (xstreq (client_id, m->client_id))
                    ^~~~~~~~~
    session.c:568:37: note: expanded from macro 'xstreq'
    #define xstreq(a,b) ((!a && !b) || (a && b && (strcmp(a,b)==0)))
                                        ^
    session.c:678:10: note: uninitialized use occurs here
        if ((wm_command_count > 0) && (wm_command))
             ^~~~~~~~~~~~~~~~
    session.c:592:17: note: remove the '&&' if its condition is always true
        if (xstreq (client_id, m->client_id))
                    ^
    session.c:578:26: note: initialize the variable 'wm_command_count' to silence this warning
        gint wm_command_count;
                             ^
                              = 0
    

Merge request reports