###########################################################################
include(CheckCCompilerFlag)
+unset(WPICKY)
+
+if(CURL_WERROR AND CMAKE_COMPILER_IS_GNUCC AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0)
+ set(WPICKY "${WPICKY} -pedantic-errors")
+endif()
+
if(PICKY_COMPILER)
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
-Wno-sign-conversion # clang 2.9 gcc 4.3
-Wno-system-headers # clang 1.0 gcc 3.0
# -Wpadded # clang 2.9 gcc 4.1 # Not used because we cannot change public structs
- -Wredundant-decls # clang 2.7 gcc 4.1
-Wold-style-definition # clang 2.7 gcc 3.4
+ -Wredundant-decls # clang 2.7 gcc 4.1
+ # -Wsign-conversion # clang 2.9 gcc 4.3 # FIXME
+ # -Wno-error=sign-conversion # FIXME
-Wstrict-prototypes # clang 1.0 gcc 3.3
# -Wswitch-enum # clang 2.7 gcc 4.1 # Not used because this basically disallows default case
-Wtype-limits # clang 2.7 gcc 4.3
-Wshift-sign-overflow # clang 2.9
-Wshorten-64-to-32 # clang 1.0
-Wlanguage-extension-token # clang 3.0
+ -Wformat=2 # clang 3.0 gcc 4.8
)
# Enable based on compiler version
if((CMAKE_C_COMPILER_ID STREQUAL "Clang" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.6) OR
-Wextra-semi-stmt # clang 7.0 appleclang 10.3
)
endif()
+ if((CMAKE_C_COMPILER_ID STREQUAL "Clang" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 10.0) OR
+ (CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 12.4))
+ list(APPEND WPICKY_ENABLE
+ -Wimplicit-fallthrough # clang 4.0 gcc 7.0 appleclang 12.4 # we have silencing markup for clang 10.0 and above only
+ )
+ endif()
else() # gcc
list(APPEND WPICKY_DETECT
${WPICKY_COMMON}
-Wmissing-parameter-type # gcc 4.3
-Wold-style-declaration # gcc 4.3
-Wstrict-aliasing=3 # gcc 4.0
+ -Wtrampolines # gcc 4.3
)
endif()
if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.5 AND MINGW)
endif()
if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.8)
list(APPEND WPICKY_ENABLE
- -Wformat=2 # clang 3.0 gcc 4.8 (clang part-default, enabling it fully causes -Wformat-nonliteral warnings)
+ -Wformat=2 # clang 3.0 gcc 4.8
)
endif()
if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0)
-Wduplicated-branches # gcc 7.0
-Wformat-overflow=2 # gcc 7.0
-Wformat-truncation=2 # gcc 7.0
+ -Wimplicit-fallthrough # clang 4.0 gcc 7.0
-Wrestrict # gcc 7.0
)
endif()
#
- unset(WPICKY)
-
foreach(_CCOPT IN LISTS WPICKY_ENABLE)
set(WPICKY "${WPICKY} ${_CCOPT}")
endforeach()
set(WPICKY "${WPICKY} ${_CCOPT}")
endif()
endforeach()
-
- message(STATUS "Picky compiler options:${WPICKY}")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WPICKY}")
endif()
endif()
+
+if(WPICKY)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WPICKY}")
+ message(STATUS "Picky compiler options:${WPICKY}")
+endif()
default:
fprintf(stderr, "\r%s: invalid parameter %s\n",
appname, *argv + 3);
- exit(1);
+ return 1;
}
break;
}
- /* FALLTHROUGH */
+ fprintf(stderr, "\r%s: invalid or unknown option %s\n",
+ appname, *argv);
+ return 1;
default:
fprintf(stderr, "\r%s: invalid or unknown option %s\n",
appname, *argv);
- exit(1);
+ return 1;
}
}
else {
switch(type) {
case CURLINFO_TEXT:
fprintf(stderr, "== Info: %s", data);
- /* FALLTHROUGH */
- default: /* in case a new one is introduced to shock us */
return 0;
-
case CURLINFO_HEADER_OUT:
text = "=> Send header";
break;
case CURLINFO_SSL_DATA_IN:
text = "<= Recv SSL data";
break;
+ default: /* in case a new one is introduced to shock us */
+ return 0;
}
dump(text, stderr, (unsigned char *)data, size, config->trace_ascii);
switch(type) {
case CURLINFO_TEXT:
fprintf(stderr, "== %u Info: %s", num, data);
- /* FALLTHROUGH */
- default: /* in case a new one is introduced to shock us */
return 0;
-
case CURLINFO_HEADER_OUT:
text = "=> Send header";
break;
case CURLINFO_SSL_DATA_IN:
text = "<= Recv SSL data";
break;
+ default: /* in case a new one is introduced to shock us */
+ return 0;
}
dump(text, num, (unsigned char *)data, size, 1);
switch(type) {
case CURLINFO_TEXT:
fprintf(stderr, "== Info: %s", data);
- /* FALLTHROUGH */
- default: /* in case a new one is introduced to shock us */
return 0;
-
case CURLINFO_HEADER_OUT:
text = "=> Send header";
break;
case CURLINFO_SSL_DATA_IN:
text = "<= Recv SSL data";
break;
+ default: /* in case a new one is introduced to shock us */
+ return 0;
}
dump(text, (unsigned char *)data, size, 1);
switch(type) {
case CURLINFO_TEXT:
fprintf(stderr, "%s [%d] Info: %s", timebuf, num, data);
- /* FALLTHROUGH */
- default: /* in case a new one is introduced to shock us */
return 0;
-
case CURLINFO_HEADER_OUT:
text = "=> Send header";
break;
case CURLINFO_SSL_DATA_IN:
text = "<= Recv SSL data";
break;
+ default: /* in case a new one is introduced to shock us */
+ return 0;
}
dump(text, num, (unsigned char *)data, size, 1);
switch(type) {
case CURLINFO_TEXT:
fprintf(stderr, "== Info: %s", data);
- /* FALLTHROUGH */
- default: /* in case a new one is introduced to shock us */
return 0;
-
case CURLINFO_HEADER_OUT:
text = "=> Send header";
break;
case CURLINFO_DATA_IN:
text = "<= Recv data";
break;
+ default: /* in case a new one is introduced to shock us */
+ return 0;
}
dump(text, stderr, data, size, TRUE);
#if (defined(__GNUC__) || defined(__clang__)) && \
defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
- !defined(__MINGW32__) && !defined(CURL_NO_FMT_CHECKS)
-#define CURL_TEMP_PRINTF(a,b) __attribute__ ((format(printf, a, b)))
+ !defined(CURL_NO_FMT_CHECKS)
+#if defined(__MINGW32__) && !defined(__clang__)
+#define CURL_TEMP_PRINTF(fmt, arg) \
+ __attribute__((format(gnu_printf, fmt, arg)))
#else
-#define CURL_TEMP_PRINTF(a,b)
+#define CURL_TEMP_PRINTF(fmt, arg) \
+ __attribute__((format(printf, fmt, arg)))
+#endif
+#else
+#define CURL_TEMP_PRINTF(fmt, arg)
#endif
CURL_EXTERN int curl_mprintf(const char *format, ...) CURL_TEMP_PRINTF(1, 2);
infof(data, "CONNECT phase completed");
data->state.authproxy.done = TRUE;
data->state.authproxy.multipass = FALSE;
- /* FALLTHROUGH */
+ FALLTHROUGH();
case H1_TUNNEL_FAILED:
if(new_state == H1_TUNNEL_FAILED)
CURL_TRC_CF(data, cf, "new tunnel state 'failed'");
if(result)
goto out;
h1_tunnel_go_state(cf, ts, H1_TUNNEL_CONNECT, data);
- /* FALLTHROUGH */
+ FALLTHROUGH();
case H1_TUNNEL_CONNECT:
/* see that the request is completely sent */
if(result || !done)
goto out;
h1_tunnel_go_state(cf, ts, H1_TUNNEL_RECEIVE, data);
- /* FALLTHROUGH */
+ FALLTHROUGH();
case H1_TUNNEL_RECEIVE:
/* read what is there */
goto out;
/* got it */
h1_tunnel_go_state(cf, ts, H1_TUNNEL_RESPONSE, data);
- /* FALLTHROUGH */
+ FALLTHROUGH();
case H1_TUNNEL_RESPONSE:
CURL_TRC_CF(data, cf, "CONNECT response");
infof(data, "CONNECT phase completed");
data->state.authproxy.done = TRUE;
data->state.authproxy.multipass = FALSE;
- /* FALLTHROUGH */
+ FALLTHROUGH();
case H2_TUNNEL_FAILED:
if(new_state == H2_TUNNEL_FAILED)
CURL_TRC_CF(data, cf, "[%d] new tunnel state 'failed'", ts->stream_id);
if(result)
goto out;
h2_tunnel_go_state(cf, ts, H2_TUNNEL_CONNECT, data);
- /* FALLTHROUGH */
+ FALLTHROUGH();
case H2_TUNNEL_CONNECT:
/* see that the request is completely sent */
result = CURLE_OK;
goto out;
}
- /* FALLTHROUGH */
+ FALLTHROUGH();
case H2_TUNNEL_RESPONSE:
DEBUGASSERT(ts->has_final_response);
if(result)
goto out;
ctx->state = HAPROXY_SEND;
- /* FALLTHROUGH */
+ FALLTHROUGH();
case HAPROXY_SEND:
len = Curl_dyn_len(&ctx->data_out);
if(len > 0) {
}
}
ctx->state = HAPROXY_DONE;
- /* FALLTHROUGH */
+ FALLTHROUGH();
default:
Curl_dyn_free(&ctx->data_out);
break;
cf_hc_baller_init(&ctx->h21_baller, cf, data, "h21",
cf->conn->transport);
ctx->state = CF_HC_CONNECT;
- /* FALLTHROUGH */
+ FALLTHROUGH();
case CF_HC_CONNECT:
if(cf_hc_baller_is_active(&ctx->h3_baller)) {
/* only set IDLE and INTVL if setting KEEPALIVE is successful */
if(setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE,
(void *)&optval, sizeof(optval)) < 0) {
- infof(data, "Failed to set SO_KEEPALIVE on fd %d", sockfd);
+ infof(data, "Failed to set SO_KEEPALIVE on fd %" CURL_FORMAT_SOCKET_T,
+ sockfd);
}
else {
#if defined(SIO_KEEPALIVE_VALS)
vals.keepaliveinterval = optval;
if(WSAIoctl(sockfd, SIO_KEEPALIVE_VALS, (LPVOID) &vals, sizeof(vals),
NULL, 0, &dummy, NULL, NULL) != 0) {
- infof(data, "Failed to set SIO_KEEPALIVE_VALS on fd %d: %d",
- (int)sockfd, WSAGetLastError());
+ infof(data, "Failed to set SIO_KEEPALIVE_VALS on fd "
+ "%" CURL_FORMAT_SOCKET_T ": %d",
+ sockfd, WSAGetLastError());
}
#else
#ifdef TCP_KEEPIDLE
KEEPALIVE_FACTOR(optval);
if(setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPIDLE,
(void *)&optval, sizeof(optval)) < 0) {
- infof(data, "Failed to set TCP_KEEPIDLE on fd %d", sockfd);
+ infof(data, "Failed to set TCP_KEEPIDLE on fd %" CURL_FORMAT_SOCKET_T,
+ sockfd);
}
#elif defined(TCP_KEEPALIVE)
/* Mac OS X style */
KEEPALIVE_FACTOR(optval);
if(setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPALIVE,
(void *)&optval, sizeof(optval)) < 0) {
- infof(data, "Failed to set TCP_KEEPALIVE on fd %d", sockfd);
+ infof(data, "Failed to set TCP_KEEPALIVE on fd %" CURL_FORMAT_SOCKET_T,
+ sockfd);
}
#endif
#ifdef TCP_KEEPINTVL
KEEPALIVE_FACTOR(optval);
if(setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPINTVL,
(void *)&optval, sizeof(optval)) < 0) {
- infof(data, "Failed to set TCP_KEEPINTVL on fd %d", sockfd);
+ infof(data, "Failed to set TCP_KEEPINTVL on fd %" CURL_FORMAT_SOCKET_T,
+ sockfd);
}
#endif
#endif
if(result)
goto out;
-#ifndef CURL_DISABLE_VERBOSE_STRINGS
- {
- const char *ipmsg;
#ifdef ENABLE_IPV6
- if(ctx->addr.family == AF_INET6) {
- set_ipv6_v6only(ctx->sock, 0);
- ipmsg = " Trying [%s]:%d...";
- }
- else
-#endif
- ipmsg = " Trying %s:%d...";
- infof(data, ipmsg, ctx->r_ip, ctx->r_port);
+ if(ctx->addr.family == AF_INET6) {
+ set_ipv6_v6only(ctx->sock, 0);
+ infof(data, " Trying [%s]:%d...", ctx->r_ip, ctx->r_port);
}
+ else
#endif
+ infof(data, " Trying %s:%d...", ctx->r_ip, ctx->r_port);
#ifdef ENABLE_IPV6
is_tcp = (ctx->addr.family == AF_INET
*when = ctx->first_byte_at;
break;
}
- /* FALLTHROUGH */
+ FALLTHROUGH();
default:
*when = ctx->connected_at;
break;
struct connectdata;
struct Curl_sockaddr_ex;
-#ifndef SIZEOF_CURL_SOCKET_T
-/* configure and cmake check and set the define */
-# ifdef _WIN64
-# define SIZEOF_CURL_SOCKET_T 8
-# else
-/* default guess */
-# define SIZEOF_CURL_SOCKET_T 4
-# endif
-#endif
-
-#if SIZEOF_CURL_SOCKET_T < 8
-# define CURL_FORMAT_SOCKET_T "d"
-#else
-# define CURL_FORMAT_SOCKET_T "qd"
-#endif
-
-
/*
* The Curl_sockaddr_ex structure is basically libcurl's external API
* curl_sockaddr structure with enough space available to directly hold any
if(result)
return result;
ctx->state = SCFST_WAITING;
- /* FALLTHROUGH */
+ FALLTHROUGH();
case SCFST_WAITING:
result = is_connected(cf, data, done);
if(!result && *done) {
if(!co->spath)
badcookie = TRUE;
fields++; /* add a field and fall down to secure */
- /* FALLTHROUGH */
+ FALLTHROUGH();
case 3:
co->secure = FALSE;
if(strcasecompare(ptr, "TRUE")) {
/* connection is already authenticated,
* don't send a header in future requests */
*state = NTLMSTATE_LAST;
- /* FALLTHROUGH */
+ FALLTHROUGH();
case NTLMSTATE_LAST:
Curl_safefree(*allocuserpwd);
authp->done = TRUE;
#include <curl/system.h>
+/* curl uses its own printf() function internally. It understands the GNU
+ * format. Use this format, so that is matches the GNU format attribute we
+ * use with the mingw compiler, allowing it to verify them at compile-time.
+ */
+#ifdef __MINGW32__
+# undef CURL_FORMAT_CURL_OFF_T
+# undef CURL_FORMAT_CURL_OFF_TU
+# define CURL_FORMAT_CURL_OFF_T "lld"
+# define CURL_FORMAT_CURL_OFF_TU "llu"
+#endif
+
+/* based on logic in "curl/mprintf.h" */
+
+#if (defined(__GNUC__) || defined(__clang__)) && \
+ defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
+ !defined(CURL_NO_FMT_CHECKS)
+#if defined(__MINGW32__) && !defined(__clang__)
+#define CURL_PRINTF(fmt, arg) \
+ __attribute__((format(gnu_printf, fmt, arg)))
+#else
+#define CURL_PRINTF(fmt, arg) \
+ __attribute__((format(__printf__, fmt, arg)))
+#endif
+#else
+#define CURL_PRINTF(fmt, arg)
+#endif
+
/*
* Use getaddrinfo to resolve the IPv4 address literal. If the current network
* interface doesn't support IPv4, but supports IPv6, NAT64, and DNS64,
#define SIZEOF_TIME_T 4
#endif
+#ifndef SIZEOF_CURL_SOCKET_T
+/* configure and cmake check and set the define */
+# ifdef _WIN64
+# define SIZEOF_CURL_SOCKET_T 8
+# else
+/* default guess */
+# define SIZEOF_CURL_SOCKET_T 4
+# endif
+#endif
+
+#if SIZEOF_CURL_SOCKET_T < 8
+# define CURL_FORMAT_SOCKET_T "d"
+#elif defined(__MINGW32__)
+# define CURL_FORMAT_SOCKET_T "zd"
+#else
+# define CURL_FORMAT_SOCKET_T "qd"
+#endif
+
/*
* Default sizeof(off_t) in case it hasn't been defined in config file.
*/
#endif
#endif
+/* fallthrough attribute */
+
+#if !defined(FALLTHROUGH)
+#if (defined(__GNUC__) && __GNUC__ >= 7) || \
+ (defined(__clang__) && __clang_major__ >= 10)
+# define FALLTHROUGH() __attribute__((fallthrough))
+#else
+# define FALLTHROUGH() do {} while (0)
+#endif
+#endif
+
/*
* Include macros and defines that should only be processed once.
*/
int len;
char error[CURL_ERROR_SIZE + 2];
va_start(ap, fmt);
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
+#endif
len = mvsnprintf(error, CURL_ERROR_SIZE, fmt, ap);
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
if(data->set.errorbuffer && !data->state.errorbuf) {
strcpy(data->set.errorbuffer, error);
int len;
char buffer[MAXINFO + 2];
va_start(ap, fmt);
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
+#endif
len = mvsnprintf(buffer, MAXINFO, fmt, ap);
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
va_end(ap);
buffer[len++] = '\n';
buffer[len] = '\0';
char buffer[MAXINFO + 2];
len = msnprintf(buffer, MAXINFO, "[%s] ", cf->cft->name);
va_start(ap, fmt);
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
+#endif
len += mvsnprintf(buffer + len, MAXINFO - len, fmt, ap);
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
va_end(ap);
buffer[len++] = '\n';
buffer[len] = '\0';
* Output a failure message on registered callbacks for transfer.
*/
void Curl_failf(struct Curl_easy *data,
-#if defined(__GNUC__) && !defined(printf) && \
- defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
- !defined(__MINGW32__)
- const char *fmt, ...)
- __attribute__((format(printf, 2, 3)));
-#else
- const char *fmt, ...);
-#endif
+ const char *fmt, ...) CURL_PRINTF(2, 3);
#define failf Curl_failf
* Output an informational message when transfer's verbose logging is enabled.
*/
void Curl_infof(struct Curl_easy *data,
-#if defined(__GNUC__) && !defined(printf) && defined(CURL_HAVE_C99) && \
- !defined(__MINGW32__)
- const char *fmt, ...)
- __attribute__((format(printf, 2, 3)));
-#else
- const char *fmt, ...);
-#endif
+ const char *fmt, ...) CURL_PRINTF(2, 3);
/**
* Output an informational message when both transfer's verbose logging
* and connection filters verbose logging are enabled.
*/
void Curl_trc_cf_infof(struct Curl_easy *data, struct Curl_cfilter *cf,
-#if defined(__GNUC__) && !defined(printf) && defined(CURL_HAVE_C99) && \
- !defined(__MINGW32__)
- const char *fmt, ...)
- __attribute__((format(printf, 3, 4)));
-#else
- const char *fmt, ...);
-#endif
+ const char *fmt, ...) CURL_PRINTF(3, 4);
#else /* defined(CURL_DISABLE_VERBOSE_STRINGS) */
/* All informational messages are not compiled in for size savings */
}
/* sendf() sends formatted data to the server */
+static CURLcode sendf(curl_socket_t sockfd, struct Curl_easy *data,
+ const char *fmt, ...) CURL_PRINTF(3, 4);
+
static CURLcode sendf(curl_socket_t sockfd, struct Curl_easy *data,
const char *fmt, ...)
{
char *sptr;
va_list ap;
va_start(ap, fmt);
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
+#endif
s = vaprintf(fmt, ap); /* returns an allocated string */
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
va_end(ap);
if(!s)
return CURLE_OUT_OF_MEMORY; /* failure */
return CURLE_OK;
#else
char *str;
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
+#endif
str = vaprintf(fmt, ap); /* this allocs a new string to append */
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
if(str) {
CURLcode result = dyn_nappend(s, (unsigned char *)str, strlen(str));
CURLcode Curl_dyn_add(struct dynbuf *s, const char *str)
WARN_UNUSED_RESULT;
CURLcode Curl_dyn_addf(struct dynbuf *s, const char *fmt, ...)
- WARN_UNUSED_RESULT;
+ WARN_UNUSED_RESULT CURL_PRINTF(2, 3);
CURLcode Curl_dyn_vaddf(struct dynbuf *s, const char *fmt, va_list ap)
- WARN_UNUSED_RESULT;
+ WARN_UNUSED_RESULT CURL_PRINTF(2, 0);
void Curl_dyn_reset(struct dynbuf *s);
CURLcode Curl_dyn_tail(struct dynbuf *s, size_t trail);
CURLcode Curl_dyn_setlen(struct dynbuf *s, size_t set);
ev->list = nxt;
free(m);
m = nxt;
- infof(easy, "socket cb: socket %d REMOVED", s);
+ infof(easy, "socket cb: socket %" CURL_FORMAT_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 %d UPDATED as %s%s", s,
+ infof(easy, "socket cb: socket %" CURL_FORMAT_SOCKET_T
+ " UPDATED as %s%s", s,
(what&CURL_POLL_IN)?"IN":"",
(what&CURL_POLL_OUT)?"OUT":"");
}
m->socket.events = socketcb2poll(what);
m->socket.revents = 0;
ev->list = m;
- infof(easy, "socket cb: socket %d ADDED as %s%s", s,
+ infof(easy, "socket cb: socket %" CURL_FORMAT_SOCKET_T
+ " ADDED as %s%s", s,
(what&CURL_POLL_IN)?"IN":"",
(what&CURL_POLL_OUT)?"OUT":"");
}
if(fds[i].revents) {
/* socket activity, tell libcurl */
int act = poll2cselect(fds[i].revents); /* convert */
- infof(multi->easyp, "call curl_multi_socket_action(socket %d)",
- fds[i].fd);
+ infof(multi->easyp,
+ "call curl_multi_socket_action(socket "
+ "%" CURL_FORMAT_SOCKET_T ")", fds[i].fd);
mcode = curl_multi_socket_action(multi, fds[i].fd, act,
&ev->running_handles);
}
case CURLFORM_PTRNAME:
current_form->flags |= HTTPPOST_PTRNAME; /* fall through */
- /* FALLTHROUGH */
+ FALLTHROUGH();
case CURLFORM_COPYNAME:
if(current_form->name)
return_value = CURL_FORMADD_OPTION_TWICE;
*/
case CURLFORM_PTRCONTENTS:
current_form->flags |= HTTPPOST_PTRCONTENTS;
- /* FALLTHROUGH */
+ FALLTHROUGH();
case CURLFORM_COPYCONTENTS:
if(current_form->value)
return_value = CURL_FORMADD_OPTION_TWICE;
break;
case FTP_QUIT:
- /* fallthrough, just stop! */
default:
/* internal error */
ftp_state(data, FTP_STOP);
case CURLE_REMOTE_FILE_NOT_FOUND:
case CURLE_WRITE_ERROR:
/* the connection stays alive fine even though this happened */
- /* fall-through */
case CURLE_OK: /* doesn't affect the control connection's status */
if(!premature)
break;
/* until we cope better with prematurely ended requests, let them
* fallback as if in complete failure */
- /* FALLTHROUGH */
+ FALLTHROUGH();
default: /* by default, an error means the control connection is
wedged and should not be used anymore */
ftpc->ctl_valid = FALSE;
* fields. */
if(data->set.timecondition)
data->info.timecond = TRUE;
- /* FALLTHROUGH */
+ FALLTHROUGH();
case 204:
/* (quote from RFC2616, section 10.2.5): The server has
* fulfilled the request but does not need to return an
break;
case IMAP_LOGOUT:
- /* fallthrough, just stop! */
default:
/* internal error */
imap_state(data, IMAP_STOP);
if(!result) {
va_list ap;
va_start(ap, fmt);
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
+#endif
result = Curl_pp_vsendf(data, &imapc->pp, Curl_dyn_ptr(&imapc->dyn), ap);
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
va_end(ap);
}
return result;
case PROT_PRIVATE:
return 'P';
case PROT_CMD:
- /* Fall through */
default:
/* Those 2 cases should not be reached! */
break;
_ldap_trace x; \
} while(0)
- static void _ldap_trace(const char *fmt, ...);
+ static void _ldap_trace(const char *fmt, ...) CURL_PRINTF(1, 2);
#else
#define LDAP_TRACE(x) Curl_nop_stmt
#endif
sockfd = socket(domain, type, protocol);
- if(source && (sockfd != CURL_SOCKET_BAD))
+ if(source && (sockfd != CURL_SOCKET_BAD)) {
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
+#endif
curl_dbg_log(fmt, source, line, sockfd);
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+ }
return sockfd;
}
int res = socketpair(domain, type, protocol, socket_vector);
- if(source && (0 == res))
+ if(source && (0 == res)) {
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
+#endif
curl_dbg_log(fmt, source, line, socket_vector[0], socket_vector[1]);
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+ }
return res;
}
curl_socket_t sockfd = accept(s, addr, addrlen);
- if(source && (sockfd != CURL_SOCKET_BAD))
+ if(source && (sockfd != CURL_SOCKET_BAD)) {
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
+#endif
curl_dbg_log(fmt, source, line, sockfd);
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+ }
return sockfd;
}
"FD %s:%d sclose(%ld)\n":
"FD %s:%d sclose(%zd)\n";
- if(source)
+ if(source) {
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
+#endif
curl_dbg_log(fmt, source, line, sockfd);
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+ }
}
/* this is our own defined way to close sockets on *ALL* platforms */
return;
va_start(ap, format);
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
+#endif
nchars = mvsnprintf(buf, LOGLINE_BUFSIZE, format, ap);
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
va_end(ap);
if(nchars > LOGLINE_BUFSIZE - 1)
CURL_EXTERN void curl_dbg_memdebug(const char *logname);
CURL_EXTERN void curl_dbg_memlimit(long limit);
-CURL_EXTERN void curl_dbg_log(const char *format, ...);
+CURL_EXTERN void curl_dbg_log(const char *format, ...) CURL_PRINTF(1, 2);
/* file descriptor manipulators */
CURL_EXTERN curl_socket_t curl_dbg_socket(int domain, int type, int protocol,
case MIMEKIND_FILE:
if(part->fp && feof(part->fp))
break; /* At EOF. */
- /* FALLTHROUGH */
+ FALLTHROUGH();
default:
if(part->readfunc) {
if(!(part->flags & MIME_FAST_READ)) {
mimesetstate(&part->state, MIMESTATE_USERHEADERS, hdr->next);
break;
}
- /* FALLTHROUGH */
+ FALLTHROUGH();
case MIMESTATE_CURLHEADERS:
if(!hdr)
mimesetstate(&part->state, MIMESTATE_USERHEADERS, part->userheaders);
fclose(part->fp);
part->fp = NULL;
}
- /* FALLTHROUGH */
+ FALLTHROUGH();
case CURL_READFUNC_ABORT:
case CURL_READFUNC_PAUSE:
case READ_ERROR:
va_list ap;
va_start(ap, fmt);
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
+#endif
s = curl_mvaprintf(fmt, ap);
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
va_end(ap);
if(s) {
size_t lastreadstatus; /* Last read callback returned status. */
};
-CURLcode Curl_mime_add_header(struct curl_slist **slp, const char *fmt, ...);
+CURLcode Curl_mime_add_header(struct curl_slist **slp, const char *fmt, ...)
+ CURL_PRINTF(2, 3);
#if !defined(CURL_DISABLE_MIME) && (!defined(CURL_DISABLE_HTTP) || \
!defined(CURL_DISABLE_SMTP) || \
case '0':
if(!(flags & FLAGS_LEFT))
flags |= FLAGS_PAD_NIL;
- /* FALLTHROUGH */
+ FALLTHROUGH();
case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
flags |= FLAGS_WIDTH;
break;
case '\0':
fmt--;
+ FALLTHROUGH();
default:
break;
}
switch(*fmt) {
case 'S':
flags |= FLAGS_ALT;
- /* FALLTHROUGH */
+ FALLTHROUGH();
case 's':
vto[i].type = FORMAT_STRING;
break;
data->req.bytecount = 0;
data->req.size = remlen;
mq->npacket = remlen; /* get this many bytes */
- /* FALLTHROUGH */
+ FALLTHROUGH();
case MQTT_PUB_REMAIN: {
/* read rest of packet, but no more. Cap to buffer size */
size_t rest = mq->npacket;
/* remember the first byte */
mq->npacket = 0;
mqstate(data, MQTT_REMAINING_LENGTH, MQTT_NOSTATE);
- /* FALLTHROUGH */
+ FALLTHROUGH();
case MQTT_REMAINING_LENGTH:
do {
result = Curl_read(data, sockfd, (char *)&byte, 1, &nread);
many callbacks and protocols work differently, we could potentially do
this more fine-grained in the future. */
premature = TRUE;
+ FALLTHROUGH();
default:
break;
}
/* case C passes through, not a match */
break;
case TYPE_IPV4:
- /* FALLTHROUGH */
case TYPE_IPV6: {
const char *check = token;
char *slash;
switch(code) {
case LDAP_SIZELIMIT_EXCEEDED:
infof(data, "Too many authentication mechanisms\n");
- /* FALLTHROUGH */
+ FALLTHROUGH();
case LDAP_SUCCESS:
case LDAP_NO_RESULTS_RETURNED:
if(Curl_sasl_can_authenticate(&li->sasl, data))
result = oldap_perform_bind(data, OLDAP_BIND);
break;
}
- /* FALLTHROUGH */
+ FALLTHROUGH();
case OLDAP_TLS:
result = oldap_ssl_connect(data, OLDAP_TLS);
if(result && data->set.use_ssl != CURLUSESSL_TRY)
switch(code) {
case LDAP_SIZELIMIT_EXCEEDED:
infof(data, "There are more than %d entries", lr->nument);
- /* FALLTHROUGH */
+ FALLTHROUGH();
case LDAP_SUCCESS:
data->req.size = data->req.bytecount;
break;
*/
CURLcode Curl_pp_sendf(struct Curl_easy *data,
struct pingpong *pp,
- const char *fmt, ...);
+ const char *fmt, ...) CURL_PRINTF(3, 4);
/***********************************************************************
*
CURLcode Curl_pp_vsendf(struct Curl_easy *data,
struct pingpong *pp,
const char *fmt,
- va_list args);
+ va_list args) CURL_PRINTF(3, 0);
/*
* Curl_pp_readresp()
break;
case SMTP_QUIT:
- /* fallthrough, just stop! */
default:
/* internal error */
smtp_state(data, SMTP_STOP);
return CURLPX_OK;
}
}
- /* FALLTHROUGH */
+ FALLTHROUGH();
+ case CONNECT_RESOLVED:
CONNECT_RESOLVED:
- case CONNECT_RESOLVED: {
+ {
struct Curl_addrinfo *hp = NULL;
/*
* We cannot use 'hostent' as a struct that Curl_resolv() returns. It
if(!hp)
return CURLPX_RESOLVE_HOST;
}
- /* FALLTHROUGH */
-CONNECT_REQ_INIT:
+ FALLTHROUGH();
case CONNECT_REQ_INIT:
+CONNECT_REQ_INIT:
/*
* This is currently not supporting "Identification Protocol (RFC1413)".
*/
sx->outstanding = packetsize;
sxstate(sx, data, CONNECT_REQ_SENDING);
}
- /* FALLTHROUGH */
+ FALLTHROUGH();
case CONNECT_REQ_SENDING:
/* Send request */
presult = socks_state_send(cf, sx, data, CURLPX_SEND_CONNECT,
sx->outp = socksreq;
sxstate(sx, data, CONNECT_SOCKS_READ);
- /* FALLTHROUGH */
+ FALLTHROUGH();
case CONNECT_SOCKS_READ:
/* Receive response */
presult = socks_state_recv(cf, sx, data, CURLPX_RECV_CONNECT,
/* remain in sending state */
return CURLPX_OK;
}
- /* FALLTHROUGH */
-CONNECT_SOCKS_READ_INIT:
+ FALLTHROUGH();
case CONNECT_SOCKS_READ_INIT:
+CONNECT_SOCKS_READ_INIT:
sx->outstanding = 2; /* expect two bytes */
sx->outp = socksreq; /* store it here */
- /* FALLTHROUGH */
+ FALLTHROUGH();
case CONNECT_SOCKS_READ:
presult = socks_state_recv(cf, sx, data, CURLPX_RECV_CONNECT,
"initial SOCKS5 response");
sx->outstanding = len;
sx->outp = socksreq;
}
- /* FALLTHROUGH */
+ FALLTHROUGH();
case CONNECT_AUTH_SEND:
presult = socks_state_send(cf, sx, data, CURLPX_SEND_AUTH,
"SOCKS5 sub-negotiation request");
sx->outp = socksreq;
sx->outstanding = 2;
sxstate(sx, data, CONNECT_AUTH_READ);
- /* FALLTHROUGH */
+ FALLTHROUGH();
case CONNECT_AUTH_READ:
presult = socks_state_recv(cf, sx, data, CURLPX_RECV_AUTH,
"SOCKS5 sub-negotiation response");
/* Everything is good so far, user was authenticated! */
sxstate(sx, data, CONNECT_REQ_INIT);
- /* FALLTHROUGH */
-CONNECT_REQ_INIT:
+ FALLTHROUGH();
case CONNECT_REQ_INIT:
+CONNECT_REQ_INIT:
if(socks5_resolve_local) {
enum resolve_t rc = Curl_resolv(data, sx->hostname, sx->remote_port,
TRUE, &dns);
return CURLPX_OK;
}
}
- /* FALLTHROUGH */
+ FALLTHROUGH();
+ case CONNECT_RESOLVED:
CONNECT_RESOLVED:
- case CONNECT_RESOLVED: {
+ {
char dest[MAX_IPADR_LEN]; /* printable address */
struct Curl_addrinfo *hp = NULL;
if(dns)
infof(data, "SOCKS5 connect to %s:%d (remotely resolved)",
sx->hostname, sx->remote_port);
}
- /* FALLTHROUGH */
+ FALLTHROUGH();
-CONNECT_REQ_SEND:
case CONNECT_REQ_SEND:
+CONNECT_REQ_SEND:
/* PORT MSB */
socksreq[len++] = (unsigned char)((sx->remote_port >> 8) & 0xff);
/* PORT LSB */
sx->outp = socksreq;
sx->outstanding = len;
sxstate(sx, data, CONNECT_REQ_SENDING);
- /* FALLTHROUGH */
+ FALLTHROUGH();
case CONNECT_REQ_SENDING:
presult = socks_state_send(cf, sx, data, CURLPX_SEND_REQUEST,
"SOCKS5 connect request");
sx->outstanding = 10; /* minimum packet size is 10 */
sx->outp = socksreq;
sxstate(sx, data, CONNECT_REQ_READ);
- /* FALLTHROUGH */
+ FALLTHROUGH();
case CONNECT_REQ_READ:
presult = socks_state_recv(cf, sx, data, CURLPX_RECV_REQACK,
"SOCKS5 connect request ack");
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
}
#endif
- /* FALLTHROUGH */
+ FALLTHROUGH();
case CONNECT_REQ_READ_MORE:
presult = socks_state_recv(cf, sx, data, CURLPX_RECV_ADDRESS,
"SOCKS5 connect request address");
failf(data, "Failed to determine user name.");
return CURLE_COULDNT_CONNECT;
}
- infof(data, "SOCKS5 server authenticated user %s with GSS-API.",
- names.sUserName);
- s_pSecFn->FreeContextBuffer(names.sUserName);
+ else {
+#ifndef CURL_DISABLE_VERBOSE_STRINGS
+ char *user_utf8 = curlx_convert_tchar_to_UTF8(names.sUserName);
+ infof(data, "SOCKS5 server authenticated user %s with GSS-API.",
+ (user_utf8 ? user_utf8 : "(unknown)"));
+ curlx_unicodefree(user_utf8);
+#endif
+ s_pSecFn->FreeContextBuffer(names.sUserName);
+ }
/* Do encryption */
socksreq[0] = 1; /* GSS-API subnegotiation version */
case 0: /* timeout */
pfd[0].revents = 0;
pfd[1].revents = 0;
- /* FALLTHROUGH */
+ FALLTHROUGH();
default: /* read! */
if(pfd[0].revents & POLLIN) {
/* read data from network */
Curl_dyn_reset(host);
result = Curl_dyn_addf(host, "%u.%u.%u.%u",
- parts[0] >> 24, (parts[0] >> 16) & 0xff,
- (parts[0] >> 8) & 0xff, parts[0] & 0xff);
+ (unsigned int)(parts[0] >> 24),
+ (unsigned int)((parts[0] >> 16) & 0xff),
+ (unsigned int)((parts[0] >> 8) & 0xff),
+ (unsigned int)(parts[0] & 0xff));
break;
case 1: /* a.b -- 8.24 bits */
if((parts[0] > 0xff) || (parts[1] > 0xffffff))
return HOST_NAME;
Curl_dyn_reset(host);
result = Curl_dyn_addf(host, "%u.%u.%u.%u",
- parts[0], (parts[1] >> 16) & 0xff,
- (parts[1] >> 8) & 0xff, parts[1] & 0xff);
+ (unsigned int)(parts[0]),
+ (unsigned int)((parts[1] >> 16) & 0xff),
+ (unsigned int)((parts[1] >> 8) & 0xff),
+ (unsigned int)(parts[1] & 0xff));
break;
case 2: /* a.b.c -- 8.8.16 bits */
if((parts[0] > 0xff) || (parts[1] > 0xff) || (parts[2] > 0xffff))
return HOST_NAME;
Curl_dyn_reset(host);
result = Curl_dyn_addf(host, "%u.%u.%u.%u",
- parts[0], parts[1], (parts[2] >> 8) & 0xff,
- parts[2] & 0xff);
+ (unsigned int)(parts[0]),
+ (unsigned int)(parts[1]),
+ (unsigned int)((parts[2] >> 8) & 0xff),
+ (unsigned int)(parts[2] & 0xff));
break;
case 3: /* a.b.c.d -- 8.8.8.8 bits */
if((parts[0] > 0xff) || (parts[1] > 0xff) || (parts[2] > 0xff) ||
return HOST_NAME;
Curl_dyn_reset(host);
result = Curl_dyn_addf(host, "%u.%u.%u.%u",
- parts[0], parts[1], parts[2], parts[3]);
+ (unsigned int)(parts[0]),
+ (unsigned int)(parts[1]),
+ (unsigned int)(parts[2]),
+ (unsigned int)(parts[3]));
break;
}
if(result)
&type_3_desc,
&attrs, &expiry);
if(status != SEC_E_OK) {
- infof(data, "NTLM handshake failure (type-3 message): Status=%x",
+ infof(data, "NTLM handshake failure (type-3 message): Status=%lx",
status);
if(status == SEC_E_INSUFFICIENT_MEMORY)
qctx->no_gso = TRUE;
return send_packet_no_gso(cf, data, qctx, pkt, pktlen, gsolen, psent);
}
- /* FALLTHROUGH */
+ FALLTHROUGH();
default:
failf(data, "sendmsg() returned %zd (errno %d)", sent, SOCKERRNO);
return CURLE_SEND_ERROR;
keymatch = CURLKHMATCH_OK;
break;
case SSH_KNOWN_HOSTS_OTHER:
- /* fallthrough */
case SSH_KNOWN_HOSTS_NOT_FOUND:
- /* fallthrough */
case SSH_KNOWN_HOSTS_UNKNOWN:
- /* fallthrough */
case SSH_KNOWN_HOSTS_ERROR:
keymatch = CURLKHMATCH_MISSING;
break;
keymatch = CURLKHMATCH_OK;
break;
case SSH_SERVER_FILE_NOT_FOUND:
- /* fallthrough */
case SSH_SERVER_NOT_KNOWN:
keymatch = CURLKHMATCH_MISSING;
break;
if(rc < 0)
return SSH_ERROR;
- /* FALLTHROUGH */
+ FALLTHROUGH();
case 1:
sshc->kbd_state = 1;
ssh_set_blocking(sshc->ssh_session, 0);
state(data, SSH_S_STARTUP);
- /* FALLTHROUGH */
+ FALLTHROUGH();
case SSH_S_STARTUP:
rc = ssh_connect(sshc->ssh_session);
state(data, SSH_HOSTKEY);
- /* FALLTHROUGH */
+ FALLTHROUGH();
case SSH_HOSTKEY:
rc = myssh_is_known(data);
}
state(data, SSH_AUTHLIST);
- /* FALLTHROUGH */
+ FALLTHROUGH();
case SSH_AUTHLIST:{
sshc->authed = FALSE;
break;
}
state(data, SSH_AUTH_PASS);
- /* FALLTHROUGH */
+ FALLTHROUGH();
case SSH_AUTH_PASS:
rc = ssh_userauth_password(sshc->ssh_session, NULL, conn->passwd);
break;
}
state(data, SSH_SFTP_REALPATH);
- /* FALLTHROUGH */
+ FALLTHROUGH();
case SSH_SFTP_REALPATH:
/*
* Get the "home" directory
sshc->readdir_longentry = NULL;
state(data, SSH_SFTP_READDIR_BOTTOM);
- /* FALLTHROUGH */
+ FALLTHROUGH();
case SSH_SFTP_READDIR_BOTTOM:
if(Curl_dyn_addn(&sshc->readdir_buf, "\n", 1))
result = CURLE_OUT_OF_MEMORY;
break;
}
state(data, SSH_SCP_DOWNLOAD);
- /* FALLTHROUGH */
+ FALLTHROUGH();
case SSH_SCP_DOWNLOAD:{
curl_off_t bytecount;
ssh_set_blocking(sshc->ssh_session, 0);
state(data, SSH_SESSION_DISCONNECT);
- /* FALLTHROUGH */
+ FALLTHROUGH();
case SSH_SESSION_DISCONNECT:
/* during weird times when we've been prematurely aborted, the channel
data->state.most_recent_ftp_entrypath = NULL;
state(data, SSH_SESSION_FREE);
- /* FALLTHROUGH */
+ FALLTHROUGH();
case SSH_SESSION_FREE:
if(sshc->ssh_session) {
ssh_free(sshc->ssh_session);
break;
case SSH_QUIT:
- /* fallthrough, just stop! */
default:
/* internal error */
sshc->nextstate = SSH_NO_STATE;
return -1;
}
- /* FALLTHROUGH */
+ FALLTHROUGH();
case 1:
conn->proto.sshc.sftp_recv_state = 1;
switch(rc) {
default: /* unknown return codes will equal reject */
- /* FALLTHROUGH */
case CURLKHSTAT_REJECT:
state(data, SSH_SESSION_FREE);
- /* FALLTHROUGH */
+ FALLTHROUGH();
case CURLKHSTAT_DEFER:
/* DEFER means bail out but keep the SSH_HOSTKEY state */
result = sshc->actualcode = CURLE_PEER_FAILED_VERIFICATION;
/* remove old host+key that doesn't match */
if(host)
libssh2_knownhost_del(sshc->kh, host);
- /* FALLTHROUGH */
+ FALLTHROUGH();
case CURLKHSTAT_FINE:
- /* FALLTHROUGH */
case CURLKHSTAT_FINE_ADD_TO_FILE:
/* proceed */
if(keycheck != LIBSSH2_KNOWNHOST_CHECK_MATCH) {
}
state(data, SSH_S_STARTUP);
- /* FALLTHROUGH */
+ FALLTHROUGH();
case SSH_S_STARTUP:
rc = session_startup(sshc->ssh_session, sock);
state(data, SSH_HOSTKEY);
- /* FALLTHROUGH */
+ FALLTHROUGH();
case SSH_HOSTKEY:
/*
* Before we authenticate we should check the hostkey's fingerprint
break;
case SSH_QUIT:
- /* fallthrough, just stop! */
default:
/* internal error */
sshc->nextstate = SSH_NO_STATE;
UI_set_result(ui, uis, password);
return 1;
}
+ FALLTHROUGH();
default:
break;
}
(UI_get_input_flags(uis) & UI_INPUT_FLAG_DEFAULT_PWD)) {
return 1;
}
+ FALLTHROUGH();
default:
break;
}
case SSL_FILETYPE_PEM:
if(cert_done)
break;
- /* FALLTHROUGH */
+ FALLTHROUGH();
case SSL_FILETYPE_ASN1:
cert_use_result = key_blob ?
SSL_CTX_use_PrivateKey_blob(ctx, key_blob, file_type, key_passwd) :
failf(data, OSSL_PACKAGE " was built without TLS 1.3 support");
return CURLE_NOT_BUILT_IN;
#endif
- /* FALLTHROUGH */
+ FALLTHROUGH();
case CURL_SSLVERSION_TLSv1_2:
#if OPENSSL_VERSION_NUMBER >= 0x1000100FL
*ctx_options |= SSL_OP_NO_TLSv1_1;
failf(data, OSSL_PACKAGE " was built without TLS 1.2 support");
return CURLE_NOT_BUILT_IN;
#endif
- /* FALLTHROUGH */
+ FALLTHROUGH();
case CURL_SSLVERSION_TLSv1_1:
#if OPENSSL_VERSION_NUMBER >= 0x1000100FL
*ctx_options |= SSL_OP_NO_TLSv1;
failf(data, OSSL_PACKAGE " was built without TLS 1.1 support");
return CURLE_NOT_BUILT_IN;
#endif
- /* FALLTHROUGH */
+ FALLTHROUGH();
case CURL_SSLVERSION_TLSv1_0:
case CURL_SSLVERSION_TLSv1:
break;
#if OPENSSL_VERSION_NUMBER >= 0x1000100FL
*ctx_options |= SSL_OP_NO_TLSv1_1;
#endif
- /* FALLTHROUGH */
+ FALLTHROUGH();
case CURL_SSLVERSION_MAX_TLSv1_1:
#if OPENSSL_VERSION_NUMBER >= 0x1000100FL
*ctx_options |= SSL_OP_NO_TLSv1_2;
#endif
- /* FALLTHROUGH */
+ FALLTHROUGH();
case CURL_SSLVERSION_MAX_TLSv1_2:
#ifdef TLS1_3_VERSION
*ctx_options |= SSL_OP_NO_TLSv1_3;
size_t errorlen;
rustls_error(rresult, errorbuf, sizeof(errorbuf), &errorlen);
failf(data, "rustls_connection_process_new_packets: %.*s",
- errorlen, errorbuf);
+ (int)errorlen, errorbuf);
*err = map_error(rresult);
return -1;
}
char errorbuf[255];
size_t errorlen;
rustls_error(rresult, errorbuf, sizeof(errorbuf), &errorlen);
- failf(data, "rustls_connection_read: %.*s", errorlen, errorbuf);
+ failf(data, "rustls_connection_read: %.*s", (int)errorlen, errorbuf);
*err = CURLE_READ_ERROR;
nread = -1;
goto out;
&plainwritten);
if(rresult != RUSTLS_RESULT_OK) {
rustls_error(rresult, errorbuf, sizeof(errorbuf), &errorlen);
- failf(data, "rustls_connection_write: %.*s", errorlen, errorbuf);
+ failf(data, "rustls_connection_write: %.*s", (int)errorlen, errorbuf);
*err = CURLE_WRITE_ERROR;
return -1;
}
}
if(result != RUSTLS_RESULT_OK) {
rustls_error(result, errorbuf, sizeof(errorbuf), &errorlen);
- failf(data, "rustls_client_connection_new: %.*s", errorlen, errorbuf);
+ failf(data, "rustls_client_connection_new: %.*s", (int)errorlen, errorbuf);
return CURLE_COULDNT_CONNECT;
}
rustls_connection_set_userdata(rconn, backend);
return CURLE_SSL_CONNECT_ERROR;
}
if(blocking && 0 == what) {
- failf(data, "rustls connection timeout after %d ms",
- socket_check_timeout);
+ failf(data, "rustls connection timeout after %"
+ CURL_FORMAT_TIMEDIFF_T " ms", socket_check_timeout);
return CURLE_OPERATION_TIMEDOUT;
}
if(0 == what) {
cert_showfilename_error);
else
failf(data, "schannel: Failed to import cert file %s, "
- "last error is 0x%x",
+ "last error is 0x%lx",
cert_showfilename_error, errorcode);
return CURLE_SSL_CERTPROBLEM;
}
if(!client_certs[0]) {
failf(data, "schannel: Failed to get certificate from file %s"
- ", last error is 0x%x",
+ ", last error is 0x%lx",
cert_showfilename_error, GetLastError());
CertCloseStore(cert_store, 0);
return CURLE_SSL_CERTPROBLEM;
CERT_STORE_OPEN_EXISTING_FLAG | cert_store_name,
cert_store_path);
if(!cert_store) {
- failf(data, "schannel: Failed to open cert store %x %s, "
- "last error is 0x%x",
- cert_store_name, cert_store_path, GetLastError());
+ char *path_utf8 =
+ curlx_convert_tchar_to_UTF8(cert_store_path);
+ failf(data, "schannel: Failed to open cert store %lx %s, "
+ "last error is 0x%lx",
+ cert_store_name,
+ (path_utf8 ? path_utf8 : "(unknown)"),
+ GetLastError());
free(cert_store_path);
+ curlx_unicodefree(path_utf8);
curlx_unicodefree(cert_path);
return CURLE_SSL_CERTPROBLEM;
}
/* Sanity check that the cert_context object is the right type */
if(CERT_QUERY_CONTENT_CERT != actual_content_type) {
failf(data,
- "schannel: unexpected content type '%d' when extracting "
+ "schannel: unexpected content type '%lu' when extracting "
"certificate from CA file '%s'",
actual_content_type, ca_file_text);
result = CURLE_SSL_CACERT_BADFILE;
failf(data, "schannel: CertGetCertificateChain trust error"
" CERT_TRUST_REVOCATION_STATUS_UNKNOWN");
else
- failf(data, "schannel: CertGetCertificateChain error mask: 0x%08x",
+ failf(data, "schannel: CertGetCertificateChain error mask: 0x%08lx",
dwTrustErrorMask);
result = CURLE_PEER_FAILED_VERIFICATION;
}
*curlcode = CURLE_OK;
return 0;
case SSL_ERROR_NONE:
- /* FALLTHROUGH */
case SSL_ERROR_WANT_READ:
- /* FALLTHROUGH */
case SSL_ERROR_WANT_WRITE:
/* there's data pending, re-invoke wolfSSL_read() */
CURL_TRC_CF(data, cf, "wolfssl_recv(len=%zu) -> AGAIN", blen);
case 4:
wc = (wc << 8) | *(const unsigned char *) from++;
wc = (wc << 8) | *(const unsigned char *) from++;
- /* FALLTHROUGH */
+ FALLTHROUGH();
case 2:
wc = (wc << 8) | *(const unsigned char *) from++;
- /* FALLTHROUGH */
+ FALLTHROUGH();
default: /* case 1: */
wc = (wc << 8) | *(const unsigned char *) from++;
}
break;
case 2:
sec1 = fracp[-2];
- /* FALLTHROUGH */
+ FALLTHROUGH();
case 1:
sec2 = fracp[-1];
break;
switch(tzp - sec) {
case 0:
sec = "00";
+ FALLTHROUGH();
case 2:
break;
default:
*/
const size_t len = ((pubkey->end - pubkey->beg - 2) * 4);
if(!certnum)
- infof(data, " ECC Public Key (%lu bits)", len);
+ infof(data, " ECC Public Key (%zu bits)", len);
if(data->set.ssl.certinfo) {
char q[sizeof(len) * 8 / 3 + 1];
(void)msnprintf(q, sizeof(q), "%zu", len);
if(len > 32)
elem.beg = q; /* Strip leading zero bytes. */
if(!certnum)
- infof(data, " RSA Public Key (%lu bits)", len);
+ infof(data, " RSA Public Key (%zu bits)", len);
if(data->set.ssl.certinfo) {
char r[sizeof(len) * 8 / 3 + 1];
msnprintf(r, sizeof(r), "%zu", len);
case WS_DEC_INIT:
ws_dec_reset(dec);
dec->state = WS_DEC_HEAD;
- /* FALLTHROUGH */
+ FALLTHROUGH();
case WS_DEC_HEAD:
result = ws_dec_read_head(dec, data, inraw);
if(result) {
dec->state = WS_DEC_INIT;
break;
}
- /* FALLTHROUGH */
+ FALLTHROUGH();
case WS_DEC_PAYLOAD:
result = ws_dec_pass_payload(dec, data, inraw, write_payload, write_ctx);
ws_dec_info(dec, data, "passing");
dnl Only clang 2.9 or later
if test "$compiler_num" -ge "209"; then
tmp_CFLAGS="$tmp_CFLAGS -Wno-sign-conversion"
+ # CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sign-conversion]) # FIXME
+ # tmp_CFLAGS="$tmp_CFLAGS -Wno-error=sign-conversion" # FIXME
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shift-sign-overflow])
# CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [padded]) # Not used because we cannot change public structs
fi
dnl Only clang 3.0 or later
if test "$compiler_num" -ge "300"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [language-extension-token])
+ tmp_CFLAGS="$tmp_CFLAGS -Wformat=2"
fi
#
dnl Only clang 3.2 or later
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [assign-enum])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [extra-semi-stmt])
fi
+ dnl clang 10 or later
+ if test "$compiler_num" -ge "1000"; then
+ tmp_CFLAGS="$tmp_CFLAGS -Wimplicit-fallthrough" # we have silencing markup for clang 10.0 and above only
+ fi
fi
dnl Disable pointer to bool conversion warnings since they cause
dnl lib/securetransp.c cause several warnings for checks we want.
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [type-limits old-style-declaration])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-parameter-type empty-body])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [clobbered ignored-qualifiers])
- CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [conversion])
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [conversion trampolines])
tmp_CFLAGS="$tmp_CFLAGS -Wno-sign-conversion"
+ # CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sign-conversion]) # FIXME
+ # tmp_CFLAGS="$tmp_CFLAGS -Wno-error=sign-conversion" # FIXME
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [vla])
dnl required for -Warray-bounds, included in -Wall
tmp_CFLAGS="$tmp_CFLAGS -ftree-vrp"
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [alloc-zero])
tmp_CFLAGS="$tmp_CFLAGS -Wformat-overflow=2"
tmp_CFLAGS="$tmp_CFLAGS -Wformat-truncation=2"
- if test "$compiler_num" -lt "1200"; then
- dnl gcc 12 doesn't acknowledge our comment markups
- tmp_CFLAGS="$tmp_CFLAGS -Wimplicit-fallthrough=4"
- fi
+ tmp_CFLAGS="$tmp_CFLAGS -Wimplicit-fallthrough"
fi
#
dnl Only gcc 10 or later
result = curl_easy_setopt(easy, tag, &blob);
break;
}
- /* FALLTHROUGH */
+ FALLTHROUGH();
case CURLOPT_ERRORBUFFER: /* This is an output buffer. */
result = Curl_vsetopt(easy, tag, arg);
break;
switch(type) {
case CURLINFO_TEXT:
fprintf(output, "%s%s== Info: %.*s", timebuf, idsbuf, (int)size, data);
- /* FALLTHROUGH */
+ FALLTHROUGH();
default: /* in case a new one is introduced to shock us */
return 0;
memset(line, '#', num);
line[num] = '\0';
msnprintf(format, sizeof(format), "\r%%-%ds %%5.1f%%%%", barwidth);
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
+#endif
fprintf(bar->out, format, line, percent);
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
}
fflush(bar->out);
bar->prev = point;
char *bufp;
va_list ap;
va_start(ap, fmt);
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
+#endif
bufp = curlx_mvaprintf(fmt, ap);
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
va_end(ap);
if(!bufp) {
ret = CURLE_OUT_OF_MEMORY;
extern CURLcode easysrc_init(void);
extern CURLcode easysrc_add(struct slist_wc **plist, const char *bupf);
extern CURLcode easysrc_addf(struct slist_wc **plist,
- const char *fmt, ...);
+ const char *fmt, ...) CURL_PRINTF(2, 3);
extern CURLcode easysrc_perform(void);
extern CURLcode easysrc_cleanup(void);
case TOOLMIME_STDIN:
if(!filename)
filename = "-";
- /* FALLTHROUGH */
+ FALLTHROUGH();
case TOOLMIME_STDINDATA:
ret = curl_mime_data_cb(part, m->size,
(curl_read_callback) tool_mime_stdin_read,
config->file_clobber_mode = toggle ? CLOBBER_ALWAYS : CLOBBER_NEVER;
break;
}
- /* FALLTHROUGH */
+ FALLTHROUGH();
case 'o': /* --output */
/* output file */
{
switch(*nextarg) {
case '+':
nextarg++;
- /* FALLTHROUGH */
+ FALLTHROUGH();
default:
/* If-Modified-Since: (section 14.28 in RFC2068) */
config->timecond = CURL_TIMECOND_IFMODSINCE;
curl_free(pathbuffer);
curl_url_cleanup(gatewayurl);
{
- const char *msg = NULL;
switch(result) {
case CURLE_URL_MALFORMAT:
- msg = "malformed target URL";
+ helpf(tool_stderr, "malformed target URL");
break;
case CURLE_FILE_COULDNT_READ_FILE:
- msg = "IPFS automatic gateway detection failed";
+ helpf(tool_stderr, "IPFS automatic gateway detection failed");
break;
case CURLE_BAD_FUNCTION_ARGUMENT:
- msg = "--ipfs-gateway was given a malformed URL";
+ helpf(tool_stderr, "--ipfs-gateway was given a malformed URL");
break;
default:
break;
}
- if(msg)
- helpf(tool_stderr, msg);
}
return result;
}
char *ptr;
char *print_buffer;
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
+#endif
print_buffer = curlx_mvaprintf(fmt, ap);
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
if(!print_buffer)
return;
len = strlen(print_buffer);
va_start(ap, fmt);
DEBUGASSERT(!strchr(fmt, '\n'));
fputs("curl: ", errors); /* prefix it */
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
+#endif
vfprintf(errors, fmt, ap);
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
va_end(ap);
fputs("\n", errors); /* newline it */
}
#include "tool_setup.h"
#include "tool_cfgable.h"
-void warnf(struct GlobalConfig *config, const char *fmt, ...);
-void notef(struct GlobalConfig *config, const char *fmt, ...);
-void helpf(FILE *errors, const char *fmt, ...);
-void errorf(struct GlobalConfig *config, const char *fmt, ...);
+void warnf(struct GlobalConfig *config, const char *fmt, ...)
+ CURL_PRINTF(2, 3);
+void notef(struct GlobalConfig *config, const char *fmt, ...)
+ CURL_PRINTF(2, 3);
+void helpf(FILE *errors, const char *fmt, ...)
+ CURL_PRINTF(2, 3);
+void errorf(struct GlobalConfig *config, const char *fmt, ...)
+ CURL_PRINTF(2, 3);
#endif /* HEADER_CURL_TOOL_MSGS_H */
break;
case set:
protoset[0] = NULL;
- /* FALLTHROUGH */
+ FALLTHROUGH();
case allow:
protoset_set(protoset, p);
break;
format = "\\%03o";
}
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
+#endif
result = curlx_dyn_addf(&escaped, format,
(unsigned int) *(unsigned char *) s);
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
}
}
}
case TOOLMIME_STDIN:
if(!filename)
filename = "-";
- /* FALLTHROUGH */
+ FALLTHROUGH();
case TOOLMIME_STDINDATA:
/* Can only be reading stdin in the current context. */
CODE1("curl_mime_data_cb(part%d, -1, (curl_read_callback) fread, \\",
if(multiply(amount, pat->content.Set.size + 1))
return GLOBERROR("range overflow", 0, CURLE_URL_MALFORMAT);
- /* FALLTHROUGH */
+ FALLTHROUGH();
case ',':
*buf = '\0';
++pattern;
++(*posp);
}
- /* FALLTHROUGH */
+ FALLTHROUGH();
default:
*buf++ = *pattern++; /* copy character to set element */
++(*posp);
switch(type) {
case CURLINFO_TEXT:
fprintf(stderr, "== Info: %s", data);
- /* FALLTHROUGH */
- default: /* in case a new one is introduced to shock us */
return 0;
-
case CURLINFO_HEADER_OUT:
text = "=> Send header";
break;
return 0;
text = "<= Recv data";
break;
+ default: /* in case a new one is introduced to shock us */
+ return 0;
}
fprintf(stderr, "%s, %lu bytes (0x%lx)\n",
switch(type) {
case CURLINFO_TEXT:
fprintf(stderr, "== Info: %s", data);
- /* FALLTHROUGH */
- default: /* in case a new one is introduced to shock us */
return 0;
-
case CURLINFO_HEADER_OUT:
text = "=> Send header";
break;
case CURLINFO_SSL_DATA_IN:
text = "<= Recv SSL data";
break;
+ default: /* in case a new one is introduced to shock us */
+ return 0;
}
dump(text, (unsigned char *)data, size, 1);
for(i = 0; i < 7; i++) {
char *partp;
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
+#endif
msnprintf(total, sizeof(total),
url,
(i == 0)? &bigpart[1] : smallpart,
(i == 4)? &bigpart[1] : smallpart,
(i == 5)? &bigpart[1] : smallpart,
(i == 6)? &bigpart[1] : smallpart);
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
rc = curl_url_set(urlp, CURLUPART_URL, total, CURLU_NON_SUPPORT_SCHEME);
if((!i && (rc != CURLUE_BAD_SCHEME)) ||
(i && rc)) {
th = _beginthreadex(NULL, 0, run_thread, &results[i], 0, NULL);
#endif
if(!th) {
- fprintf(stderr, "%s:%d Couldn't create thread, errno %d\n",
+ fprintf(stderr, "%s:%d Couldn't create thread, errno %lu\n",
__FILE__, __LINE__, GetLastError());
tid_count = i;
test_failure = -1;
time_t out = curl_getdate(dates[i].input, NULL);
if(out != dates[i].output) {
printf("WRONGLY %s => %ld (instead of %ld)\n",
- dates[i].input, out, dates[i].output);
+ dates[i].input, (long)out, (long)dates[i].output);
error++;
}
}
return ret;
}
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
+#endif
+
static int rlimit(int keep_open)
{
int nitems, i;
return 0;
}
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
int test(char *URL)
{
CURLcode res;
return ret;
}
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
+#endif
+
static int rlimit(int keep_open)
{
int *tmpfd;
return 0;
}
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
int test(char *URL)
{
CURLcode res;
switch(type) {
case CURLINFO_TEXT:
fprintf(stderr, "== Info: %s", (char *)data);
- /* FALLTHROUGH */
- default: /* in case a new one is introduced to shock us */
return 0;
-
case CURLINFO_HEADER_OUT:
text = "=> Send header";
break;
case CURLINFO_SSL_DATA_IN:
text = "<= Recv SSL data";
break;
+ default: /* in case a new one is introduced to shock us */
+ return 0;
}
dump(text, stderr, (unsigned char *)data, size, config->trace_ascii);
rc = curl_msnprintf(buf, sizeof(buf), "%d, %.*1$d", 500, 1);
if(rc != sizeof(buf) - 1) {
- printf("curl_mprintf() returned %d and not %d!\n", rc,
+ printf("curl_mprintf() returned %d and not %zu!\n", rc,
sizeof(buf) - 1);
errors++;
}
switch(type) {
case CURLINFO_TEXT:
fprintf(stderr, "%s== Info: %s", timestr, (char *)data);
- /* FALLTHROUGH */
- default: /* in case a new one is introduced to shock us */
return 0;
-
case CURLINFO_HEADER_OUT:
text = "=> Send header";
break;
case CURLINFO_SSL_DATA_IN:
text = "<= Recv SSL data";
break;
+ default: /* in case a new one is introduced to shock us */
+ return 0;
}
libtest_debug_dump(timebuf, text, stderr, data, size, trace_cfg->nohex);
rc = swrite(fd, (char *)packet, sizeof(packet));
if(rc > 0) {
- logmsg("WROTE %d bytes [CONNACK]", rc);
+ logmsg("WROTE %zd bytes [CONNACK]", rc);
loghex(packet, rc);
logprotocol(FROM_SERVER, "CONNACK", 2, dump, packet, sizeof(packet));
}
rc = swrite(fd, (char *)packet, sizeof(packet));
if(rc == sizeof(packet)) {
- logmsg("WROTE %d bytes [SUBACK]", rc);
+ logmsg("WROTE %zd bytes [SUBACK]", rc);
loghex(packet, rc);
logprotocol(FROM_SERVER, "SUBACK", 3, dump, packet, rc);
return 0;
rc = swrite(fd, (char *)packet, sizeof(packet));
if(rc == sizeof(packet)) {
- logmsg("WROTE %d bytes [PUBACK]", rc);
+ logmsg("WROTE %zd bytes [PUBACK]", rc);
loghex(packet, rc);
logprotocol(FROM_SERVER, dump, packet, rc);
return 0;
};
ssize_t rc = swrite(fd, (char *)packet, sizeof(packet));
if(rc == sizeof(packet)) {
- logmsg("WROTE %d bytes [DISCONNECT]", rc);
+ logmsg("WROTE %zd bytes [DISCONNECT]", rc);
loghex(packet, rc);
logprotocol(FROM_SERVER, "DISCONNECT", 0, dump, packet, rc);
return 0;
rc = swrite(fd, (char *)packet, sendamount);
if(rc > 0) {
- logmsg("WROTE %d bytes [PUBLISH]", rc);
+ logmsg("WROTE %zd bytes [PUBLISH]", rc);
loghex(packet, rc);
logprotocol(FROM_SERVER, "PUBLISH", remaininglength, dump, packet, rc);
}
ssize_t rc = sread(fd, (char *)buffer, 2);
int i;
if(rc < 2) {
- logmsg("READ %d bytes [SHORT!]", rc);
+ logmsg("READ %zd bytes [SHORT!]", rc);
return 1; /* fail */
}
- logmsg("READ %d bytes", rc);
+ logmsg("READ %zd bytes", rc);
loghex(buffer, rc);
*bytep = buffer[0];
}
}
*remaining_lengthp = decode_length(&buffer[1], i, remaining_length_bytesp);
- logmsg("Remaining Length: %ld [%d bytes]", (long) *remaining_lengthp,
+ logmsg("Remaining Length: %zu [%zu bytes]", *remaining_lengthp,
*remaining_length_bytesp);
return 0;
}
buff_size = remaining_length;
buffer = realloc(buffer, buff_size);
if(!buffer) {
- logmsg("Failed realloc of size %lu", buff_size);
+ logmsg("Failed realloc of size %zu", buff_size);
goto end;
}
}
/* reading variable header and payload into buffer */
rc = sread(fd, (char *)buffer, remaining_length);
if(rc > 0) {
- logmsg("READ %d bytes", rc);
+ logmsg("READ %zd bytes", rc);
loghex(buffer, rc);
}
}
/* check the length of the payload */
if((ssize_t)payload_len != (rc - 12)) {
- logmsg("Payload length mismatch, expected %x got %x",
+ logmsg("Payload length mismatch, expected %zx got %zx",
rc - 12, payload_len);
goto end;
}
/* two bytes topic length */
topic_len = (buffer[2] << 8) | buffer[3];
if(topic_len != (remaining_length - 5)) {
- logmsg("Wrong topic length, got %d expected %d",
+ logmsg("Wrong topic length, got %u expected %zu",
topic_len, remaining_length - 5);
goto end;
}
dump, buffer, rc);
topiclen = (buffer[1 + bytes] << 8) | buffer[2 + bytes];
- logmsg("Got %d bytes topic", topiclen);
+ logmsg("Got %zu bytes topic", topiclen);
/* TODO: verify topiclen */
#ifdef QOS
/* get the request */
rc = sread(fd, (char *)&buffer[0], 2);
- logmsg("READ %d bytes [DISCONNECT]", rc);
+ logmsg("READ %zd bytes [DISCONNECT]", rc);
loghex(buffer, rc);
logprotocol(FROM_CLIENT, "DISCONNECT", 0, dump, buffer, rc);
goto end;
curl_socket_t newfd = accept(sockfd, NULL, NULL);
if(CURL_SOCKET_BAD == newfd) {
error = SOCKERRNO;
- logmsg("accept(%d, NULL, NULL) failed with error: (%d) %s",
- sockfd, error, sstrerror(error));
+ logmsg("accept(%" CURL_FORMAT_SOCKET_T ", NULL, NULL) "
+ "failed with error: (%d) %s", sockfd, error, sstrerror(error));
}
else {
- logmsg("====> Client connect, fd %d. Read config from %s",
- newfd, configfile);
+ logmsg("====> Client connect, fd %" CURL_FORMAT_SOCKET_T ". "
+ "Read config from %s", newfd, configfile);
set_advisor_read_lock(loglockfile);
(void)mqttit(newfd); /* until done */
clear_advisor_read_lock(loglockfile);
rc = listen(sock, 5);
if(0 != rc) {
error = SOCKERRNO;
- logmsg("listen(%d, 5) failed with error: (%d) %s",
+ logmsg("listen(%" CURL_FORMAT_SOCKET_T ", 5) failed with error: (%d) %s",
sock, error, sstrerror(error));
sclose(sock);
return CURL_SOCKET_BAD;
continue;
}
else {
- logmsg("[select_ws_wait_thread] PeekNamedPipe len: %d", length);
+ logmsg("[select_ws_wait_thread] PeekNamedPipe len: %lu", length);
}
}
else {
/* if the pipe has NOT been closed, sleep and continue waiting */
ret = GetLastError();
if(ret != ERROR_BROKEN_PIPE) {
- logmsg("[select_ws_wait_thread] PeekNamedPipe error: %d", ret);
+ logmsg("[select_ws_wait_thread] PeekNamedPipe error: %lu", ret);
SleepEx(0, FALSE);
continue;
}
curl_socket_t newfd = accept(sockfd, NULL, NULL);
if(CURL_SOCKET_BAD == newfd) {
error = SOCKERRNO;
- logmsg("accept(%d, NULL, NULL) failed with error: (%d) %s",
- sockfd, error, sstrerror(error));
+ logmsg("accept(%" CURL_FORMAT_SOCKET_T ", NULL, NULL) "
+ "failed with error: (%d) %s", sockfd, error, sstrerror(error));
}
else {
logmsg("====> Client connect");
rc = listen(sock, 5);
if(0 != rc) {
error = SOCKERRNO;
- logmsg("listen(%d, 5) failed with error: (%d) %s",
+ logmsg("listen(%" CURL_FORMAT_SOCKET_T ", 5) failed with error: (%d) %s",
sock, error, sstrerror(error));
sclose(sock);
return CURL_SOCKET_BAD;
return CURL_SOCKET_BAD;
}
if(rc < 9) {
- logmsg("SOCKS4 connect message too short: %d", rc);
+ logmsg("SOCKS4 connect message too short: %zd", rc);
return CURL_SOCKET_BAD;
}
if(!config.port)
logmsg("Sending SOCKS4 response failed!");
return CURL_SOCKET_BAD;
}
- logmsg("Sent %d bytes", rc);
+ logmsg("Sent %zd bytes", rc);
loghex(response, rc);
if(cd == 90)
rc = recv(fd, (char *)buffer, sizeof(buffer), 0);
if(rc <= 0) {
- logmsg("SOCKS identifier message missing, recv returned %d", rc);
+ logmsg("SOCKS identifier message missing, recv returned %zd", rc);
return CURL_SOCKET_BAD;
}
- logmsg("READ %d bytes", rc);
+ logmsg("READ %zd bytes", rc);
loghex(buffer, rc);
if(buffer[SOCKS5_VERSION] == 4)
return socks4(fd, buffer, rc);
if(rc < 3) {
- logmsg("SOCKS5 identifier message too short: %d", rc);
+ logmsg("SOCKS5 identifier message too short: %zd", rc);
return CURL_SOCKET_BAD;
}
/* after NMETHODS follows that many bytes listing the methods the client
says it supports */
if(rc != (buffer[SOCKS5_NMETHODS] + 2)) {
- logmsg("Expected %d bytes, got %d", buffer[SOCKS5_NMETHODS] + 2, rc);
+ logmsg("Expected %d bytes, got %zd", buffer[SOCKS5_NMETHODS] + 2, rc);
return CURL_SOCKET_BAD;
}
logmsg("Incoming request deemed fine!");
logmsg("Sending response failed!");
return CURL_SOCKET_BAD;
}
- logmsg("Sent %d bytes", rc);
+ logmsg("Sent %zd bytes", rc);
loghex(response, rc);
/* expect the request or auth */
rc = recv(fd, (char *)buffer, sizeof(buffer), 0);
if(rc <= 0) {
- logmsg("SOCKS5 request or auth message missing, recv returned %d", rc);
+ logmsg("SOCKS5 request or auth message missing, recv returned %zd", rc);
return CURL_SOCKET_BAD;
}
- logmsg("READ %d bytes", rc);
+ logmsg("READ %zd bytes", rc);
loghex(buffer, rc);
if(config.responsemethod == 2) {
unsigned char plen;
bool login = TRUE;
if(rc < 5) {
- logmsg("Too short auth input: %d", rc);
+ logmsg("Too short auth input: %zd", rc);
return CURL_SOCKET_BAD;
}
if(buffer[SOCKS5_VERSION] != 1) {
}
ulen = buffer[SOCKS5_ULEN];
if(rc < 4 + ulen) {
- logmsg("Too short packet for username: %d", rc);
+ logmsg("Too short packet for username: %zd", rc);
return CURL_SOCKET_BAD;
}
plen = buffer[SOCKS5_ULEN + ulen + 1];
if(rc < 3 + ulen + plen) {
- logmsg("Too short packet for ulen %d plen %d: %d", ulen, plen, rc);
+ logmsg("Too short packet for ulen %d plen %d: %zd", ulen, plen, rc);
return CURL_SOCKET_BAD;
}
if((ulen != strlen(config.user)) ||
logmsg("Sending auth response failed!");
return CURL_SOCKET_BAD;
}
- logmsg("Sent %d bytes", rc);
+ logmsg("Sent %zd bytes", rc);
loghex(response, rc);
if(!login)
return CURL_SOCKET_BAD;
/* expect the request */
rc = recv(fd, (char *)buffer, sizeof(buffer), 0);
if(rc <= 0) {
- logmsg("SOCKS5 request message missing, recv returned %d", rc);
+ logmsg("SOCKS5 request message missing, recv returned %zd", rc);
return CURL_SOCKET_BAD;
}
- logmsg("READ %d bytes", rc);
+ logmsg("READ %zd bytes", rc);
loghex(buffer, rc);
}
if(rc < 6) {
- logmsg("Too short for request: %d", rc);
+ logmsg("Too short for request: %zd", rc);
return CURL_SOCKET_BAD;
}
return CURL_SOCKET_BAD;
}
if(rc < (4 + len + 2)) {
- logmsg("Request too short: %d, expected %d", rc, 4 + len + 2);
+ logmsg("Request too short: %zd, expected %d", rc, 4 + len + 2);
return CURL_SOCKET_BAD;
}
logmsg("Received ATYP %d", type);
logmsg("Sending connect response failed!");
return CURL_SOCKET_BAD;
}
- logmsg("Sent %d bytes", rc);
+ logmsg("Sent %zd bytes", rc);
loghex(response, rc);
if(!rep)
curl_socket_t newfd = accept(sockfd, NULL, NULL);
if(CURL_SOCKET_BAD == newfd) {
error = SOCKERRNO;
- logmsg("accept(%d, NULL, NULL) failed with error: (%d) %s",
+ logmsg("accept(%" CURL_FORMAT_SOCKET_T ", NULL, NULL) "
+ "failed with error: (%d) %s",
sockfd, error, sstrerror(error));
}
else {
curl_socket_t remotefd;
- logmsg("====> Client connect, fd %d. Read config from %s",
- newfd, configfile);
+ logmsg("====> Client connect, fd %" CURL_FORMAT_SOCKET_T ". "
+ "Read config from %s", newfd, configfile);
remotefd = sockit(newfd); /* SOCKS until done */
if(remotefd == CURL_SOCKET_BAD) {
logmsg("====> Client disconnect");
rc = listen(sock, 5);
if(0 != rc) {
error = SOCKERRNO;
- logmsg("listen(%d, 5) failed with error: (%d) %s",
+ logmsg("listen(%" CURL_FORMAT_SOCKET_T ", 5) failed with error: (%d) %s",
sock, error, sstrerror(error));
sclose(sock);
return CURL_SOCKET_BAD;
req->callcount++;
- logmsg("Process %d bytes request%s", req->offset,
+ logmsg("Process %zu bytes request%s", req->offset,
req->callcount > 1?" [CONTINUED]":"");
/* try to figure out the request characteristics as soon as possible, but
logmsg("request not complete yet");
return 0; /* not complete yet */
}
- logmsg("- request found to be complete (%d)", req->testno);
+ logmsg("- request found to be complete (%ld)", req->testno);
if(req->testno == DOCNUMBER_NOTHING) {
/* check for a Testno: header with the test case number */
char *testno = strstr(line, "\nTestno: ");
if(testno) {
req->testno = strtol(&testno[9], NULL, 10);
- logmsg("Found test number %d in Testno: header!", req->testno);
+ logmsg("Found test number %ld in Testno: header!", req->testno);
}
else {
logmsg("No Testno: header");
/* Negotiate iterations */
static long prev_testno = -1;
static long prev_partno = -1;
- logmsg("Negotiate: prev_testno: %d, prev_partno: %d",
- prev_testno, prev_partno);
+ logmsg("Negotiate: prev_testno: %ld, prev_partno: %ld",
+ prev_testno, prev_partno);
if(req->testno != prev_testno) {
prev_testno = req->testno;
prev_partno = req->partno;
int intervals = msecs_left / MAX_SLEEP_TIME_MS;
if(msecs_left%MAX_SLEEP_TIME_MS)
intervals++;
- logmsg("Pausing %d milliseconds after writing %d bytes",
- msecs_left, written);
+ logmsg("Pausing %d milliseconds after writing %zd bytes",
+ msecs_left, written);
while((intervals > 0) && !got_exit_signal) {
int sleep_time = msecs_left > MAX_SLEEP_TIME_MS ?
MAX_SLEEP_TIME_MS : msecs_left;
curl_socket_t msgsock;
do {
msgsock = accept_connection(sock);
- logmsg("accept_connection %d returned %d", sock, msgsock);
+ logmsg("accept_connection %" CURL_FORMAT_SOCKET_T
+ " returned %" CURL_FORMAT_SOCKET_T, sock, msgsock);
if(CURL_SOCKET_BAD == msgsock)
goto sws_cleanup;
if(req->delay)
if(!stream) {
int error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
- logmsg("Couldn't open test file for test : %d", testno);
+ logmsg("Couldn't open test file for test: %ld", testno);
return EACCESS;
}
else {
if(!FormatMessageA((FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS), NULL, err,
LANG_NEUTRAL, buf, (DWORD)buflen, NULL))
- msnprintf(buf, buflen, "Unknown error %lu (%#lx)", err, err);
+ msnprintf(buf, buflen, "Unknown error %d (%#x)", err, err);
return buf;
}
static BOOL WINAPI ctrl_event_handler(DWORD dwCtrlType)
{
int signum = 0;
- logmsg("ctrl_event_handler: %d", dwCtrlType);
+ logmsg("ctrl_event_handler: %lu", dwCtrlType);
switch(dwCtrlType) {
#ifdef SIGINT
case CTRL_C_EVENT: signum = SIGINT; break;
default: return FALSE;
}
if(signum) {
- logmsg("ctrl_event_handler: %d -> %d", dwCtrlType, signum);
+ logmsg("ctrl_event_handler: %lu -> %d", dwCtrlType, signum);
raise(signum);
}
return TRUE;
#include "server_setup.h"
char *data_to_hex(char *data, size_t len);
-void logmsg(const char *msg, ...);
+void logmsg(const char *msg, ...) CURL_PRINTF(1, 2);
long timediff(struct timeval newer, struct timeval older);
#define TEST_DATA_PATH "%s/data/test%ld"
* SPDX-License-Identifier: curl
*
***************************************************************************/
+#define CURL_NO_FMT_CHECKS
+
#include "curlcheck.h"
#include "urldata.h"
/* Variations of empty strings */
Curl_infof(data, "");
fail_unless(strlen(result) == 1, "Empty string");
-Curl_infof(data, "%s", NULL);
+Curl_infof(data, "%s", (char *)NULL);
fail_unless(verify(result, "(nil)") == 0, "Passing NULL as string");
/* A string just long enough to not be truncated */