Skip to content

Comments

Fix nmsgtool compiler warning when building without rdkafka/json-c#181

Open
regalk13 wants to merge 4 commits intonextfrom
fix-compiler-warn
Open

Fix nmsgtool compiler warning when building without rdkafka/json-c#181
regalk13 wants to merge 4 commits intonextfrom
fix-compiler-warn

Conversation

@regalk13
Copy link

@regalk13 regalk13 commented Feb 4, 2026

  • Removed guards around function calls, which was causing unused function warning.

  • Tests were failing when json-c was disabled because they unconditionally called json-related functions that weren't available. This PR adds conditional test execution by exporting a USE_JSON variable from the build system and wrapping all json-dependent operations in conditionals across all tests. When json-c is disabled, tests now execute no-op commands followed by check calls to properly register as passing rather than failing on unavailable functions.

fprintf(stderr, "%s: Error: nmsg protocol must be set for Kafka topic\n",
argv_program);
#endif /* HAVE_JSON_C */
exit(EXIT_FAILURE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit weird, but these calls to exit() must be kept here for internal consistency with the rest of the helper functions that also call exit(1) in the event of an error... it's done a million places in src/io.c ...

fprintf(stderr, "%s: Error: nmsg protocol must be set for Kafka topic\n",
argv_program);
#endif /* HAVE_JSON_C */
exit(EXIT_FAILURE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same instruction as above

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added back the exit(EXIT_FAILURE) for both.

examples/print_version


AM_TESTS_ENVIRONMENT = export USE_JSON="$(use_json_c)";
Copy link
Contributor

@kadealicious kadealicious Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this line necessary, considering we run the following assignment in shell tests (and have HAVE_JSON_C in the C tests):

USE_JSON="@use_json_c@"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shell tests with a template .sh.in works without problem using USE_JSON="@use_json_c@", the variables are replaced at ./configure stage. The problem is that there are at least two tests (tests/test-kicker.sh, tests/test-sample.sh) that do not have template, and therefore the only way to access the value of use_json_c in the same way is by generating an ENV variable.

However, a good alternative could be to use the variable in all shell tests.

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