mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
lib:util: Move discard_const(_p) to own header for libndr.h
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13778 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Guenther Deschner <gd@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
parent
532ce0d20a
commit
96df6878ed
51
lib/util/discard.h
Normal file
51
lib/util/discard.h
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
Samba utility functions
|
||||
Copyright (C) Andrew Tridgell 1992-1999
|
||||
Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _SAMBA_DISCARD_H_
|
||||
#define _SAMBA_DISCARD_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
|
||||
|
||||
#endif /* _SAMBA_DISCARD_H_ */
|
@ -94,31 +94,4 @@
|
||||
#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_ */
|
||||
|
@ -54,6 +54,7 @@ extern const char *panic_action;
|
||||
#endif
|
||||
|
||||
#include "lib/util/memory.h"
|
||||
#include "lib/util/discard.h"
|
||||
|
||||
#include "fault.h"
|
||||
|
||||
|
@ -127,7 +127,7 @@ else:
|
||||
tftw.c''',
|
||||
deps='samba-util-core DYNCONFIG close-low-fd tiniparser genrand util_str_hex',
|
||||
public_deps='talloc tevent execinfo pthread LIBCRYPTO charset util_setid',
|
||||
public_headers='debug.h attr.h byteorder.h data_blob.h memory.h safe_string.h time.h talloc_stack.h string_wrappers.h idtree.h idtree_random.h blocking.h signal.h substitute.h fault.h genrand.h tfork.h',
|
||||
public_headers='debug.h attr.h byteorder.h data_blob.h discard.h memory.h safe_string.h time.h talloc_stack.h string_wrappers.h idtree.h idtree_random.h blocking.h signal.h substitute.h fault.h genrand.h tfork.h',
|
||||
header_path= [ ('dlinklist.h samba_util.h', '.'), ('*', 'util') ],
|
||||
local_include=False,
|
||||
vnum='0.0.1',
|
||||
|
@ -26,7 +26,7 @@
|
||||
#define __LIBNDR_H__
|
||||
|
||||
#include <talloc.h>
|
||||
#include "../lib/util/memory.h" /* for discard_const */
|
||||
#include "../lib/util/discard.h" /* for discard_const */
|
||||
#include "../lib/util/byteorder.h"
|
||||
#include "../lib/util/data_blob.h"
|
||||
#include "../lib/util/time.h"
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "system/time.h"
|
||||
#include "lib/util/debug.h"
|
||||
#include "lib/util/talloc_stack.h"
|
||||
#include "lib/util/memory.h" /* for SAFE_FREE() */
|
||||
#include "source3/lib/util_path.h"
|
||||
#include "librpc/gen_ndr/ndr_krb5pac.h"
|
||||
#include "../libcli/security/security.h"
|
||||
|
Loading…
Reference in New Issue
Block a user