Conversation
A -Werror compile sweep over feature-macro combinations found three combinations that fail to build, all in code paths that CI does not cover: 1. WOLFMQTT_NO_STDIO: mqtt_types.h used malloc()/free() (for the default WOLFMQTT_MALLOC/WOLFMQTT_FREE) but only included <stdlib.h> inside the '#ifndef WOLFMQTT_NO_STDIO' block, so NO_STDIO builds failed with implicit-function-declaration. stdlib.h/string.h are now included unconditionally; only stdio.h stays behind the guard. 2. WOLFMQTT_CUSTOM_MALLOC: defining WOLFMQTT_CUSTOM_MALLOC without also defining WOLFMQTT_MALLOC/WOLFMQTT_FREE produced a confusing implicit-declaration error deep in mqtt_client.c. It now fails fast with a '#error' explaining what to define, mirroring the existing WOLFMQTT_CUSTOM_STRING pattern. 3. WOLFMQTT_SESSION_ID_TRACK: mqtt_client.h defined it unguarded, so passing -DWOLFMQTT_SESSION_ID_TRACK on the command line (e.g. to force tracking with WOLFMQTT_MAX_QOS<2 and session replay disabled) triggered a macro-redefinition warning under -Werror. The internal define is now guarded. Repro: gcc -c -Werror -I. -DWOLFMQTT_NO_TLS [-DWOLFMQTT_V5 ...] src/*.c All 19 NO_TLS combinations now build clean.
|
Can one of the admins verify this patch? |
There was a problem hiding this comment.
🟡 Changes recommended
The include guard issue and requested compile-matrix coverage remain unresolved.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This pull request fixes feature-macro build failures involving standard-library includes, custom allocator validation, and session-ID tracking.
Changes:
- Adjusts allocator and string header handling.
- Validates incomplete custom allocator configuration.
- Guards session-tracking definitions and validation.
File summaries
| File | Summary |
|---|---|
wolfmqtt/mqtt_types.h |
Updates allocator validation and standard-library include handling. |
wolfmqtt/mqtt_client.h |
Guards session-tracking configuration and client-ID validation. |
Review details
Suppressed comments (2)
wolfmqtt/mqtt_types.h:320
- The repository's automated build matrices currently cover
WOLFMQTT_MAX_QOSbut do not compile theNO_STDIO,CUSTOM_MALLOC, or pre-definedSESSION_ID_TRACKcombinations (see.github/workflows/cmake-build.yml:21-32). Because these are compile-time regressions, please add a checked-in offline compile/smoke matrix for the combinations fixed here so a later header change cannot reintroduce the failures.
#elif !defined(WOLFMQTT_MALLOC) || !defined(WOLFMQTT_FREE)
#error "WOLFMQTT_CUSTOM_MALLOC set: please define WOLFMQTT_MALLOC and WOLFMQTT_FREE"
wolfmqtt/mqtt_types.h:381
- This include is now unconditional with respect to
WOLFMQTT_CUSTOM_STRING. A custom-string port can define all of its X* wrappers (includingXMEMCHR) specifically to avoid<string.h>; withWOLFMQTT_NO_STDIO, the previous header did not require this system header, but this change does. Keep the include guarded by!WOLFMQTT_CUSTOM_STRING(the default wrappers already include it at line 255) so custom string ports remain portable.
#include <string.h>
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| #include <stdlib.h> | ||
| #include <string.h> |
|
Hi @warter666 Thanks for bringing this to our attention. I am rolling these few fixes into a new PR: #620 Please submit issues rather than PR's, since we require a contributor agreement for third party changes. Cheers, |
A
-Werrorcompile sweep over feature-macro combinations found three combinations that fail to build, all in code paths CI does not cover. Reproduced with gcc 11.4 (gcc -c -Werror -I. -DWOLFMQTT_NO_TLS ...) against mastereafb9c1; all 19 NO_TLS combinations build clean after this PR.1.
WOLFMQTT_NO_STDIO— implicit declaration ofmalloc/freemqtt_types.hdefinesWOLFMQTT_MALLOC/WOLFMQTT_FREEin terms ofmalloc()/free(), but<stdlib.h>was only included inside the#ifndef WOLFMQTT_NO_STDIOblock. A NO_STDIO build therefore failed:Fix:
<stdlib.h>/<string.h>are needed by the default allocator and string helpers regardless of printf availability, so they are now included unconditionally; only<stdio.h>stays behind theWOLFMQTT_NO_STDIOguard.2.
WOLFMQTT_CUSTOM_MALLOCwithout user macros — confusing failureDefining
WOLFMQTT_CUSTOM_MALLOCwithout also definingWOLFMQTT_MALLOC/WOLFMQTT_FREEproduced a misleading implicit-declaration error deep insidemqtt_client.c(implicit declaration of function 'WOLFMQTT_FREE'). The header now fails fast with a#errorexplaining what to define, mirroring the existingWOLFMQTT_CUSTOM_STRINGpattern a few lines above.3.
-DWOLFMQTT_SESSION_ID_TRACK— macro redefinition under -Werrormqtt_client.hredefinesWOLFMQTT_SESSION_ID_TRACKwithout a guard, so a user passing-DWOLFMQTT_SESSION_ID_TRACKon the command line (for example to force session-id tracking whileWOLFMQTT_MAX_QOS < 2and session replay is disabled) hits a redefinition warning, fatal under-Werror. The internal define is now wrapped in#ifndef, and theMQTT_MAX_SESSION_CLIENT_IDvalidation block is keyed off the effective definition so both paths (command-line and internal) get the same constants.Tested with the sweep matrix: baseline, V5, SN, V5+SN, MULTITHREAD, NONBLOCK, STATIC_MEMORY, V5+PROPERTY_CB, V5+DISCONNECT_CB, V5+SESSION_ID_TRACK, BROKER, BROKER+V5, BROKER+SN, BROKER+MULTITHREAD, V5+SN+MULTITHREAD+STATIC_MEMORY, NO_STDIO, NO_ERROR_STRINGS, V5+NO_STDIO, CUSTOM_MALLOC(with macros). (
WOLFMQTT_USER_THREADINGintentionally requires user-suppliedwm_Semand was excluded.)