Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove variable declaration from for-loop header and enclose in block #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions oursqlx/_exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,23 +617,26 @@ enum _oursqlx_exception_type _oursqlx_exc_from_errno(int err) {
return _oursqlx_PermissionsError;

default:
#if MYSQL_VERSION_ID >= 50700
for(unsigned int i = 0; i < sizeof(errmsg_section_start)/sizeof(int); ++i) {
int min = errmsg_section_start[i];
int max = errmsg_section_start[i] + errmsg_section_size[i] - 1;
if ( err >= min && err <= max ) {
return _oursqlx_ProgrammingError;
}
}
if ( err > CR_MIN_ERROR && err < CR_MAX_ERROR) {
return _oursqlx_InterfaceError;
}
#else
if (err >= ER_ERROR_FIRST && err <= ER_ERROR_LAST)
return _oursqlx_ProgrammingError;
else if (err > CR_MIN_ERROR && err < CR_MAX_ERROR)
return _oursqlx_InterfaceError;
#endif
#if MYSQL_VERSION_ID >= 50700
{
unsigned int i;
for(i = 0; i < sizeof(errmsg_section_start)/sizeof(int); ++i) {
int min = errmsg_section_start[i];
int max = errmsg_section_start[i] + errmsg_section_size[i] - 1;
if ( err >= min && err <= max ) {
return _oursqlx_ProgrammingError;
}
}
if ( err > CR_MIN_ERROR && err < CR_MAX_ERROR) {
return _oursqlx_InterfaceError;
}
}
#else
if (err >= ER_ERROR_FIRST && err <= ER_ERROR_LAST)
return _oursqlx_ProgrammingError;
else if (err > CR_MIN_ERROR && err < CR_MAX_ERROR)
return _oursqlx_InterfaceError;
#endif
}
return _oursqlx_UnknownError;
}