Skip to content

mb2hal: Fix module info placement and cppcheck problem - #4483

Merged
grandixximo merged 1 commit into
LinuxCNC:masterfrom
BsAtHome:fix_mb2hal-modinfo
Aug 29, 2026
Merged

mb2hal: Fix module info placement and cppcheck problem#4483
grandixximo merged 1 commit into
LinuxCNC:masterfrom
BsAtHome:fix_mb2hal-modinfo

Conversation

@BsAtHome

Copy link
Copy Markdown
Contributor

The new cppcheck in Ubuntu 26.04 (for future CI, see #4477) would trip on a define test of MODULE_VERBOSE. The placement was wrong in the header and the usage should be replaced with MODULE_INFO as used everywhere else.

This PR addresses the issue. It also removes the RTAPI dependent inclusion check of rtapi_app.h (probably copy-pasted from a compiled component). This is a user-space program that does not need rtapi_app_main() and uses plain main().

@grandixximo

Copy link
Copy Markdown
Contributor

Good catch...

@BsAtHome
BsAtHome marked this pull request as draft August 28, 2026 14:14
@BsAtHome

Copy link
Copy Markdown
Contributor Author

Well, there is still a problem. Just installed a Ubuntu 26.04 in a VM and it still complains. Need to look deeper what is happening.

@BsAtHome
BsAtHome force-pushed the fix_mb2hal-modinfo branch from aaacba8 to 455ef16 Compare August 28, 2026 14:19
@BsAtHome
BsAtHome marked this pull request as ready for review August 28, 2026 14:19
@BsAtHome

Copy link
Copy Markdown
Contributor Author

The real issue here is that the MODULE_INFO stuff is only available when RTAPI is defined. However, that is never the case with user-space components and therefore, the whole MODULE_xxx exercise is a hopeless endeavor. It simply needs to be removed.

@hdiethelm

Copy link
Copy Markdown
Contributor

The issue looks to be how cppcheck handles #ifdef. cppcheck has to figure out which cases it should check.

You see that here, it sees #ifdef MODULE_VERBOSE and does a check with MODULE_VERBOSE=1 due to --force, which of course fails:

Checking src/hal/user_comps/mb2hal/mb2hal.c ...
Checking src/hal/user_comps/mb2hal/mb2hal.c: MODULE_VERBOSE...
src/hal/user_comps/mb2hal/mb2hal.h:36:1: error: syntax error [syntaxError]
MODULE_VERBOSE(emc2, "component:mb2hal:Userspace HAL component to communicate with one or more Modbus devices");
^
Checking src/hal/user_comps/mb2hal/mb2hal.c: RTAPI..

If there are missing includes, this generates more errors, due to cppckeck does not find KERNEL_VERSION and just assumes KERNEL_VERSION=1 for example which of course also fails. As soon as rtapi.h is found, problem solved.

See:
https://cppcheck.sourceforge.io/manual.html Automatic configuration of preprocessor defines

@grandixximo
grandixximo merged commit f353293 into LinuxCNC:master Aug 29, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants