libxl: Introduce FILLZERO
authorIan Jackson <ian.jackson@eu.citrix.com>
Tue, 10 Feb 2015 19:00:06 +0000 (19:00 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 26 Jun 2015 15:53:51 +0000 (16:53 +0100)
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.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
v2: New in this version of the series.

tools/libxl/CODING_STYLE
tools/libxl/libxl_internal.h
tools/libxl/libxl_utils.h

index f5b58909b34d158f4c06bb3e279f6648b1aa01ec..a65efb3f6f63e7601d60bdbd03490b10a645c742 100644 (file)
@@ -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
index 6364d22cac6de77d388fb0ecb782a74aacf15565..2db6b2e851706482b45da78a6d885da79b72e705 100644 (file)
@@ -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;
index 1c1761da4e1ede1c31fbdd5d4bf48b0b587c10e3..9b90a4410eefa5d89ec979b83f516ea0d5c2ec98 100644 (file)
@@ -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
 
 /*