[PATCH 1/2] ndr: restore libndr.so.2 ABI compatibility: ndr_print_debug

Michael Tokarev mjt at tls.msk.ru
Tue Nov 1 09:21:12 UTC 2022


Commit 7b9f87b877bd385e8cec893cd282d4b3fc00206d changed signature of
ndr_print_debug function and for this very purpose, incremented an
soname of whole library, instead of providing a trivial compatibility
symbol. Do this now to restore the damage for a bit.

Rename the newly introduced function to ndr_print_debug_level(), modify
it to accept NULL for the new "location" arguments, and introduce old
ndr_print_debug() function with the old signature, making it a trivial
wrapper around the new ndr_print_debug_level().

Include this symbol change directly into ndr-3.0.0.sigs, since the next
patch will rename this file into ndr-2.0.1.sigs.

Signed-off-by: Michael Tokarev <mjt at tls.msk.ru>
---
 librpc/ABI/ndr-3.0.0.sigs |  3 ++-
 librpc/ndr/libndr.h       |  6 +++---
 librpc/ndr/ndr.c          | 28 +++++++++++++++++++++-------
 3 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/librpc/ABI/ndr-3.0.0.sigs b/librpc/ABI/ndr-3.0.0.sigs
index d3f3eca26ae..347f278fae7 100644
--- a/librpc/ABI/ndr-3.0.0.sigs
+++ b/librpc/ABI/ndr-3.0.0.sigs
@@ -42,7 +42,8 @@ ndr_print_array_uint8: void (struct ndr_print *, const char *, const uint8_t *,
 ndr_print_bad_level: void (struct ndr_print *, const char *, uint16_t)
 ndr_print_bitmap_flag: void (struct ndr_print *, size_t, const char *, uint32_t, uint32_t)
 ndr_print_bool: void (struct ndr_print *, const char *, const bool)
-ndr_print_debug: bool (int, ndr_print_fn_t, const char *, void *, const char *, const char *)
+ndr_print_debug: void (ndr_print_fn_t, const char *, void *)
+ndr_print_debug_level: bool (int, ndr_print_fn_t, const char *, void *, const char *, const char *)
 ndr_print_debug_helper: void (struct ndr_print *, const char *, ...)
 ndr_print_debugc: void (int, ndr_print_fn_t, const char *, void *)
 ndr_print_debugc_helper: void (struct ndr_print *, const char *, ...)
diff --git a/librpc/ndr/libndr.h b/librpc/ndr/libndr.h
index 98f8ff870d2..bfabd3a8b73 100644
--- a/librpc/ndr/libndr.h
+++ b/librpc/ndr/libndr.h
@@ -214,7 +214,7 @@ struct ndr_print {
 #define LIBNDR_FLAG_NO_NDR_SIZE		(1U<<31)
 
 /* useful macro for debugging */
-#define NDR_PRINT_DEBUG(type, p) (void)ndr_print_debug(1, (ndr_print_fn_t)ndr_print_ ##type, #p, p, __location__, __func__)
+#define NDR_PRINT_DEBUG(type, p) (void)ndr_print_debug_level(1, (ndr_print_fn_t)ndr_print_ ##type, #p, p, __location__, __func__)
 #define NDR_PRINT_DEBUGC(dbgc_class, type, p) ndr_print_debugc(dbgc_class, (ndr_print_fn_t)ndr_print_ ##type, #p, p)
 #define NDR_PRINT_UNION_DEBUG(type, level, p) ndr_print_union_debug((ndr_print_fn_t)ndr_print_ ##type, #p, level, p)
 #define NDR_PRINT_FUNCTION_DEBUG(type, flags, p) ndr_print_function_debug((ndr_print_function_t)ndr_print_ ##type, #type, flags, p)
@@ -239,7 +239,7 @@ struct ndr_print {
  */
 #define NDR_PRINT_DEBUG_LEVEL(l, type, p) \
 	(void) ( CHECK_DEBUGLVL(l) \
-		&& ndr_print_debug(l, (ndr_print_fn_t)ndr_print_ ##type, #p, p, __location__, __func__) )
+		&& ndr_print_debug_level(l, (ndr_print_fn_t)ndr_print_ ##type, #p, p, __location__, __func__) )
 
 /* useful macro for debugging in strings */
 #define NDR_PRINT_STRUCT_STRING(ctx, type, p) ndr_print_struct_string(ctx, (ndr_print_fn_t)ndr_print_ ##type, #p, p)
@@ -617,7 +617,7 @@ void ndr_print_debug_helper(struct ndr_print *ndr, const char *format, ...) PRIN
 void ndr_print_debugc_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
 void ndr_print_printf_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
 void ndr_print_string_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
-bool ndr_print_debug(int level, ndr_print_fn_t fn, const char *name, void *ptr, const char *location, const char *function);
+bool ndr_print_debug_level(int level, ndr_print_fn_t fn, const char *name, void *ptr, const char *location, const char *function);
 void ndr_print_debugc(int dbgc_class, ndr_print_fn_t fn, const char *name, void *ptr);
 void ndr_print_union_debug(ndr_print_fn_t fn, const char *name, uint32_t level, void *ptr);
 void ndr_print_function_debug(ndr_print_function_t fn, const char *name, int flags, void *ptr);
diff --git a/librpc/ndr/ndr.c b/librpc/ndr/ndr.c
index 25765880d8b..c9d6fb1de0a 100644
--- a/librpc/ndr/ndr.c
+++ b/librpc/ndr/ndr.c
@@ -428,16 +428,21 @@ _PUBLIC_ void ndr_print_debugc(int dbgc_class, ndr_print_fn_t fn, const char *na
 /*
   a useful helper function for printing idl structures via DEBUG()
 */
-_PUBLIC_ bool ndr_print_debug(int level,
-			      ndr_print_fn_t fn,
-			      const char *name,
-			      void *ptr,
-			      const char *location,
-			      const char *function)
+_PUBLIC_ bool ndr_print_debug_level(int level,
+			            ndr_print_fn_t fn,
+			            const char *name,
+			            void *ptr,
+			            const char *location,
+			            const char *function)
 {
 	struct ndr_print *ndr;
 
-	DEBUGLF(level, (" "), location, function);
+	if (location) {
+		DEBUGLF(level, (" "), location, function);
+	} else {
+		/* called from ndr_print_debug() compatibility wrapper below */
+		DEBUG(1,(" "));
+	}
 
 	ndr = talloc_zero(NULL, struct ndr_print);
 	if (!ndr) return false;
@@ -455,6 +460,15 @@ _PUBLIC_ bool ndr_print_debug(int level,
 	return true;
 }
 
+/*
+  old compatibility wrapper without location information for libndr before 4.17
+  (do not change the signature!)
+*/
+_PUBLIC_ void ndr_print_debug(ndr_print_fn_t fn, const char *name, void *ptr)
+{
+	ndr_print_debug_level(1, fn, name, ptr, NULL, NULL);
+}
+
 /*
   a useful helper function for printing idl unions via DEBUG()
 */
-- 
2.30.2




More information about the samba-technical mailing list