From 7bf17862c58ef1ad396dca3d0bf9c661a65e5ce5 Mon Sep 17 00:00:00 2001 From: Paul Furtado Date: Mon, 8 Aug 2016 18:32:57 -0400 Subject: [PATCH 1/2] Fix indentation --- oursqlx/_exceptions.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/oursqlx/_exceptions.c b/oursqlx/_exceptions.c index 0d76ff0..68a4525 100644 --- a/oursqlx/_exceptions.c +++ b/oursqlx/_exceptions.c @@ -617,23 +617,23 @@ 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 + 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 } return _oursqlx_UnknownError; } From 9ffee5dc887bd1a22cb55a708699007ac58437f7 Mon Sep 17 00:00:00 2001 From: Paul Furtado Date: Mon, 8 Aug 2016 18:38:24 -0400 Subject: [PATCH 2/2] Remove variable declaration from for-loop header and enclose in block This solves `error: for loop initial declarations are only allowed in C99 mode` when building on gcc 4.4.7 (Default gcc on CentOS 6.x) --- oursqlx/_exceptions.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/oursqlx/_exceptions.c b/oursqlx/_exceptions.c index 68a4525..bb77f75 100644 --- a/oursqlx/_exceptions.c +++ b/oursqlx/_exceptions.c @@ -618,7 +618,9 @@ enum _oursqlx_exception_type _oursqlx_exc_from_errno(int err) { default: #if MYSQL_VERSION_ID >= 50700 - for(unsigned int i = 0; i < sizeof(errmsg_section_start)/sizeof(int); ++i) { + { + 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 ) { @@ -628,6 +630,7 @@ enum _oursqlx_exception_type _oursqlx_exc_from_errno(int err) { 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;