From: Ian Jackson Date: Tue, 10 Feb 2015 19:00:06 +0000 (+0000) Subject: libxl: Introduce FILLZERO X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~2993 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a074278122b338fb08fa20ab30825e1366b2da68;p=xen.git libxl: Introduce FILLZERO 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 Acked-by: Ian Campbell --- v2: New in this version of the series. --- diff --git a/tools/libxl/CODING_STYLE b/tools/libxl/CODING_STYLE index f5b58909b3..a65efb3f6f 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 6364d22cac..2db6b2e851 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -3291,6 +3291,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 1c1761da4e..9b90a4410e 100644 --- a/tools/libxl/libxl_utils.h +++ b/tools/libxl/libxl_utils.h @@ -160,6 +160,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 /*