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 <ian.jack...@eu.citrix.com> --- 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 36a13ea..465cdda 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -3225,6 +3225,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 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel