Skip to content

OPCUA-3371 Refactor subscriber method to simplify CAN frame reading logic#106

Merged
luismiguensfernandez merged 1 commit into
masterfrom
fix/clang-warning
Jun 8, 2026
Merged

OPCUA-3371 Refactor subscriber method to simplify CAN frame reading logic#106
luismiguensfernandez merged 1 commit into
masterfrom
fix/clang-warning

Conversation

@luismiguensfernandez

Copy link
Copy Markdown
Member

CLang detected a code-smell:

scan-build: Analysis run complete.
scan-build: Analysis results (plist files) deposited in '/builds/quasar-team/CanModule/build-clang/scan-build-reports/2026-06-07-235511-3040-1'
SCAN_PROJECT_COUNT=0
[clang-analysis] Running clang-tidy
Suppressed 1 warnings (1 NOLINT).
1 warning generated.
/builds/quasar-team/CanModule/src/main/CanVendorSocketCan.cpp:392:11: error: Out of bound access to memory after the end of 'events' [clang-analyzer-security.ArrayBound,-warnings-as-errors]
  392 |       if (events[i].data.fd == m_socket_fd) {
      |           ^~~~~~~~~
/builds/quasar-team/CanModule/src/main/CanVendorSocketCan.cpp:377:3: note: Loop condition is true.  Entering loop body
  377 |   while (m_subcriber_run) {
      |   ^
/builds/quasar-team/CanModule/src/main/CanVendorSocketCan.cpp:379:9: note: Assuming 'nfds' is >= 0
  379 |     if (nfds < 0) {
      |         ^~~~~~~~
/builds/quasar-team/CanModule/src/main/CanVendorSocketCan.cpp:379:5: note: Taking false branch
  379 |     if (nfds < 0) {
      |     ^
/builds/quasar-team/CanModule/src/main/CanVendorSocketCan.cpp:391:21: note: Assuming 'i' is < 'nfds'
  391 |     for (int i = 0; i < nfds; ++i) {
      |                     ^~~~~~~~
/builds/quasar-team/CanModule/src/main/CanVendorSocketCan.cpp:391:5: note: Loop condition is true.  Entering loop body
  391 |     for (int i = 0; i < nfds; ++i) {
      |     ^
/builds/quasar-team/CanModule/src/main/CanVendorSocketCan.cpp:392:11: note: Assuming field 'fd' is not equal to field 'm_socket_fd'
  392 |       if (events[i].data.fd == m_socket_fd) {
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/builds/quasar-team/CanModule/src/main/CanVendorSocketCan.cpp:392:7: note: Taking false branch
  392 |       if (events[i].data.fd == m_socket_fd) {
      |       ^
/builds/quasar-team/CanModule/src/main/CanVendorSocketCan.cpp:391:21: note: Assuming 'i' is < 'nfds'
  391 |     for (int i = 0; i < nfds; ++i) {
      |                     ^~~~~~~~
/builds/quasar-team/CanModule/src/main/CanVendorSocketCan.cpp:391:5: note: Loop condition is true.  Entering loop body
  391 |     for (int i = 0; i < nfds; ++i) {
      |     ^
/builds/quasar-team/CanModule/src/main/CanVendorSocketCan.cpp:392:11: note: Access of 'events' at index 1, while it holds only a single 'struct epoll_event' element
  392 |       if (events[i].data.fd == m_socket_fd) {
      |           ^~~~~~~~~
Suppressed 1 warnings (1 NOLINT).
1 warning treated as error
[clang-analysis] clang-tidy findings (project sources only):
/builds/quasar-team/CanModule/src/main/CanVendorSocketCan.cpp:392:11: error: Out of bound access to memory after the end of 'events' [clang-analyzer-security.ArrayBound,-warnings-as-errors]
[clang-analysis] ERROR: analyzer failures detected (scan-invocation-failed=0, scan-build-exit=0, scan-project-findings=0, clang-tidy=1)

@luismiguensfernandez luismiguensfernandez merged commit d3be301 into master Jun 8, 2026
13 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.

1 participant