tests: fix callback signatures to please UndefinedBehaviorSanitizer

Make test applications use the correct prototypes for callbacks.

Closes #15289
This commit is contained in:
Daniel Stenberg 2024-10-14 13:01:19 +02:00
parent eed3c8f4b7
commit 8403e5a701
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
17 changed files with 59 additions and 58 deletions

View file

@ -180,7 +180,7 @@ UNITTEST DOHcode doh_req_encode(const char *host,
}
static size_t
doh_write_cb(const void *contents, size_t size, size_t nmemb, void *userp)
doh_write_cb(char *contents, size_t size, size_t nmemb, void *userp)
{
size_t realsize = size * nmemb;
struct dynbuf *mem = (struct dynbuf *)userp;

View file

@ -398,9 +398,9 @@ struct events {
* Callback that gets called with a new value when the timeout should be
* updated.
*/
static int events_timer(struct Curl_multi *multi, /* multi handle */
static int events_timer(CURLM *multi, /* multi handle */
long timeout_ms, /* see above */
void *userp) /* private callback pointer */
void *userp) /* private callback pointer */
{
struct events *ev = userp;
(void)multi;
@ -449,7 +449,7 @@ static short socketcb2poll(int pollmask)
* Callback that gets called with information about socket activity to
* monitor.
*/
static int events_socket(struct Curl_easy *easy, /* easy handle */
static int events_socket(CURL *easy, /* easy handle */
curl_socket_t s, /* socket */
int what, /* see above */
void *userp, /* private callback
@ -461,6 +461,7 @@ static int events_socket(struct Curl_easy *easy, /* easy handle */
struct socketmonitor *m;
struct socketmonitor *prev = NULL;
bool found = FALSE;
struct Curl_easy *data = easy;
#if defined(CURL_DISABLE_VERBOSE_STRINGS)
(void) easy;
@ -479,13 +480,13 @@ static int events_socket(struct Curl_easy *easy, /* easy handle */
else
ev->list = nxt;
free(m);
infof(easy, "socket cb: socket %" FMT_SOCKET_T " REMOVED", s);
infof(data, "socket cb: socket %" FMT_SOCKET_T " REMOVED", s);
}
else {
/* The socket 's' is already being monitored, update the activity
mask. Convert from libcurl bitmask to the poll one. */
m->socket.events = socketcb2poll(what);
infof(easy, "socket cb: socket %" FMT_SOCKET_T
infof(data, "socket cb: socket %" FMT_SOCKET_T
" UPDATED as %s%s", s,
(what&CURL_POLL_IN) ? "IN" : "",
(what&CURL_POLL_OUT) ? "OUT" : "");
@ -499,7 +500,7 @@ static int events_socket(struct Curl_easy *easy, /* easy handle */
if(!found) {
if(what == CURL_POLL_REMOVE) {
/* should not happen if our logic is correct, but is no drama. */
DEBUGF(infof(easy, "socket cb: asked to REMOVE socket %"
DEBUGF(infof(data, "socket cb: asked to REMOVE socket %"
FMT_SOCKET_T "but not present!", s));
DEBUGASSERT(0);
}
@ -511,7 +512,7 @@ static int events_socket(struct Curl_easy *easy, /* easy handle */
m->socket.events = socketcb2poll(what);
m->socket.revents = 0;
ev->list = m;
infof(easy, "socket cb: socket %" FMT_SOCKET_T " ADDED as %s%s", s,
infof(data, "socket cb: socket %" FMT_SOCKET_T " ADDED as %s%s", s,
(what&CURL_POLL_IN) ? "IN" : "",
(what&CURL_POLL_OUT) ? "OUT" : "");
}

View file

@ -27,7 +27,7 @@
#include "curl_setup.h"
#include "timeval.h"
struct Curl_easy;
void Curl_speedinit(struct Curl_easy *data);
CURLcode Curl_speedcheck(struct Curl_easy *data,
struct curltime now);