[PyQt] [PATCH 3/5] Use SIP_NULLPTR if return value is a pointer to an object
Stefan Brüns
stefan.bruens at rwth-aachen.de
Sat Sep 29 15:27:47 BST 2018
Current versions of GCC and LLVM issue a warning "zero as null pointer
constant [-Wzero-as-null-pointer-constant]" if 0 is used.
In case a slot returns (no) PyObject, use SIP_NULLPTR.
Signed-off-by: Stefan Brüns <stefan.bruens at rwth-aachen.de>
---
sipgen/gencode.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/sipgen/gencode.c b/sipgen/gencode.c
index b08f255..e0d61c5 100644
--- a/sipgen/gencode.c
+++ b/sipgen/gencode.c
@@ -5924,7 +5924,7 @@ static void generateSlot(moduleDef *mod, classDef *cd, enumDef *ed,
memberDef *md, FILE *fp)
{
char *arg_str, *decl_arg_str, *prefix, *ret_type;
- int ret_int, has_args;
+ int ret_int, has_args, ret_ptr;
overDef *od, *overs;
scopedNameDef *fqcname;
nameDef *pyname;
@@ -5955,17 +5955,21 @@ static void generateSlot(moduleDef *mod, classDef *cd, enumDef *ed,
{
ret_int = TRUE;
ret_type = "int ";
+ ret_ptr = FALSE;
}
else
{
ret_int = FALSE;
+ ret_ptr = FALSE;
if (isSSizeReturnSlot(md))
ret_type = "SIP_SSIZE_T ";
else if (isLongReturnSlot(md))
ret_type = "long ";
- else
+ else {
ret_type = "PyObject *";
+ ret_ptr = TRUE;
+ }
}
has_args = TRUE;
@@ -6091,7 +6095,7 @@ static void generateSlot(moduleDef *mod, classDef *cd, enumDef *ed,
prcode(fp,
" return %s;\n"
"\n"
- , (md->slot == cmp_slot ? "-2" : (ret_int ? "-1" : "0")));
+ , (md->slot == cmp_slot ? "-2" : (ret_int ? "-1" : (ret_ptr ? "SIP_NULLPTR" : "0"))));
}
if (has_args)
@@ -6194,7 +6198,7 @@ static void generateSlot(moduleDef *mod, classDef *cd, enumDef *ed,
prcode(fp, ", NULL);\n"
"\n"
" return %s;\n"
- ,ret_int ? "-1" : "0");
+ ,ret_int ? "-1" : (ret_ptr ? "SIP_NULLPTR" : "0"));
}
}
}
--
2.19.0
More information about the PyQt
mailing list