Skip to content

Commit

Permalink
message.c: Cast uintptr_t types to upb_MessageDef (#1492)
Browse files Browse the repository at this point in the history
This fixes build with clang

python/message.c:1238:49: error: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned long') to parameter of type 'const upb_MessageDef *' (aka 'const struct upb_MessageDef *') [-Wint-conversion]
 1238 |                        upb_MessageDef_MiniTable(other->def),
      |                                                 ^~~~~~~~~~
/mnt/b/yoe/master/build/tmp/work/cortexa72-cortexa53-crypto-yoe-linux/python3-protobuf/4.24.0/protobuf-4.24.0/upb/reflection/message_def.h:138:69: note: passing argument to parameter 'm' here
  138 | const upb_MiniTable* upb_MessageDef_MiniTable(const upb_MessageDef* m);
      |                                                                     ^
python/message.c:1609:69: error: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned long') to parameter of type 'const upb_MessageDef *' (aka 'const struct upb_MessageDef *') [-Wint-conversion]
 1609 |       upb_Message_DeepClone(self->ptr.msg, upb_MessageDef_MiniTable(self->def),
      |                                                                     ^~~~~~~~~
/mnt/b/yoe/master/build/tmp/work/cortexa72-cortexa53-crypto-yoe-linux/python3-protobuf/4.24.0/protobuf-4.24.0/upb/reflection/message_def.h:138:69: note: passing argument to parameter 'm' here
  138 | const upb_MiniTable* upb_MessageDef_MiniTable(const upb_MessageDef* m);
      |                                                                     ^
python/message.c:1611:44: error: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned long') to parameter of type 'const upb_MessageDef *' (aka 'const struct upb_MessageDef *') [-Wint-conversion]
 1611 |   PyObject* ret = PyUpb_Message_Get(clone, self->def, arena);
      |                                            ^~~~~~~~~

Co-authored-by: Adam Cozzette <acozzette@google.com>
  • Loading branch information
kraj and acozzette authored Sep 7, 2023
1 parent af17da5 commit 3dffa71
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions python/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,7 @@ static PyObject* PyUpb_Message_CopyFrom(PyObject* _self, PyObject* arg) {
const upb_Message* other_msg = PyUpb_Message_GetIfReified((PyObject*)other);
if (other_msg) {
upb_Message_DeepCopy(self->ptr.msg, other_msg,
upb_MessageDef_MiniTable(other->def),
upb_MessageDef_MiniTable((const upb_MessageDef*)other->def),
PyUpb_Arena_Get(self->arena));
} else {
PyObject* tmp = PyUpb_Message_Clear(self);
Expand Down Expand Up @@ -1615,9 +1615,9 @@ PyObject* DeepCopy(PyObject* _self, PyObject* arg) {

PyObject* arena = PyUpb_Arena_New();
upb_Message* clone =
upb_Message_DeepClone(self->ptr.msg, upb_MessageDef_MiniTable(self->def),
upb_Message_DeepClone(self->ptr.msg, upb_MessageDef_MiniTable((const upb_MessageDef*)self->def),
PyUpb_Arena_Get(arena));
PyObject* ret = PyUpb_Message_Get(clone, self->def, arena);
PyObject* ret = PyUpb_Message_Get(clone, (const upb_MessageDef*)self->def, arena);
Py_DECREF(arena);

return ret;
Expand Down

0 comments on commit 3dffa71

Please sign in to comment.