diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/cbasetypes.h | 19 | ||||
-rw-r--r-- | src/common/db.c | 1 | ||||
-rw-r--r-- | src/common/sql.c | 15 |
3 files changed, 26 insertions, 9 deletions
diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index d3db86543..98c3552c4 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -291,12 +291,19 @@ typedef uintptr_t uintptr; #define GCC_VERSION 0 #endif -// Pragma macro only enabled on gcc >= 4.5 or clang - borrowed from Mana Plus -#if defined(__GNUC__) && (defined(__clang__) || GCC_VERSION >= 40500) -#define PRAGMA_GCC45(str) _Pragma(#str) -#else // ! defined(__GNUC__) && (defined(__clang__) || GCC_VERSION >= 40500) -#define PRAGMA_GCC45(str) -#endif // ! defined(__GNUC__) && (defined(__clang__) || GCC_VERSION >= 40500) +// Pragma macro only enabled on gcc >= 4.6 or clang - borrowed from Mana Plus +#if defined(__GNUC__) && (defined(__clang__) || GCC_VERSION >= 40600) +#define PRAGMA_GCC46(str) _Pragma(#str) +#else // ! defined(__GNUC__) && (defined(__clang__) || GCC_VERSION >= 40600) +#define PRAGMA_GCC46(str) +#endif // ! defined(__GNUC__) && (defined(__clang__) || GCC_VERSION >= 40600) + +// fallthrough attribute only enabled on gcc >= 7.0 +#if defined(__GNUC__) && (GCC_VERSION >= 70000) +#define FALLTHROUGH __attribute__ ((fallthrough)); +#else // ! defined(__GNUC__) && (GCC_VERSION >= 70000) +#define FALLTHROUGH +#endif // ! defined(__GNUC__) && (GCC_VERSION >= 70000) // boolean types for C #if !defined(_MSC_VER) || _MSC_VER >= 1800 diff --git a/src/common/db.c b/src/common/db.c index bbcac4b33..0c7bc2ae0 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -2418,6 +2418,7 @@ enum DBOptions db_fix_options(enum DBType type, enum DBOptions options) default: ShowError("db_fix_options: Unknown database type %u with options %x\n", type, options); + FALLTHROUGH case DB_STRING: case DB_ISTRING: // String databases, no fix required return options; diff --git a/src/common/sql.c b/src/common/sql.c index be0bd43e3..8da105872 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -422,39 +422,48 @@ static int Sql_P_BindSqlDataType(MYSQL_BIND* bind, enum SqlDataType buffer_type, break; // fixed size case SQLDT_UINT8: bind->is_unsigned = 1; + FALLTHROUGH case SQLDT_INT8: bind->buffer_type = MYSQL_TYPE_TINY; buffer_len = 1; break; case SQLDT_UINT16: bind->is_unsigned = 1; + FALLTHROUGH case SQLDT_INT16: bind->buffer_type = MYSQL_TYPE_SHORT; buffer_len = 2; break; case SQLDT_UINT32: bind->is_unsigned = 1; + FALLTHROUGH case SQLDT_INT32: bind->buffer_type = MYSQL_TYPE_LONG; buffer_len = 4; break; case SQLDT_UINT64: bind->is_unsigned = 1; + FALLTHROUGH case SQLDT_INT64: bind->buffer_type = MYSQL_TYPE_LONGLONG; buffer_len = 8; break; // platform dependent size case SQLDT_UCHAR: bind->is_unsigned = 1; + FALLTHROUGH case SQLDT_CHAR: bind->buffer_type = Sql_P_SizeToMysqlIntType(sizeof(char)); buffer_len = sizeof(char); break; case SQLDT_USHORT: bind->is_unsigned = 1; + FALLTHROUGH case SQLDT_SHORT: bind->buffer_type = Sql_P_SizeToMysqlIntType(sizeof(short)); buffer_len = sizeof(short); break; case SQLDT_UINT: bind->is_unsigned = 1; + FALLTHROUGH case SQLDT_INT: bind->buffer_type = Sql_P_SizeToMysqlIntType(sizeof(int)); buffer_len = sizeof(int); break; case SQLDT_ULONG: bind->is_unsigned = 1; + FALLTHROUGH case SQLDT_LONG: bind->buffer_type = Sql_P_SizeToMysqlIntType(sizeof(long)); buffer_len = sizeof(long); break; case SQLDT_ULONGLONG: bind->is_unsigned = 1; + FALLTHROUGH case SQLDT_LONGLONG: bind->buffer_type = Sql_P_SizeToMysqlIntType(sizeof(int64)); buffer_len = sizeof(int64); break; @@ -655,8 +664,8 @@ int SqlStmt_BindParam(struct SqlStmt *self, size_t idx, enum SqlDataType buffer_ if (idx >= self->max_params) return SQL_SUCCESS; // out of range - ignore -PRAGMA_GCC45(GCC diagnostic push) -PRAGMA_GCC45(GCC diagnostic ignored "-Wcast-qual") +PRAGMA_GCC46(GCC diagnostic push) +PRAGMA_GCC46(GCC diagnostic ignored "-Wcast-qual") /* * MySQL uses the same struct with a non-const buffer for both * parameters (input) and columns (output). @@ -664,7 +673,7 @@ PRAGMA_GCC45(GCC diagnostic ignored "-Wcast-qual") * dropping a const qualifier here. */ return Sql_P_BindSqlDataType(self->params+idx, buffer_type, (void *)buffer, buffer_len, NULL, NULL); -PRAGMA_GCC45(GCC diagnostic pop) +PRAGMA_GCC46(GCC diagnostic pop) } /// Executes the prepared statement. |