Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Address clang-tidy warnings in db files (#1405)
The general approach here was: - Always declare variables as close to where they are defined as possible. - Check for pre-conditions of functions before doing work (e.g. ensure we can connect to the DB before doing a bunch of string formatting) - Keep the scope of mutexes as reasonably small as practical. - Use idiomatic C11, such as for-loops over the thing being iterated, not while() loops over constants, or variables that aren't modified. - Prefer if(fail){return} function-body after over `if(not fail){ function-body inside if} return; Clang-tidy returns a clean bill of health, but while going through this file i noticed a lot of things that raise questions. Lack of checking column counts. Lack of handling the possibility of multiple return values. Questionably handling of strings. Complete lack of checking function inputs for invalid values (e.g. nullptr). I'm not going to fix those, my organization doesn't USE the DB drivers, so i have little interest in re-working the logic beyond addressing clang-tidy warnings for my own sanity, but i did add TODO comments for someone else to look at in the future. Additional note: While the changes look very invasive.... they aren't. I don't think there is a way to get github to ignore whitespace in the filediff, but if someone were to compare the commit locally, they'll see that almost all of the changes are just adjusting indentation.
- Loading branch information