ekeeke / Genesis-Plus-GX

An enhanced port of Genesis Plus - accurate & portable Sega 8/16 bit emulator
Other
673 stars 193 forks source link

Fix -Wmaybe-uninitialized warnings #502

Closed orbea closed 1 year ago

orbea commented 1 year ago

This silences some verbose -Wmaybe-uninitialized warnings with gcc 12.2.1.

@ekeeke please review for correctness.

    In function 'xe_1ap_read',
        inlined from 'xe_1ap_1_read' at core/input_hw/xe_1ap.c:158:10:
    core/input_hw/xe_1ap.c:108:8: warning: 'data' may be used uninitialized [-Wmaybe-uninitialized]
      108 |   data |= ((xe_1ap[index].Counter & 1) << 4);
          |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    core/input_hw/xe_1ap.c: In function 'xe_1ap_1_read':
    core/input_hw/xe_1ap.c:63:17: note: 'data' was declared here
       63 |   unsigned char data;
          |                 ^~~~
    In function 'xe_1ap_read',
        inlined from 'xe_1ap_2_read' at core/input_hw/xe_1ap.c:163:10:
    core/input_hw/xe_1ap.c:108:8: warning: 'data' may be used uninitialized [-Wmaybe-uninitialized]
      108 |   data |= ((xe_1ap[index].Counter & 1) << 4);
          |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    core/input_hw/xe_1ap.c: In function 'xe_1ap_2_read':
    core/input_hw/xe_1ap.c:63:17: note: 'data' was declared here
       63 |   unsigned char data;
          |                 ^~~~
    core/vdp_render.c: In function 'render_bg_m5_vs_enhanced':
    core/vdp_render.c:2085:22: warning: 'v_offset' may be used uninitialized [-Wmaybe-uninitialized]
     2085 |       v_line = (line + v_offset + vs[column]) & pf_row_mask;
          |                 ~~~~~^~~~~~~~~~
    core/vdp_render.c:1855:15: note: 'v_offset' was declared here
     1855 |   int column, v_offset;
          |               ^~~~~~~~
ekeeke commented 1 year ago

Thanks for pull request but I ended up fixing this myself (in a similar but not exactly the same way). See https://github.com/ekeeke/Genesis-Plus-GX/commit/c4077c4f2406fa7cbaf2ca88a72995ccbcb2ac70

orbea commented 1 year ago

@ekeeke Thanks!