From 89d11c8b05eef6ddb0dcb90c42cb63f235e71d51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= Date: Wed, 3 Apr 2024 21:21:35 +0100 Subject: [PATCH 1/3] Fix `sys/poll.h` -> `poll.h` See https://pubs.opengroup.org/onlinepubs/7908799/xsh/poll.h.html, or the other files in this project referencing `poll.h`: ```console % grep -r 'poll.h' libmariadb/ma_net.c:#include libmariadb/mariadb_lib.c:#include plugins/pvio/pvio_socket.c:#include unittest/libmariadb/async.c:#include ``` --- plugins/pvio/pvio_socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/pvio/pvio_socket.c b/plugins/pvio/pvio_socket.c index d6046a9e..c891a206 100644 --- a/plugins/pvio/pvio_socket.c +++ b/plugins/pvio/pvio_socket.c @@ -39,7 +39,7 @@ #include #endif #ifdef HAVE_POLL -#include +#include #endif #ifdef HAVE_SYS_IOCTL_H #include From 4c1c7f37d69448d186f47be28689c6af13d22392 Mon Sep 17 00:00:00 2001 From: Josh Hunt Date: Wed, 27 Mar 2024 16:50:20 -0700 Subject: [PATCH 2/3] Fix SSL_read/write return value checking in ma_tls_async_check_result SSL_{read,write}'s return values == 0 signify the operation was unsuccessful, but here it's being treated as success. Other calls of these functions already properly checks the return value. Signed-off-by: Josh Hunt --- libmariadb/mariadb_async.c | 2 +- libmariadb/secure/openssl.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libmariadb/mariadb_async.c b/libmariadb/mariadb_async.c index 8e5d77b1..abb66a16 100644 --- a/libmariadb/mariadb_async.c +++ b/libmariadb/mariadb_async.c @@ -140,7 +140,7 @@ my_ssl_async_check_result(int res, struct mysql_async_context *b, MARIADB_SSL *c { int ssl_err; b->events_to_wait_for= 0; - if (res >= 0) + if (res > 0) return 1; ssl_err= SSL_get_error(ssl, res); if (ssl_err == SSL_ERROR_WANT_READ) diff --git a/libmariadb/secure/openssl.c b/libmariadb/secure/openssl.c index a21d692e..ef6be9b1 100644 --- a/libmariadb/secure/openssl.c +++ b/libmariadb/secure/openssl.c @@ -529,7 +529,7 @@ ma_tls_async_check_result(int res, struct mysql_async_context *b, SSL *ssl) { int ssl_err; b->events_to_wait_for= 0; - if (res >= 0) + if (res > 0) return 1; ssl_err= SSL_get_error(ssl, res); if (ssl_err == SSL_ERROR_WANT_READ) From 51b2a621b3d5ef949098dcb7912048caaf878793 Mon Sep 17 00:00:00 2001 From: Sam James Date: Mon, 4 Mar 2024 04:33:30 +0000 Subject: [PATCH 3/3] Fix -Wcalloc-transposed-args MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes warnings like: ``` unittest/libmariadb/bulk1.c: In function ‘bulk1’: unittest/libmariadb/bulk1.c:77:43: error: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args] 77 | lengths= (unsigned long *)calloc(sizeof(long), TEST_ARRAY_SIZE); | ^~~~ unittest/libmariadb/bulk1.c:77:43: note: earlier argument should specify number of elements, later size of each element unittest/libmariadb/bulk1.c:78:39: error: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argu ment and not in the later argument [-Werror=calloc-transposed-args] 78 | vals= (unsigned int *)calloc(sizeof(int), TEST_ARRAY_SIZE); | ^~~ ``` The calloc prototype is: ``` void *calloc(size_t nmemb, size_t size); ``` So, just swap the number of members and size arguments to match the prototype, as we're initialising N struct of size Y. GCC then sees we're not doing anything wrong. Signed-off-by: Sam James --- plugins/io/remote_io.c | 4 ++-- plugins/trace/trace_example.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/io/remote_io.c b/plugins/io/remote_io.c index c06ecacd..eb5b5f37 100644 --- a/plugins/io/remote_io.c +++ b/plugins/io/remote_io.c @@ -279,11 +279,11 @@ MA_FILE *ma_rio_open(const char *url,const char *operation) MA_REMOTE_FILE *rf; (void)operation; - if (!(file = (MA_FILE *)calloc(sizeof(MA_FILE), 1))) + if (!(file = (MA_FILE *)calloc(1, sizeof(MA_FILE)))) return NULL; file->type= MA_FILE_REMOTE; - if (!(file->ptr= rf= (MA_REMOTE_FILE *)calloc(sizeof(MA_REMOTE_FILE), 1))) + if (!(file->ptr= rf= (MA_REMOTE_FILE *)calloc(1, sizeof(MA_REMOTE_FILE)))) { free(file); return NULL; diff --git a/plugins/trace/trace_example.c b/plugins/trace/trace_example.c index 1060542c..e177c206 100644 --- a/plugins/trace/trace_example.c +++ b/plugins/trace/trace_example.c @@ -132,7 +132,7 @@ static TRACE_INFO *get_trace_info(unsigned long thread_id) info= (TRACE_INFO *)info->next; } - if (!(info= (TRACE_INFO *)calloc(sizeof(TRACE_INFO), 1))) + if (!(info= (TRACE_INFO *)calloc(1, sizeof(TRACE_INFO)))) return NULL; info->thread_id= thread_id; info->next= trace_info;