From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Jackson Subject: [PATCH 24/29] libxl: Introduce FILLZERO Date: Tue, 10 Feb 2015 20:10:11 +0000 Message-ID: <1423599016-32639-25-git-send-email-ian.jackson@eu.citrix.com> References: <1423599016-32639-1-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1423599016-32639-1-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xensource.com Cc: Ian Jackson , Euan Harris List-Id: xen-devel@lists.xenproject.org FILLZERO is a macro for memset(&foo,0,sizeof(foo)). It eliminates the possiblity to make the error memset(&foo,0,sizeof(&foo)). No callers yet, but document it in CODING_STYLE. (In accordance with existing libxl policy, I haven't gone through all existing possible call sites.) Signed-off-by: Ian Jackson --- v2: New in this version of the series. --- tools/libxl/CODING_STYLE | 1 + tools/libxl/libxl_internal.h | 3 +++ tools/libxl/libxl_utils.h | 3 +++ 3 files changed, 7 insertions(+) diff --git a/tools/libxl/CODING_STYLE b/tools/libxl/CODING_STYLE index f5b5890..a65efb3 100644 --- a/tools/libxl/CODING_STYLE +++ b/tools/libxl/CODING_STYLE @@ -62,6 +62,7 @@ whenever they are applicable. For example: libxl__ctx_[un]lock CTX_LOCK, CTX_UNLOCK gc=...; ao=...; EGC_GC, AO_GC, STATE_AO_GC explicit gc creation GC_INIT, GC_FREE + memset(..,0,sizeof..) FILLZERO ERROR HANDLING diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 9ab3ab7..cfc0706 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -3226,6 +3226,9 @@ _hidden const char *libxl__device_model_savefile(libxl__gc *gc, uint32_t domid); }) +#define FILLZERO LIBXL_FILLZERO + + /* * All of these assume (or define) * libxl__gc *gc; diff --git a/tools/libxl/libxl_utils.h b/tools/libxl/libxl_utils.h index acacdd9..51eac68 100644 --- a/tools/libxl/libxl_utils.h +++ b/tools/libxl/libxl_utils.h @@ -154,6 +154,9 @@ int libxl_cpumap_to_nodemap(libxl_ctx *ctx, void libxl_string_copy(libxl_ctx *ctx, char **dst, char **src); + +#define LIBXL_FILLZERO(object) (memset(&(object), 0, sizeof((object)))) + #endif /* -- 1.7.10.4