From f7fe2b6f7a184c92ff50290f3c2adfd4dcead010 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Fri, 29 Jun 2018 10:10:38 +0200 Subject: [PATCH] fix some [-Wformat=], [-Werror=format-security] and [-Wformat-extra-args] build warnings --- .gitignore | 1 + messages/mysqlx_resultset__data_row.cc | 5 ++--- util/exceptions.cc | 4 ++-- xmysqlnd/xmysqlnd_session.cc | 4 ++-- xmysqlnd/xmysqlnd_wireprotocol.cc | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/messages/mysqlx_resultset__data_row.cc b/messages/mysqlx_resultset__data_row.cc index 20cb05e..0d2f660 100644 --- a/messages/mysqlx_resultset__data_row.cc +++ b/messages/mysqlx_resultset__data_row.cc @@ -318,8 +318,7 @@ MYSQL_XDEVAPI_PHP_METHOD(mysqlx_data_row, decode) (unsigned int) day, (unsigned int) hours, (unsigned int) minutes, - (unsigned int) seconds, - (unsigned int) useconds)); + (unsigned int) seconds)); #undef DATETIME_FMT_STR break; } @@ -360,7 +359,7 @@ MYSQL_XDEVAPI_PHP_METHOD(mysqlx_data_row, decode) break; } if (buf_size == 1) { - php_error_docref(nullptr, E_WARNING, "Unexpected value %d for first byte of TIME"); + php_error_docref(nullptr, E_WARNING, "Unexpected value for first byte of TIME"); } const uint8_t scale = buf[0]; const uint8_t last_byte = buf[buf_size - 1]; /* last byte is the sign and the last 4 bits, if any */ diff --git a/util/exceptions.cc b/util/exceptions.cc index a611ea2..ed8def7 100644 --- a/util/exceptions.cc +++ b/util/exceptions.cc @@ -154,7 +154,7 @@ void raise_doc_ref_exception(const doc_ref_exception& e) }; const int severity = severity_mapping.at(e.severity); const char* what = e.what(); - php_error_docref(nullptr, severity, what); + php_error_docref(nullptr, severity, "%s", what); } /* }}} */ @@ -179,7 +179,7 @@ void raise_unknown_exception() /* {{{ mysqlx::util::log_warning */ void log_warning(const string& msg) { - php_error_docref(nullptr, E_WARNING, msg.c_str()); + php_error_docref(nullptr, E_WARNING, "%s", msg.c_str()); } /* }}} */ diff --git a/xmysqlnd/xmysqlnd_session.cc b/xmysqlnd/xmysqlnd_session.cc index f9a9fa4..617bb0a 100644 --- a/xmysqlnd/xmysqlnd_session.cc +++ b/xmysqlnd/xmysqlnd_session.cc @@ -1239,7 +1239,7 @@ XMYSQLND_METHOD(xmysqlnd_session_data, authenticate)( os << "[HY000] Authentication failed using " << boost::join(auth_mech_names, ", ") << ". Check username and password or try a secure connection"; - php_error_docref(nullptr, E_WARNING, os.str().c_str()); + php_error_docref(nullptr, E_WARNING, "%s", os.str().c_str()); } } } @@ -2983,7 +2983,7 @@ XMYSQLND_SESSION_AUTH_DATA * extract_auth_information(const util::Url& node_url) XMYSQLND_SESSION_AUTH_DATA * auth = new XMYSQLND_SESSION_AUTH_DATA; if( nullptr == auth ) { - php_error_docref(nullptr, E_WARNING, "Coulnd't allocate %u bytes", + php_error_docref(nullptr, E_WARNING, "Coulnd't allocate %lu bytes", sizeof(XMYSQLND_SESSION_AUTH_DATA)); DBG_RETURN(nullptr); } diff --git a/xmysqlnd/xmysqlnd_wireprotocol.cc b/xmysqlnd/xmysqlnd_wireprotocol.cc index 0c7bb69..637bfe8 100644 --- a/xmysqlnd/xmysqlnd_wireprotocol.cc +++ b/xmysqlnd/xmysqlnd_wireprotocol.cc @@ -181,7 +181,7 @@ xmysqlnd_inspect_changed_exec_state(const struct st_xmysqlnd_on_execution_state_ case Mysqlx::Notice::SessionStateChanged::ROWS_MATCHED: state_type = EXEC_STATE_ROWS_MATCHED; break; default: DBG_ERR_FMT("Unknown param name %d. Please add it to the switch", message.param()); - php_error_docref("Unknown param name %d in %s::%d. Please add it to the switch", message.param(), __FILE__, __LINE__); + php_error_docref(nullptr, E_WARNING, "Unknown param name %d in %s::%d. Please add it to the switch", message.param(), __FILE__, __LINE__); break; } if (state_type != EXEC_STATE_NONE) {