long2ice / asyncmy

A fast asyncio MySQL/MariaDB driver with replication protocol support
https://github.com/long2ice/asyncmy
Apache License 2.0
230 stars 25 forks source link

Overflow build warning #96

Open peterschutt opened 1 month ago

peterschutt commented 1 month ago

I noticed this while building from source:

building 'asyncmy.connection' extension
gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -I/tmp/tmpvdo1u3mu/.venv/include -I/usr/local/include/python3.12 -c asyncmy/connection.c -o /workspace/asyncmy-0.2.9/build/temp.linux-x86_64-cpython-312/asyncmy/connection.o
asyncmy/connection.c: In function '__pyx_gb_7asyncmy_10connection_11MySQLResult_9generator25':
asyncmy/connection.c:34974:52: warning: overflow in conversion from 'long unsigned int' to 'int' changes value from '18446744073709551615' to '-1' [-Woverflow]
34974 |     __pyx_cur_scope->__pyx_v_self->affected_rows = 0xFFFFFFFFFFFFFFFF;

I assume it originates from here:

https://github.com/long2ice/asyncmy/blob/076218a391aaa1c9919ade9b4368b9c7a8346339/asyncmy/connection.pyx#L1102-L1105

Perhaps affected_rows needs to be larger than int?

https://github.com/long2ice/asyncmy/blob/076218a391aaa1c9919ade9b4368b9c7a8346339/asyncmy/connection.pyx#L1047

I really don't know enough to know if this is an issue, or not (or if I've found the actual origin of the issue!), so just reporting to be safe, and happy to close off if a non-issue.