TokTok / c-toxcore

The future of online communications.
https://tox.chat
GNU General Public License v3.0
2.25k stars 284 forks source link

refactor: Make tox-bootstrapd use bool instead of int #2692

Open nurupo opened 7 months ago

nurupo commented 7 months ago

A continuation of the cleanup done in https://github.com/TokTok/c-toxcore/pull/2621.

tox-bootrstrapd historically had used ints for boolean values, as it was initially written in C89 which has no stdbool.h. Since then it has modernized and moved on to using C11, but the usage of the int type to represent boolean values, "boolean ints", remained. Recently, driven by a desire to eliminate implicit int-to-bool conversion, @iphydf did a cleanup in b7404f24f63054c00c26abab4bd0b9dc58f96efb, changing some of the boolean ints to bools and doing manual int-to-bool conversion on the remaining boolean ints. This left the codebase in an inconsistent state of both ints and bools now being used to represent boolean values, not to mention that the explicit int-to-bool conversions are a bit ugly. The only boolean ints that remained are those stemming from libconfig's config_lookup_bool() taking an *int parameter to return a boolean value, as libconfig still uses C89. This commit adds a wrapper function around libconfig's config_lookup_bool() that takes a *bool instead, eliminating the remaining boolean ints and majority of the explicit int-to-bool conversions in tox-bootstrapd.


This change is Reviewable

codecov[bot] commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 73.09%. Comparing base (fa20168) to head (395e048).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #2692 +/- ## ========================================== + Coverage 73.03% 73.09% +0.06% ========================================== Files 149 149 Lines 30531 30531 ========================================== + Hits 22298 22318 +20 + Misses 8233 8213 -20 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

nurupo commented 6 months ago

@JFreegman please take a look and merge.

nurupo commented 6 months ago

Oh, wrong PR, sorry.