osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/onomondo-ipa/+/42861?usp=email )
Change subject: utils: ignore Waddress in IPA_STR_FROM_ASN ......................................................................
utils: ignore Waddress in IPA_STR_FROM_ASN
When building with -Werror, GCC complains about this assert in the macro:
#define IPA_STR_FROM_ASN(asn1_obj) ({ \ char *__str; \ assert(asn1_obj); \ <----------------------------------------------- __str = IPA_ALLOC_N((asn1_obj)->size + 1); \ assert(__str); \ memcpy(__str, (asn1_obj)->buf, (asn1_obj)->size); \ __str[(asn1_obj)->size] = '\0'; \ __str; \ })
For example:
…/src/ipa/libipa/es10b_get_eim_cfg_data.c:48:21: error: the comparison will always evaluate as ‘true’ for the address of ‘eimId’ will never be NULL [-Werror=address] 48 | IPA_STR_FROM_ASN(&res->res->eimConfigurationDataList.list.array[i]->eimId);
Add pragmas to ignore the error, so it can still assert if somebody should pass NULL to the macro.
Change-Id: Ia2ef30880dd3e5b2ab90eedd0046a95a22614a81 --- M src/ipa/libipa/utils.h 1 file changed, 3 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/onomondo-ipa refs/changes/61/42861/1
diff --git a/src/ipa/libipa/utils.h b/src/ipa/libipa/utils.h index 8ae5b66..2f95ecd 100644 --- a/src/ipa/libipa/utils.h +++ b/src/ipa/libipa/utils.h @@ -100,7 +100,10 @@ * \returns null terminated char array with contents of asn1_obj. */ #define IPA_STR_FROM_ASN(asn1_obj) ({ \ char *__str; \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored "-Waddress"") \ assert(asn1_obj); \ + _Pragma("GCC diagnostic pop") \ __str = IPA_ALLOC_N((asn1_obj)->size + 1); \ assert(__str); \ memcpy(__str, (asn1_obj)->buf, (asn1_obj)->size); \