JorgeGzm opened a new pull request, #3695:
URL: https://github.com/apache/nuttx-apps/pull/3695
## Summary
Six statements in the NXDoom sources assign a variable to itself, which clang
rejects:
```
src/doom/f_finale.c:637:16: error: explicitly assigning value of variable of
type 'const char *' to itself [-Werror,-Wself-assign]
637 | lumpname = (lumpname);
| ~~~~~~~~ ^ ~~~~~~~~
```
Chocolate DOOM wraps those strings in `DEH_String()` so that a dehacked patch
can substitute them. The port has no dehacked support and the macro went away
with it, leaving the bare parentheses behind. This removes the six leftover
assignments, plus two comments that only described the substitution:
- `games/NXDoom/src/doom/f_finale.c`: `lumpname`, `finaletext`, `finaleflat`
- `games/NXDoom/src/doom/g_game.c`: `skytexturename` (two sites)
- `games/NXDoom/src/doom/hu_stuff.c`: `s`
## Impact
Build only, and only for configurations compiled with clang. GCC does not
warn
about self-assignment, so the configurations built so far never noticed it;
clang does, and the build fails because the CI passes `-Werror`
(`tools/ci/cibuild.sh`: `-e "-Wno-cpp -Werror"`). The nxdoom configurations
are
`sim:nxdoom`, `linum-stm32h753bi:nxdoom` and `raspberrypi-4b:nxdoom`.
No functional change: the removed statements are no-ops. They were not
entirely
free, though -- the nxdoom configurations build with `CONFIG_DEBUG_NOOPT=y`,
so
the redundant stores were actually emitted, and the image loses 16 bytes of
text (see the sizes below). No change to the API, configuration, build system
or documentation.
## Testing
Host: Ubuntu 24.04.4 LTS, x86_64, Linux 7.0.0-28-generic
- clang 18.1.3, LLVM binutils 18 (`CONFIG_ARM_TOOLCHAIN_CLANG=y`)
- arm-none-eabi-gcc 13.2.1 (Arm GNU Toolchain 13.2.rel1)
Target: arm, `linum-stm32h753bi:nxdoom`
Both builds use the same warning flags the CI uses:
`make EXTRAFLAGS="-Wno-cpp -Werror"`.
### Before, clang
```
$ make -k -j EXTRAFLAGS="-Wno-cpp -Werror"
src/doom/f_finale.c:637:16: error: explicitly assigning value of variable of
type 'const char *' to itself [-Werror,-Wself-assign]
637 | lumpname = (lumpname);
| ~~~~~~~~ ^ ~~~~~~~~
src/doom/f_finale.c:693:14: error: explicitly assigning value of variable of
type 'const char *' to itself [-Werror,-Wself-assign]
693 | finaletext = (finaletext);
| ~~~~~~~~~~ ^ ~~~~~~~~~~
src/doom/f_finale.c:694:14: error: explicitly assigning value of variable of
type 'const char *' to itself [-Werror,-Wself-assign]
694 | finaleflat = (finaleflat);
| ~~~~~~~~~~ ^ ~~~~~~~~~~
src/doom/hu_stuff.c:386:5: error: explicitly assigning value of variable of
type 'const char *' to itself [-Werror,-Wself-assign]
src/doom/g_game.c:445:22: error: explicitly assigning value of variable of
type 'const char *' to itself [-Werror,-Wself-assign]
src/doom/g_game.c:2288:22: error: explicitly assigning value of variable of
type 'const char *' to itself [-Werror,-Wself-assign]
make[2]: *** [apps/Application.mk:264: src/doom/f_finale.c...o] Error 1
```
### After, clang
Compiles with no warnings and no errors.
### After, arm-none-eabi-gcc 13.2.1
```
$ make -j EXTRAFLAGS="-Wno-cpp -Werror"
$ arm-none-eabi-size nuttx
text data bss dec hex filename
616070 42876 262656 921602 e1002 nuttx
```
Same configuration before the change, for comparison:
```
text data bss dec hex filename
616086 42876 262656 921618 e1012 nuttx
```
`data` and `bss` are unchanged; `text` drops the 16 bytes of the redundant
stores.
### Runtime
The resulting image was flashed on a LINUM-STM32H753BI over ST-LINK-V3 and
nxdoom was run from the NSH prompt: the game starts and plays exactly as it
did
before the change, as expected for statements that had no effect.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]