On Fri, Jul 31, 2015 at 01:03:24PM -0700, Jarno Rajahalme wrote: > > On Jul 31, 2015, at 11:37 AM, Ben Pfaff <b...@nicira.com> wrote: > > > > On Fri, Jul 31, 2015 at 11:18:22AM -0700, Jarno Rajahalme wrote: > >> One question below, > > > > One answer below ;-) > > > >> Acked-by: Jarno Rajahalme <jrajaha...@nicira.com> > > > > Thanks. > > > >>> On Jul 29, 2015, at 11:42 PM, Ben Pfaff <b...@nicira.com> wrote: > >>> > >>> To be used in an upcoming commit. > >>> > >>> Signed-off-by: Ben Pfaff <b...@nicira.com> > >>> --- > >>> lib/list.h | 7 ++++++- > >>> 1 file changed, 6 insertions(+), 1 deletion(-) > >>> > >>> diff --git a/lib/list.h b/lib/list.h > >>> index 7ba1e35..c1b0891 100644 > >>> --- a/lib/list.h > >>> +++ b/lib/list.h > >>> @@ -23,6 +23,11 @@ > >>> #include "util.h" > >>> #include "openvswitch/list.h" > >>> > >>> +/* Initializer for a list with pointers that will (probably) cause > >>> segfaults if > >>> + * dereferenced and, better yet, show up clearly in a debugger. */ > >>> +#define OVS_LIST_POISON { (void *) (uintptr_t) 0xccccccccccccccccULL, \ > >>> + (void *) (uintptr_t) 0xccccccccccccccccULL } > >>> + > >>> static inline void list_init(struct ovs_list *); > >>> static inline void list_poison(struct ovs_list *); > >>> > >>> @@ -91,7 +96,7 @@ list_init(struct ovs_list *list) > >>> static inline void > >>> list_poison(struct ovs_list *list) > >>> { > >>> - memset(list, 0xcc, sizeof *list); > >>> + *list = (struct ovs_list) OVS_LIST_POISON; > >> > >> Could the cast be part of the macro? > > > > The short answer is "yes". Would you like it that way, then? > > If the compound literal can still be used as an initializer, then yes, > so that the macro can be used by itself in both situations, as an > initializer and as a compound literal in an assignment.
It can be used both ways, so I changed this to: --8<--------------------------cut here-------------------------->8-- From: Ben Pfaff <b...@nicira.com> Date: Fri, 31 Jul 2015 13:14:20 -0700 Subject: [PATCH] list: New macro OVS_LIST_POISON for initializing a poisoned list. To be used in an upcoming commit. Signed-off-by: Ben Pfaff <b...@nicira.com> Acked-by: Jarno Rajahalme <jrajaha...@nicira.com> --- lib/list.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/list.h b/lib/list.h index 7ba1e35..5ad54b8 100644 --- a/lib/list.h +++ b/lib/list.h @@ -23,6 +23,12 @@ #include "util.h" #include "openvswitch/list.h" +/* "struct ovs_list" with pointers that will (probably) cause segfaults if + * dereferenced and, better yet, show up clearly in a debugger. */ +#define OVS_LIST_POISON \ + (struct ovs_list) { (void *) (uintptr_t) 0xccccccccccccccccULL, \ + (void *) (uintptr_t) 0xccccccccccccccccULL } + static inline void list_init(struct ovs_list *); static inline void list_poison(struct ovs_list *); @@ -91,7 +97,7 @@ list_init(struct ovs_list *list) static inline void list_poison(struct ovs_list *list) { - memset(list, 0xcc, sizeof *list); + *list = OVS_LIST_POISON; } /* Inserts 'elem' just before 'before'. */ -- 2.1.3 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev