Description of problem: Version-Release number of selected component (if applicable): rpm -qf /usr/include/samba-4.0/ndr.h samba-devel-4.10.0-0.0.rc1.fc30.x86_64 How reproducible: Deterministic Steps to Reproduce: 1. dnf install -y gcc samba-devel pkgconf-pkg-config 2. cat >test.c <<EOF #include <ndr.h> #define ZERO_STRUCT(x) cool_function((char *)&(x), sizeof(x), 0, sizeof(x)) int main(void) { return 0; } EOF 3. gcc `pkg-config --cflags ndr` pok.c Actual results: pok.c:3: warning: "ZERO_STRUCT" redefined 3 | #define ZERO_STRUCT(x) memset((char *)&(x), sizeof(x), 0, sizeof(x)) | In file included from /usr/include/samba-4.0/ndr.h:29, from pok.c:1: /usr/include/samba-4.0/util/memory.h:54: note: this is the location of the previous definition 54 | #define ZERO_STRUCT(x) memset_s((char *)&(x), sizeof(x), 0, sizeof(x)) | Expected results: No warnings are generated. Additional info: I assume that the header file /usr/include/samba-4.0/util/memory.h is public because the macro discard_const (defined in util/memory.h) is used in another macro in ndr.h sh$ grep -n -C5 discard_const /usr/include/samba-4.0/ndr.h 373-#define NDR_PULL_SET_MEM_CTX(ndr, mem_ctx, flgs) do {\ 374- if ( !(flgs) || (ndr->flags & flgs) ) {\ 375- if (!(mem_ctx)) {\ 376- return ndr_pull_error(ndr, NDR_ERR_ALLOC, "NDR_PULL_SET_MEM_CTX(NULL): %s\n", __location__); \ 377- }\ 378: ndr->current_mem_ctx = discard_const(mem_ctx);\ 379- }\ 380-} while(0) 381- 382-#define _NDR_PULL_FIX_CURRENT_MEM_CTX(ndr) do {\ 383- if (!ndr->current_mem_ctx) {\ Making macros without any prefix is not idea way. People will need to undefine then and then define with different content.
IMHO, samba-devel should either provides prefixed macros in /usr/include/samba-4.0/util/memory.h or they should not be provided at all + and you might replace usage of `discard_const` in public ndr.h with (void *)(uintptr_t)
BTW I know that these macros are in samba for ages. But they have never been public, If you want to have them public then they should have unique prefix. (Unfortunately, C does not have namespaces)
The file has: 53 #ifndef ZERO_STRUCT 54 #define ZERO_STRUCT(x) memset_s((char *)&(x), sizeof(x), 0, sizeof(x)) 55 #endif so if you define your ZERO_STRUCT first, it will be overwritten. However, the question is if memory.h should be a public header and included in others. The same appies for byteorder.h.
This BZ can be closed as a duplicate of 1672231 https://src.fedoraproject.org/rpms/samba/c/57d362cb8f13e5dfa0f19d868852f67f8e30f3ff?branch=master
Closing, thanks! *** This bug has been marked as a duplicate of bug 1672231 ***