Re: [Xen-devel] [PATCH for-4.10] libxl: annotate s to be nonnull in libxl__enum_from_string

2017-10-23 Thread Wei Liu
On Mon, Oct 23, 2017 at 02:04:58PM +0100, Ian Jackson wrote:
> Wei Liu writes ("Re: [Xen-devel] [PATCH for-4.10] libxl: annotate s to be 
> nonnull in libxl__enum_from_string"):
> > On Mon, Oct 23, 2017 at 01:32:50PM +0100, Julien Grall wrote:
> > > I would be ok with that. Wei do you have any opinion?
> > 
> > Sure this is a simple enough patch. We should preferably turn all NN1 to
> > NN(1), too.
> 
> That would be fine by me but I don't feel a need to hurry with that.
> I can provide the patch to do that right now, or we can save doing
> that for after 4.10.
> 

Either is fine.

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH for-4.10] libxl: annotate s to be nonnull in libxl__enum_from_string

2017-10-23 Thread Ian Jackson
Wei Liu writes ("Re: [Xen-devel] [PATCH for-4.10] libxl: annotate s to be 
nonnull in libxl__enum_from_string"):
> On Mon, Oct 23, 2017 at 01:32:50PM +0100, Julien Grall wrote:
> > I would be ok with that. Wei do you have any opinion?
> 
> Sure this is a simple enough patch. We should preferably turn all NN1 to
> NN(1), too.

That would be fine by me but I don't feel a need to hurry with that.
I can provide the patch to do that right now, or we can save doing
that for after 4.10.

Ian.

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH for-4.10] libxl: annotate s to be nonnull in libxl__enum_from_string

2017-10-23 Thread Wei Liu
On Mon, Oct 23, 2017 at 01:32:50PM +0100, Julien Grall wrote:
> Hi,
> 
> On 20/10/17 11:47, Ian Jackson wrote:
> > Julien Grall writes ("Re: [Xen-devel] [PATCH for-4.10] libxl: annotate s to 
> > be nonnull in libxl__enum_from_string"):
> > > Release-acked-by: Julien Grall 
> > 
> > Thanks, I have applied this.  Not sure whether this followup is 4.10
> > material, but IMO it is if we would otherwise want to add another
> > open-coded __attribute__.
> 
> I would be ok with that. Wei do you have any opinion?
> 

Sure this is a simple enough patch. We should preferably turn all NN1 to
NN(1), too.

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH for-4.10] libxl: annotate s to be nonnull in libxl__enum_from_string

2017-10-23 Thread Julien Grall

Hi,

On 20/10/17 11:47, Ian Jackson wrote:

Julien Grall writes ("Re: [Xen-devel] [PATCH for-4.10] libxl: annotate s to be 
nonnull in libxl__enum_from_string"):

Release-acked-by: Julien Grall 


Thanks, I have applied this.  Not sure whether this followup is 4.10
material, but IMO it is if we would otherwise want to add another
open-coded __attribute__.


I would be ok with that. Wei do you have any opinion?

Cheers,



Ian.

 From b15e10f24a0d3c35033c26832e91aa14d40fc437 Mon Sep 17 00:00:00 2001
From: Ian Jackson 
Date: Fri, 20 Oct 2017 11:42:42 +0100
Subject: [PATCH] libxl: Replace open-coded __attribute__ with NN() macro

Inspired by
   #define __nonnull(...) __attribute__((__nonnull__(__VA_ARGS__)))
which is used in the hypervisor.

These annotations may well become very common in libxl, so we choose a
short name.

Signed-off-by: Ian Jackson 
CC: Andrew Cooper 
CC: Wei Liu 
CC: Julien Grall 
---
  tools/libxl/libxl_internal.h | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 9fe472e..bfa95d8 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -635,6 +635,7 @@ static inline int libxl__gc_is_real(const libxl__gc *gc)
   */
  /* register ptr in gc for free on exit from outermost libxl callframe. */
  
+#define NN(...) __attribute__((nonnull(__VA_ARGS__)))

  #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. */
@@ -1711,7 +1712,7 @@ _hidden char *libxl__domid_to_name(libxl__gc *gc, 
uint32_t domid);
  _hidden char *libxl__cpupoolid_to_name(libxl__gc *gc, uint32_t poolid);
  
  _hidden int libxl__enum_from_string(const libxl_enum_string_table *t,

-const char *s, int *e) 
__attribute__((nonnull(2)));
+const char *s, int *e) NN(2);
  
  _hidden yajl_gen_status libxl__yajl_gen_asciiz(yajl_gen hand, const char *str);
  



--
Julien Grall

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH for-4.10] libxl: annotate s to be nonnull in libxl__enum_from_string

2017-10-20 Thread Ian Jackson
Julien Grall writes ("Re: [Xen-devel] [PATCH for-4.10] libxl: annotate s to be 
nonnull in libxl__enum_from_string"):
> Release-acked-by: Julien Grall 

Thanks, I have applied this.  Not sure whether this followup is 4.10
material, but IMO it is if we would otherwise want to add another
open-coded __attribute__.

Ian.

From b15e10f24a0d3c35033c26832e91aa14d40fc437 Mon Sep 17 00:00:00 2001
From: Ian Jackson 
Date: Fri, 20 Oct 2017 11:42:42 +0100
Subject: [PATCH] libxl: Replace open-coded __attribute__ with NN() macro

Inspired by
  #define __nonnull(...) __attribute__((__nonnull__(__VA_ARGS__)))
which is used in the hypervisor.

These annotations may well become very common in libxl, so we choose a
short name.

Signed-off-by: Ian Jackson 
CC: Andrew Cooper 
CC: Wei Liu 
CC: Julien Grall 
---
 tools/libxl/libxl_internal.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 9fe472e..bfa95d8 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -635,6 +635,7 @@ static inline int libxl__gc_is_real(const libxl__gc *gc)
  */
 /* register ptr in gc for free on exit from outermost libxl callframe. */
 
+#define NN(...) __attribute__((nonnull(__VA_ARGS__)))
 #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. */
@@ -1711,7 +1712,7 @@ _hidden char *libxl__domid_to_name(libxl__gc *gc, 
uint32_t domid);
 _hidden char *libxl__cpupoolid_to_name(libxl__gc *gc, uint32_t poolid);
 
 _hidden int libxl__enum_from_string(const libxl_enum_string_table *t,
-const char *s, int *e) 
__attribute__((nonnull(2)));
+const char *s, int *e) NN(2);
 
 _hidden yajl_gen_status libxl__yajl_gen_asciiz(yajl_gen hand, const char *str);
 
-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH for-4.10] libxl: annotate s to be nonnull in libxl__enum_from_string

2017-10-20 Thread Julien Grall

Hi,

On 16/10/17 15:04, Wei Liu wrote:

Hope this can placate coverity.

Signed-off-by: Wei Liu 
---
Cc: Ian Jackson 
Cc: Julien Grall 


Release-acked-by: Julien Grall 

Cheers,


---
  tools/libxl/libxl_internal.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 45e6df6c82..9fe472efe3 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1711,7 +1711,7 @@ _hidden char *libxl__domid_to_name(libxl__gc *gc, 
uint32_t domid);
  _hidden char *libxl__cpupoolid_to_name(libxl__gc *gc, uint32_t poolid);
  
  _hidden int libxl__enum_from_string(const libxl_enum_string_table *t,

-const char *s, int *e);
+const char *s, int *e) 
__attribute__((nonnull(2)));
  
  _hidden yajl_gen_status libxl__yajl_gen_asciiz(yajl_gen hand, const char *str);
  



--
Julien Grall

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH for-4.10] libxl: annotate s to be nonnull in libxl__enum_from_string

2017-10-16 Thread Ian Jackson
Andrew Cooper writes ("Re: [Xen-devel] [PATCH for-4.10] libxl: annotate s to be 
nonnull in libxl__enum_from_string"):
> On 16/10/17 15:56, Ian Jackson wrote:
> > We are very soon going to want "NN2" and maybe "NN_1_2".
> 
> The hypervisor uses
> 
> #define __nonnull(...) __attribute__((__nonnull__(__VA_ARGS__)))
> 
> I suggest you use the same in libxl to avoid a combinatorial  explosion
> of NN variants.

We have NN already so in our code that should be NN(1) etc. I guess.

Ian.

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH for-4.10] libxl: annotate s to be nonnull in libxl__enum_from_string

2017-10-16 Thread Andrew Cooper
On 16/10/17 15:56, Ian Jackson wrote:
> Wei Liu writes ("[PATCH for-4.10] libxl: annotate s to be nonnull in 
> libxl__enum_from_string"):
>> Hope this can placate coverity.
> Acked-by: Ian Jackson 
>
> We are very soon going to want "NN2" and maybe "NN_1_2".

The hypervisor uses

#define __nonnull(...) __attribute__((__nonnull__(__VA_ARGS__)))

I suggest you use the same in libxl to avoid a combinatorial  explosion
of NN variants.

~Andrew

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH for-4.10] libxl: annotate s to be nonnull in libxl__enum_from_string

2017-10-16 Thread Ian Jackson
Wei Liu writes ("[PATCH for-4.10] libxl: annotate s to be nonnull in 
libxl__enum_from_string"):
> Hope this can placate coverity.

Acked-by: Ian Jackson 

We are very soon going to want "NN2" and maybe "NN_1_2".

Ian.

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH for-4.10] libxl: annotate s to be nonnull in libxl__enum_from_string

2017-10-16 Thread Wei Liu
Hope this can placate coverity.

Signed-off-by: Wei Liu 
---
Cc: Ian Jackson 
Cc: Julien Grall 
---
 tools/libxl/libxl_internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 45e6df6c82..9fe472efe3 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1711,7 +1711,7 @@ _hidden char *libxl__domid_to_name(libxl__gc *gc, 
uint32_t domid);
 _hidden char *libxl__cpupoolid_to_name(libxl__gc *gc, uint32_t poolid);
 
 _hidden int libxl__enum_from_string(const libxl_enum_string_table *t,
-const char *s, int *e);
+const char *s, int *e) 
__attribute__((nonnull(2)));
 
 _hidden yajl_gen_status libxl__yajl_gen_asciiz(yajl_gen hand, const char *str);
 
-- 
2.11.0


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel