mc/lib
Andreas Mohr 053108afd2 (widget_focus): fix -Wanalyzer-deref-before-check warning
widget-common.c: In function 'widget_focus':
widget-common.c:123:12: error: check of '*g.current' for NULL after already dereferencing it []8;;https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Static-Analyzer-Options.html#index-Wanalyzer-deref-before-check-Werror=analyzer-deref-before-check]8;;]
  123 |         if (g->current == NULL || !widget_get_state (WIDGET (g->current->data), WST_FOCUSED))
      |            ^
  'widget_focus': event 1
    |
    |  116 |     if (g == NULL)
    |      |        ^
    |      |        |
    |      |        (1) following 'false' branch (when 'g' is non-NULL)...
    |
  'widget_focus': event 2
    |
    |  119 |     if (WIDGET (g->current->data) != w)
    |      |                 ~^~~~~~~~~
    |      |                  |
    |      |                  (2) ...to here
../../lib/widget/widget-common.h:15:31: note: in definition of macro 'WIDGET'
    |   15 | #define WIDGET(x) ((Widget *)(x))
    |      |                               ^
    |
  'widget_focus': event 3
    |
    |widget-common.c:119:27:
    |  119 |     if (WIDGET (g->current->data) != w)
../../lib/widget/widget-common.h:15:31: note: in definition of macro 'WIDGET'
    |   15 | #define WIDGET(x) ((Widget *)(x))
    |      |                               ^
    |
  'widget_focus': events 4-6
    |
    |widget-common.c:119:8:
    |  119 |     if (WIDGET (g->current->data) != w)
    |      |        ^
    |      |        |
    |      |        (4) following 'true' branch...
    |  120 |     {
    |  121 |         widget_do_focus (WIDGET (g->current->data), FALSE);
    |      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |         |
    |      |         (5) ...to here
    |  122 |         /* Test if focus lost was allowed and focus has really been loose */
    |  123 |         if (g->current == NULL || !widget_get_state (WIDGET (g->current->data), WST_FOCUSED))
    |      |            ~
    |      |            |
    |      |            (6) pointer '*g.current' is checked for NULL here but it was already dereferenced at (3)
    |

Found by gcc-14 analyzer

Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-15 14:06:21 +03:00
..
event Indentation using GNU indent-2.2.13. 2024-06-02 12:49:13 +03:00
filehighlight Indentation using GNU indent-2.2.13. 2024-06-02 12:49:13 +03:00
mcconfig Indentation using GNU indent-2.2.13. 2024-06-02 12:49:13 +03:00
search Ticket #4587: mcviewer: fix BOL regex search. 2024-12-15 13:46:52 +03:00
skin Indentation using GNU indent-2.2.13. 2024-06-02 12:49:13 +03:00
strutil src/strutil/xstrtol.c: sync with gnulib. 2024-10-05 15:05:58 +03:00
tty Ticket #4584: re-implement mocking via weak symbols instead of symbol duplication 2024-10-19 08:56:40 +02:00
vfs Ticket #4584: re-implement mocking via weak symbols instead of symbol duplication 2024-10-19 08:56:40 +02:00
widget (widget_focus): fix -Wanalyzer-deref-before-check warning 2024-12-15 14:06:21 +03:00
charsets.c Fix typos/improve grammar in charsets.c / strutil.h 2024-10-05 15:07:13 +03:00
charsets.h (str_convert_to_input): make inline. 2021-03-14 19:30:42 +03:00
event-types.h Reimplement handling of ev_vfs_print_message_t message. 2015-11-05 14:33:21 +03:00
event.h Use argument names in function declarations. 2021-06-20 15:14:56 +03:00
file-entry.h file_entry_t: rename members: 2023-08-04 21:04:54 +03:00
filehighlight.h Move definition of file_entry_t to separate file. 2023-03-19 20:34:23 +03:00
fileloc.h Rename FISH VFS to SHELL one. 2023-10-15 16:04:39 +03:00
fs.h vfs_dirent: add new member d_len to get rid of d_name length calculation. 2024-06-02 12:41:34 +03:00
glibcompat.c glibcompat: remove g_direct_equal shim 2024-06-03 16:18:12 +02:00
glibcompat.h (mc_g_string_append_c_len): new API that extends GString one. 2024-06-02 12:41:34 +03:00
global.c Update copyright years. 2024-01-01 09:46:17 +03:00
global.h mountlist: suppress unused label warning on FreeBSD 2024-11-01 17:37:10 +01:00
hook.c Indentation using GNU indent-2.2.13. 2024-06-02 12:49:13 +03:00
hook.h
idx.h Add some files and code rom Gnulib as preparation to TAR updates. 2024-10-05 15:07:13 +03:00
intprops-internal.h Add some files and code rom Gnulib as preparation to TAR updates. 2024-10-05 15:07:13 +03:00
intprops.h Ticket #4593: tar: fix compilation on systems w/o stdckdint.h. 2024-10-08 13:02:17 +03:00
keybind.c Indentation using GNU indent-2.2.13. 2024-06-02 12:49:13 +03:00
keybind.h Rename FISH VFS to SHELL one. 2023-10-15 16:04:39 +03:00
lock.c Indentation using GNU indent-2.2.13. 2024-06-02 12:49:13 +03:00
lock.h
logging.c Update copyright years. 2024-01-01 09:46:17 +03:00
logging.h Clarify __attribute ((format (printf))) usage. 2015-11-05 14:33:20 +03:00
Makefile.am Ticket #4593: tar: fix compilation on systems w/o stdckdint.h. 2024-10-08 13:02:17 +03:00
mcconfig.h Ticket #4584: re-implement mocking via weak symbols instead of symbol duplication 2024-10-19 08:56:40 +02:00
search.h Ticket #4587: mcviewer: fix BOL regex search. 2024-12-15 13:46:52 +03:00
serialize.c Indentation using GNU indent-2.2.13. 2024-06-02 12:49:13 +03:00
serialize.h lib/mcconfig: fix coding style; apply source file template. 2019-09-01 19:41:12 +03:00
shell.c Indentation using GNU indent-2.2.13. 2024-06-02 12:49:13 +03:00
shell.h Fix typos. 2020-12-31 16:26:46 +03:00
skin.h Ticket #4433: skins: add color for non-printable characters in editor. 2023-12-10 17:47:07 +03:00
stat-size.h Remove Cray support. 2020-10-13 16:34:55 +03:00
stdckdint.in.h Add some files and code rom Gnulib as preparation to TAR updates. 2024-10-05 15:07:13 +03:00
strutil.h doc: fix typos in comments 2024-10-05 18:55:01 +02:00
timefmt.c Update copyright years. 2024-01-01 09:46:17 +03:00
timefmt.h Fix various typos in the source code (closes MidnightCommander/mc#177). 2023-01-28 21:38:05 +03:00
unixcompat.h vfs: implement support for all known stat formats and centralize handling 2024-07-28 10:00:52 +02:00
util.c Ticket #4597: fix CSI parser 2024-11-01 18:10:09 +01:00
util.h Ticket #4584: re-implement mocking via weak symbols instead of symbol duplication 2024-10-19 08:56:40 +02:00
utilunix.c (canonicalize_pathname_custom): fix --disable-charset build broken in 8f723b8 2024-10-26 18:22:53 +02:00
widget.h Create WBackground widget. 2020-03-08 20:17:29 +03:00