-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mx_mysql: Remove broken errno range check
The assertion mx_assert_return_minus_errno((unsigned int)(int)error == error, ERANGE); doesn't work as intended, the conditional expression is optimized away to true by gcc with -O1 and up [1]. We could do with assert(sizeof(long) > sizeof(int) assert(-(long)error >= INT_MIN); or with int ret; assert(!__builtin_sub_overflow(0, error, &ret)) to detect values outside of the range [0..-INT_MIN] which could not be negated into the range [INT_MIN..0]. However, the check seems not to be neccessary, as the mysql error number is nowhere converted to a negative error number, all callers just use it to compare it with constants. The other assert checks of the helper functions are just redundant. Remove the helper functions mx__mysql_errno() and mx__mysql_stmt_errno() and and use the native mysql calls instead. [1]: https://godbolt.org/z/1ajK384Ge
- Loading branch information
Showing
1 changed file
with
10 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters