libxl: annotate s to be nonnull in libxl__enum_from_string
PATCH 1/1 libxl: annotate s to be nonnull in libxl__enum_from_string
Hope this can placate coverity.
---
Cc: Ian Jackson <[email protected]>
Cc: Julien Grall <[email protected]>
--- tools/libxl/libxl_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxl/libxl_internal.h +1 -1
@@ -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);
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Wei Liu writes ("[PATCH for-4.10] libxl: annotate s to be nonnull in libxl__enum_from_string"):
Quoted 1 line
Hope this can placate coverity.
We are very soon going to want "NN2" and maybe "NN_1_2".
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 5 lines · Ian Jackson
Wei Liu writes ("[PATCH for-4.10] libxl: annotate s to be nonnull in
libxl__enum_from_string"):Quoted 1 line
Hope this can placate coverity.
Acked-by Ian Jackson <[email protected]>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
[email protected]
https://lists.xen.org/xen-devel
Andrew Cooper writes ("Re: [Xen-devel] [PATCH for-4.10] libxl: annotate s to be nonnull in libxl__enum_from_string"):
Quoted 9 lines · Ian Jackson
Quoted 1 line
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
[email protected]
https://lists.xen.org/xen-devel
Hi,
Quoted 6 lines · Wei Liu
Hope this can placate coverity.
Signed-off-by Wei Liu <[email protected]>---
Cc: Ian Jackson <[email protected]>
Cc: Julien Grall <[email protected]>
Cheers,
Quoted 18 lines
--- tools/libxl/libxl_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/libxl/libxl_internal.h +1
-1@@ -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);
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Julien Grall writes ("Re: [Xen-devel] [PATCH for-4.10] libxl: annotate s to be nonnull in libxl__enum_from_string"):
Quoted 1 line
Release-acked-by Julien Grall <[email protected]>
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 <[email protected]>
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.
--- tools/libxl/libxl_internal.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/libxl/libxl_internal.h +2 -1
@@ -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);
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Hi,
Quoted 6 lines · Ian Jackson
Julien Grall writes ("Re: [Xen-devel] [PATCH for-4.10] libxl: annotate s to be nonnull in
libxl__enum_from_string"):Quoted 1 line
Release-acked-by Julien Grall <[email protected]>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,
Quoted 45 lines
Ian.
From
b15e10f24a0d3c35033c26832e91aa14d40fc437Mon Sep 17 00:00:00 2001
From: Ian Jackson <[email protected]>
Date: Fri, 20 Oct 2017 11:42:42 +0100
Subject: [PATCH] libxl: Replace open-coded__attribute__withNN()macroInspired 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 <[email protected]>CC Andrew Cooper <[email protected]>CC Wei Liu <[email protected]>CC Julien Grall <[email protected]>--- tools/libxl/libxl_internal.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)tools/libxl/libxl_internal.h +2
-1@@ -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);
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 12 lines · Julien Grall
Hi,
Quoted 6 lines · Ian Jackson
Julien Grall writes ("Re: [Xen-devel] [PATCH for-4.10] libxl: annotate s to be nonnull in
libxl__enum_from_string"):Quoted 1 line
Release-acked-by Julien Grall <[email protected]>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
[email protected]
https://lists.xen.org/xen-devel
Wei Liu writes ("Re: [Xen-devel] [PATCH for-4.10] libxl: annotate s to be nonnull in libxl__enum_from_string"):
Quoted 5 lines · Julien Grall
Quoted 1 line
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
[email protected]
https://lists.xen.org/xen-devel
Quoted 11 lines · Ian Jackson
Wei Liu writes ("Re: [Xen-devel] [PATCH for-4.10] libxl: annotate s to be nonnull in
libxl__enum_from_string"):Quoted 5 lines · Julien Grall
Quoted 1 line
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
[email protected]
https://lists.xen.org/xen-devel