Move discard_const hack to memory.hso it can be used by Samba 3.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 20 Oct 2008 15:15:17 +0000 (17:15 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 20 Oct 2008 15:15:17 +0000 (17:15 +0200)
lib/util/memory.h
lib/util/util.h

index de01492aa255f7e8678d9f4c291a3420af8e4ae9..cfc13ab8360c2aec6f33a7192bd5156183b9e381 100644 (file)
 #define PTR_DIFF(p1,p2) ((ptrdiff_t)(((const char *)(p1)) - (const char *)(p2)))
 #endif
 
+/**
+  this is a warning hack. The idea is to use this everywhere that we
+  get the "discarding const" warning from gcc. That doesn't actually
+  fix the problem of course, but it means that when we do get to
+  cleaning them up we can do it by searching the code for
+  discard_const.
+
+  It also means that other error types aren't as swamped by the noise
+  of hundreds of const warnings, so we are more likely to notice when
+  we get new errors.
 
+  Please only add more uses of this macro when you find it
+  _really_ hard to fix const warnings. Our aim is to eventually use
+  this function in only a very few places.
+
+  Also, please call this via the discard_const_p() macro interface, as that
+  makes the return type safe.
+*/
+#ifndef discard_const
+#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
+#endif
+
+/** Type-safe version of discard_const */
+#ifndef discard_const_p
+#define discard_const_p(type, ptr) ((type *)discard_const(ptr))
+#endif
 
 #endif /* _SAMBA_MEMORY_H_ */
index 4c9a2230937a0b0270c13e6d94d1e31eed57e867..110286dbc865496b18e8a7b02890074774ce975b 100644 (file)
@@ -45,33 +45,6 @@ extern const char *panic_action;
 #include "../lib/util/mutex.h"
 #include "../lib/util/byteorder.h"
 
-/**
-  this is a warning hack. The idea is to use this everywhere that we
-  get the "discarding const" warning from gcc. That doesn't actually
-  fix the problem of course, but it means that when we do get to
-  cleaning them up we can do it by searching the code for
-  discard_const.
-
-  It also means that other error types aren't as swamped by the noise
-  of hundreds of const warnings, so we are more likely to notice when
-  we get new errors.
-
-  Please only add more uses of this macro when you find it
-  _really_ hard to fix const warnings. Our aim is to eventually use
-  this function in only a very few places.
-
-  Also, please call this via the discard_const_p() macro interface, as that
-  makes the return type safe.
-*/
-#ifndef discard_const
-#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
-#endif
-
-/** Type-safe version of discard_const */
-#ifndef discard_const_p
-#define discard_const_p(type, ptr) ((type *)discard_const(ptr))
-#endif
-
 /**
  * assert macros 
  */