Skip to content

core_dyn_x86: Initialise rettype to avoid compiler warning#2365

Merged
kcgen merged 1 commit intodosbox-staging:mainfrom
sulix:rettype_risc
Mar 25, 2023
Merged

core_dyn_x86: Initialise rettype to avoid compiler warning#2365
kcgen merged 1 commit intodosbox-staging:mainfrom
sulix:rettype_risc

Conversation

@sulix
Copy link
Copy Markdown
Contributor

@sulix sulix commented Mar 25, 2023

tl;dr: A quick warning fix with gcc 13 I found while looking at the OPL stuff.

gcc 13 warns when uninitialised data could be read, and picks up the following in risc_x64.h:

In file included from ../src/cpu/core_dyn_x86.cpp:199:
../src/cpu/core_dyn_x86/risc_x64.h: In function ‘void gen_call_function(void*, const char*, ...)’:
../src/cpu/core_dyn_x86/risc_x64.h:1127:25: warning: ‘rettype’ may be used uninitialized [-Wmaybe-uninitialized]
 1127 |                         switch (rettype) {
      |                         ^~~~~~
../src/cpu/core_dyn_x86/risc_x64.h:1075:14: note: ‘rettype’ was declared here
 1075 |         char rettype;
      |              ^~~~~~~

While this isn't actually a problem (rettype is only read if dynret is non-NULL, and dynret is only set when rettype is), it's probably worth initialising rettype just to keep the build warning-free.

gcc 13 warns when uninitialised data could be read, and picks up the
following in risc_x64.h:
```
In file included from ../src/cpu/core_dyn_x86.cpp:199:
../src/cpu/core_dyn_x86/risc_x64.h: In function ‘void gen_call_function(void*, const char*, ...)’:
../src/cpu/core_dyn_x86/risc_x64.h:1127:25: warning: ‘rettype’ may be used uninitialized [-Wmaybe-uninitialized]
 1127 |                         switch (rettype) {
      |                         ^~~~~~
../src/cpu/core_dyn_x86/risc_x64.h:1075:14: note: ‘rettype’ was declared here
 1075 |         char rettype;
      |              ^~~~~~~
```

While this isn't actually a problem (rettype is only read if dynret is
non-NULL, and dynret is only set when rettype is), it's probably worth
initialising rettype just to keep the build warning-free.
@kcgen kcgen added the cleanup Non-functional changes that simplify, improve maintainability, or squash warnings label Mar 25, 2023
@kcgen
Copy link
Copy Markdown
Member

kcgen commented Mar 25, 2023

Nice little cleanup; thanks for adding it @sulix !

@kcgen kcgen merged commit 6d56372 into dosbox-staging:main Mar 25, 2023
@Grounded0 Grounded0 added the CPU/FPU emulation Issues related to CPU or FPU emulation label Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup Non-functional changes that simplify, improve maintainability, or squash warnings CPU/FPU emulation Issues related to CPU or FPU emulation

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants