bitcoin-core / secp256k1

Optimized C library for EC operations on curve secp256k1
MIT License
2.06k stars 1k forks source link

use EXIT_ codes instead of magic numbers for exit(...) and main return values #1609

Open theStack opened 1 week ago

theStack commented 1 week ago

This is really only a minor issue, but I noticed while reviewing #1479 that the return codes of functions in the examples could potentially be confusing. Throughout the API and internal functions we use 0=failure/1=success, while for the main function and (exit(...)) it's the other way round, i.e. 0=success/1=failure. We could use EXIT_{SUCCESS,FAILURE} (defined in stdlib.h, see https://en.cppreference.com/w/c/program/EXIT_status) for the latter instead for more clarity.

See e.g. https://github.com/bitcoin/bitcoin/pull/9067/commits/4441018d0860fce64ee74fa78da79bbb21114ca9 for a comparable change in Bitcoin Core as orientation. This could be a good first issue.

real-or-random commented 1 week ago

Concept ACK

I had the same thought in the past.

My suggestion to remove assert() in the examples is slightly related and could be addressed in another commit in the same PR that would resolve this issue here.