From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xen.org
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Subject: [PATCH 14/19] libxl: Get compiler to warn about gc_opt==NULL
Date: Fri, 8 Jun 2012 18:34:25 +0100 [thread overview]
Message-ID: <1339176870-32652-15-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1339176870-32652-1-git-send-email-ian.jackson@eu.citrix.com>
Since it used to be legal to pass gc_opt==NULL, and there are various
patches floating about and under developmetn which do so, add a
compiler annotation which makes the build fail when that is done.
This turns a runtime crash into a build failure, and should ensure
that we don't accidentally commit a broken combination of patches.
This is something of an annoying approach because it adds a macro
invocation to the RHS of every declaration of a function taking a
gc_opt. So it should be reverted after Xen 4.2rc1.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
tools/libxl/libxl_internal.h | 21 +++++++++++++--------
1 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index e69482c..8635764 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -453,28 +453,33 @@ static inline libxl_ctx *libxl__gc_owner(libxl__gc *gc)
* psuedo-gc.
*/
/* register ptr in gc for free on exit from outermost libxl callframe. */
-_hidden void libxl__ptr_add(libxl__gc *gc_opt, void *ptr /* may be NULL */);
+
+#define NN1 __attribute__((nonnull(1)))
+ /* It used to be legal to pass NULL for gc_opt. Get the compiler to
+ * warn about this if any slip through. */
+
+_hidden void libxl__ptr_add(libxl__gc *gc_opt, void *ptr /* may be NULL */) NN1;
/* if this is the outermost libxl callframe then free all pointers in @gc */
_hidden void libxl__free_all(libxl__gc *gc);
/* allocate and zero @bytes. (similar to a gc'd malloc(3)+memzero()) */
-_hidden void *libxl__zalloc(libxl__gc *gc_opt, int bytes);
+_hidden void *libxl__zalloc(libxl__gc *gc_opt, int bytes) NN1;
/* allocate and zero memory for an array of @nmemb members of @size each.
* (similar to a gc'd calloc(3)). */
-_hidden void *libxl__calloc(libxl__gc *gc_opt, size_t nmemb, size_t size);
+_hidden void *libxl__calloc(libxl__gc *gc_opt, size_t nmemb, size_t size) NN1;
/* change the size of the memory block pointed to by @ptr to @new_size bytes.
* unlike other allocation functions here any additional space between the
* oldsize and @new_size is not initialised (similar to a gc'd realloc(3)). */
-_hidden void *libxl__realloc(libxl__gc *gc_opt, void *ptr, size_t new_size);
+_hidden void *libxl__realloc(libxl__gc *gc_opt, void *ptr, size_t new_size) NN1;
/* print @fmt into an allocated string large enoughto contain the result.
* (similar to gc'd asprintf(3)). */
-_hidden char *libxl__sprintf(libxl__gc *gc_opt, const char *fmt, ...) PRINTF_ATTRIBUTE(2, 3);
+_hidden char *libxl__sprintf(libxl__gc *gc_opt, const char *fmt, ...) PRINTF_ATTRIBUTE(2, 3) NN1;
/* duplicate the string @c (similar to a gc'd strdup(3)). */
-_hidden char *libxl__strdup(libxl__gc *gc_opt, const char *c);
+_hidden char *libxl__strdup(libxl__gc *gc_opt, const char *c) NN1;
/* duplicate at most @n bytes of string @c (similar to a gc'd strndup(3)). */
-_hidden char *libxl__strndup(libxl__gc *gc_opt, const char *c, size_t n);
+_hidden char *libxl__strndup(libxl__gc *gc_opt, const char *c, size_t n) NN1;
/* strip the last path component from @s and return as a newly allocated
* string. (similar to a gc'd dirname(3)). */
-_hidden char *libxl__dirname(libxl__gc *gc_opt, const char *s);
+_hidden char *libxl__dirname(libxl__gc *gc_opt, const char *s) NN1;
/* Each of these logs errors and returns a libxl error code.
* They do not mind if path is already removed.
--
1.7.2.5
next prev parent reply other threads:[~2012-06-08 17:34 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-08 17:34 [PATCH v3 00/18] libxl: domain save/restore: run in a separate process Ian Jackson
2012-06-08 17:34 ` [PATCH 01/19] libxc: xc_domain_restore, make toolstack_restore const-correct Ian Jackson
2012-06-12 15:15 ` Ian Campbell
2012-06-08 17:34 ` [PATCH 02/19] libxl: domain save: rename variables etc Ian Jackson
2012-06-12 15:24 ` Ian Campbell
2012-06-14 15:09 ` Ian Jackson
2012-06-08 17:34 ` [PATCH 03/19] libxl: domain restore: reshuffle, preparing for ao Ian Jackson
2012-06-12 15:49 ` Ian Campbell
2012-06-14 15:11 ` Ian Jackson
2012-06-08 17:34 ` [PATCH 04/19] libxl: domain save: API changes for asynchrony Ian Jackson
2012-06-12 16:51 ` Ian Campbell
2012-06-14 15:26 ` Ian Jackson
2012-06-19 10:04 ` Ian Campbell
2012-06-19 13:02 ` Ian Jackson
2012-06-19 15:15 ` Ian Campbell
2012-06-08 17:34 ` [PATCH 05/19] libxl: domain save/restore: run in a separate process Ian Jackson
2012-06-13 11:04 ` Ian Campbell
2012-06-14 16:48 ` Ian Jackson
2012-06-19 13:50 ` Ian Campbell
2012-06-08 17:34 ` [PATCH 06/19] libxl: rename libxl_dom:save_helper to physmap_path Ian Jackson
2012-06-08 17:34 ` [PATCH 07/19] libxl: provide libxl__xs_*_checked and libxl__xs_transaction_* Ian Jackson
2012-06-13 11:15 ` Ian Campbell
2012-06-14 16:53 ` Ian Jackson
2012-06-08 17:34 ` [PATCH 08/19] libxl: wait for qemu to acknowledge logdirty command Ian Jackson
2012-06-13 12:52 ` Ian Campbell
2012-06-14 15:47 ` Ian Jackson
2012-06-19 13:33 ` Ian Campbell
2012-06-08 17:34 ` [PATCH 09/19] libxl: datacopier: provide "prefix data" facility Ian Jackson
2012-06-13 12:53 ` Ian Campbell
2012-06-08 17:34 ` [PATCH 10/19] libxl: prepare for asynchronous writing of qemu save file Ian Jackson
2012-06-13 12:56 ` Ian Campbell
2012-06-08 17:34 ` [PATCH 11/19] libxl: Make libxl__domain_save_device_model asynchronous Ian Jackson
2012-06-13 12:59 ` Ian Campbell
2012-06-08 17:34 ` [PATCH 12/19] libxl: Add a gc to libxl_get_cpu_topology Ian Jackson
2012-06-13 12:59 ` Ian Campbell
2012-06-08 17:34 ` [PATCH 13/19] libxl: Do not pass NULL as gc_opt; introduce NOGC Ian Jackson
2012-06-13 13:11 ` Ian Campbell
2012-06-08 17:34 ` Ian Jackson [this message]
2012-06-13 13:08 ` [PATCH 14/19] libxl: Get compiler to warn about gc_opt==NULL Ian Campbell
2012-06-13 13:09 ` Ian Campbell
2012-06-14 16:58 ` Ian Jackson
2012-06-08 17:34 ` [PATCH 15/19] xl: Handle return value from libxl_domain_suspend correctly Ian Jackson
2012-06-08 17:34 ` [PATCH 16/19] libxl: do not leak dms->saved_state Ian Jackson
2012-06-08 17:34 ` [PATCH 17/19] libxl: do not leak spawned middle children Ian Jackson
2012-06-13 13:25 ` Ian Campbell
2012-06-14 17:08 ` Ian Jackson
2012-06-08 17:34 ` [PATCH 18/19] libxl: do not leak an event struct on ignored ao progress Ian Jackson
2012-06-08 17:34 ` [PATCH 19/19] libxl: DO NOT APPLY enforce prohibition on internal Ian Jackson
2012-06-11 16:43 ` [PATCH] libxl: further fixups re LIBXL_DOMAIN_TYPE process Ian Jackson
2012-06-13 16:48 ` Ian Campbell
2012-06-13 8:59 ` [PATCH v3 00/18] libxl: domain save/restore: run in a separate process Ian Campbell
2012-06-13 10:22 ` Ian Campbell
2012-06-13 10:30 ` Ian Campbell
2012-06-14 15:31 ` [PATCH v3 00/18] libxl: domain save/restore: run in a separate process [and 4 more messages] Ian Jackson
2012-06-14 15:39 ` Ian Jackson
2012-06-13 10:38 ` [PATCH v3 00/18] libxl: domain save/restore: run in a separate process Ian Campbell
2012-06-13 11:27 ` Ian Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1339176870-32652-15-git-send-email-ian.jackson@eu.citrix.com \
--to=ian.jackson@eu.citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).