Bug 16188 - Build failure with cmocka >= 2.0: cm_print_error() conflicts with cmocka.h macro
Summary: Build failure with cmocka >= 2.0: cm_print_error() conflicts with cmocka.h macro
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Build (show other bugs)
Version: 4.23.10
Hardware: All All
: P5 major (vote)
Target Milestone: ---
Assignee: Samba release manager
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-07-28 07:17 UTC by Anoop C S
Modified: 2026-08-11 18:23 UTC (History)
3 users (show)

See Also:


Attachments
patch from master for v4-23-test (14.30 KB, patch)
2026-07-28 08:21 UTC, Anoop C S
bjacke: review-
Details
patch from master for v4-23-test (14.52 KB, patch)
2026-07-29 10:41 UTC, Anoop C S
bjacke: review-
Details
patch from master for v4-23-test v2 (53.40 KB, patch)
2026-08-04 08:32 UTC, Anoop C S
asn: review+
anoopcs: ci-passed+
Details
patch from master for v4-23-test v2 (53.44 KB, patch)
2026-08-04 13:57 UTC, Anoop C S
asn: review+
anoopcs: ci-passed+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Anoop C S 2026-07-28 07:17:05 UTC
Samba fails to compile with cmocka >= 2.0 (e.g., libcmocka-2.0.2 as shipped in Fedora 44) due to a conflict between a forward declaration of cm_print_error() in Samba test source files and the cmocka.h header, which redefines cm_print_error as a deprecated compatibility macro (using do { ... } while(0)) wrapping the new cmocka_print_error() function.

The build fails in two test files:

source4/dsdb/samdb/ldb_modules/tests/test_group_audit.c:
source4/dsdb/samdb/ldb_modules/tests/test_group_audit.c:110:6: error: expected identifier or '(' before 'do'
  110 | void cm_print_error(const char * const format, ...);
      |      ^~~~~~~~~~~~~~
source4/dsdb/samdb/ldb_modules/tests/test_group_audit.c:110:6: error: expected identifier or '(' before 'while'
  110 | void cm_print_error(const char * const format, ...);
      |      ^~~~~~~~~~~~~~


libcli/ldap/tests/ldap_message_test.c:
libcli/ldap/tests/ldap_message_test.c:50:6: error: expected identifier or '(' before 'do'
   50 | void cm_print_error(const char * const format, ...);
      |      ^~~~~~~~~~~~~~
libcli/ldap/tests/ldap_message_test.c:50:6: error: expected identifier or '(' before 'while'
   50 | void cm_print_error(const char * const format, ...);
      |      ^~~~~~~~~~~~~~


Additional notes:
The root cause is that both files contain explicit forward declarations of cm_print_error() which was previously an internal cmocka function. In cmocka >= 2.0, cm_print_error is a macro, so void cm_print_error(...) is expanded by the preprocessor into invalid syntax.

Additionally, cmocka >= 2.0 requires <stdint.h> to be included before <cmocka.h>, which is missing from several test files.
Comment 1 Anoop C S 2026-07-28 08:21:13 UTC
Created attachment 19137 [details]
patch from master for v4-23-test
Comment 2 Björn Jacke 2026-07-29 10:37:38 UTC
can you also please add BUG: lines to each of the commits?
Comment 3 Anoop C S 2026-07-29 10:41:52 UTC
Created attachment 19144 [details]
patch from master for v4-23-test
Comment 4 Björn Jacke 2026-07-29 13:30:10 UTC
Comment on attachment 19144 [details]
patch from master for v4-23-test

this doesn't compile successfully with enable-developer in autobuild
Comment 5 Anoop C S 2026-08-04 08:32:24 UTC
Created attachment 19148 [details]
patch from master for v4-23-test v2
Comment 6 Andreas Schneider 2026-08-04 12:17:42 UTC
Comment on attachment 19148 [details]
patch from master for v4-23-test v2

lgtm
Comment 7 Anoop C S 2026-08-04 13:57:46 UTC
Created attachment 19149 [details]
patch from master for v4-23-test v2
Comment 8 Samba QA Contact 2026-08-11 18:23:36 UTC
This bug was referenced in samba v4-23-test:

43643e440dbd938a0b26a2a8f95f481bc72a387c
c6c02cffa96dd0b647317d3af9a3bbcb56e826cf
1ea76986e4be355f9f5f0d2f78aa73e220bbc58f
b73a7d4188dbd0b3d064081462287dc25f0ae433
23a748cf39e584a447da96536c27d056381dfe4e