mirror of
https://github.com/curl/curl.git
synced 2026-07-14 03:07:16 +03:00
build: fix some -Wsign-conversion/-Warith-conversion warnings
- enable `-Wsign-conversion` warnings, but also setting them to not raise errors. - fix `-Warith-conversion` warnings seen in CI. These are triggered by `-Wsign-converion` and causing errors unless explicitly silenced. It makes more sense to fix them, there just a few of them. - fix some `-Wsign-conversion` warnings. - hide `-Wsign-conversion` warnings with a `#pragma`. - add macro `CURL_WARN_SIGN_CONVERSION` to unhide them on a per-build basis. - update a CI job to unhide them with the above macro: https://github.com/curl/curl/actions/workflows/linux.yml -> OpenSSL -O3 Closes #12492
This commit is contained in:
parent
68d80a8f9b
commit
2dbe75bd7f
17 changed files with 56 additions and 42 deletions
|
|
@ -65,12 +65,16 @@ int select_wrapper(int nfds, fd_set *rd, fd_set *wr, fd_set *exc,
|
|||
|
||||
void wait_ms(int ms)
|
||||
{
|
||||
if(ms < 0)
|
||||
return;
|
||||
#ifdef USE_WINSOCK
|
||||
Sleep(ms);
|
||||
Sleep((DWORD)ms);
|
||||
#else
|
||||
struct timeval t;
|
||||
curlx_mstotv(&t, ms);
|
||||
select_wrapper(0, NULL, NULL, NULL, &t);
|
||||
{
|
||||
struct timeval t;
|
||||
curlx_mstotv(&t, ms);
|
||||
select_wrapper(0, NULL, NULL, NULL, &t);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1045,7 +1045,7 @@ static CURLUcode updateurl(CURLU *u, const char *cmd, unsigned int setflags)
|
|||
while(p) {
|
||||
char *e = strchr(p, ',');
|
||||
if(e) {
|
||||
size_t n = e-p;
|
||||
size_t n = (size_t)(e - p);
|
||||
char buf[80];
|
||||
char part[80];
|
||||
char value[80];
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ int test(char *URL)
|
|||
CURLcode res = CURLE_OK;
|
||||
struct curl_header *h;
|
||||
int count = 0;
|
||||
int origins;
|
||||
unsigned int origins;
|
||||
|
||||
global_init(CURL_GLOBAL_DEFAULT);
|
||||
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ struct timeval tutil_tvnow(void)
|
|||
*/
|
||||
struct timeval now;
|
||||
DWORD milliseconds = GetTickCount();
|
||||
now.tv_sec = milliseconds / 1000;
|
||||
now.tv_usec = (milliseconds % 1000) * 1000;
|
||||
now.tv_sec = (long)(milliseconds / 1000);
|
||||
now.tv_usec = (long)((milliseconds % 1000) * 1000);
|
||||
return now;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -569,7 +569,7 @@ static curl_socket_t mqttit(curl_socket_t fd)
|
|||
goto end;
|
||||
}
|
||||
/* ignore the connect flag byte and two keepalive bytes */
|
||||
payload_len = (buffer[10] << 8) | buffer[11];
|
||||
payload_len = (size_t)(buffer[10] << 8) | buffer[11];
|
||||
/* first part of the payload is the client ID */
|
||||
client_id_length = payload_len;
|
||||
|
||||
|
|
@ -579,14 +579,16 @@ static curl_socket_t mqttit(curl_socket_t fd)
|
|||
start_usr = client_id_offset + payload_len;
|
||||
if(usr_flag == (unsigned char)(conn_flags & usr_flag)) {
|
||||
logmsg("User flag is present in CONN flag");
|
||||
payload_len += (buffer[start_usr] << 8) | buffer[start_usr + 1];
|
||||
payload_len += (size_t)(buffer[start_usr] << 8) |
|
||||
buffer[start_usr + 1];
|
||||
payload_len += 2; /* MSB and LSB for user length */
|
||||
}
|
||||
|
||||
start_passwd = client_id_offset + payload_len;
|
||||
if(passwd_flag == (char)(conn_flags & passwd_flag)) {
|
||||
logmsg("Password flag is present in CONN flags");
|
||||
payload_len += (buffer[start_passwd] << 8) | buffer[start_passwd + 1];
|
||||
payload_len += (size_t)(buffer[start_passwd] << 8) |
|
||||
buffer[start_passwd + 1];
|
||||
payload_len += 2; /* MSB and LSB for password length */
|
||||
}
|
||||
|
||||
|
|
@ -631,7 +633,7 @@ static curl_socket_t mqttit(curl_socket_t fd)
|
|||
packet_id = (unsigned short)((buffer[0] << 8) | buffer[1]);
|
||||
|
||||
/* two bytes topic length */
|
||||
topic_len = (buffer[2] << 8) | buffer[3];
|
||||
topic_len = (size_t)(buffer[2] << 8) | buffer[3];
|
||||
if(topic_len != (remaining_length - 5)) {
|
||||
logmsg("Wrong topic length, got %u expected %zu",
|
||||
topic_len, remaining_length - 5);
|
||||
|
|
@ -676,7 +678,7 @@ static curl_socket_t mqttit(curl_socket_t fd)
|
|||
logprotocol(FROM_CLIENT, "PUBLISH", remaining_length,
|
||||
dump, buffer, rc);
|
||||
|
||||
topiclen = (buffer[1 + bytes] << 8) | buffer[2 + bytes];
|
||||
topiclen = (size_t)(buffer[1 + bytes] << 8) | buffer[2 + bytes];
|
||||
logmsg("Got %zu bytes topic", topiclen);
|
||||
/* TODO: verify topiclen */
|
||||
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ void logmsg(const char *msg, ...)
|
|||
static const char *win32_strerror(int err, char *buf, size_t buflen)
|
||||
{
|
||||
if(!FormatMessageA((FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS), NULL, err,
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS), NULL, (DWORD)err,
|
||||
LANG_NEUTRAL, buf, (DWORD)buflen, NULL))
|
||||
msnprintf(buf, buflen, "Unknown error %d (%#x)", err, err);
|
||||
return buf;
|
||||
|
|
@ -247,7 +247,7 @@ int wait_ms(int timeout_ms)
|
|||
#if defined(MSDOS)
|
||||
delay(timeout_ms);
|
||||
#elif defined(USE_WINSOCK)
|
||||
Sleep(timeout_ms);
|
||||
Sleep((DWORD)timeout_ms);
|
||||
#else
|
||||
pending_ms = timeout_ms;
|
||||
initial_tv = tvnow();
|
||||
|
|
|
|||
|
|
@ -368,7 +368,7 @@ UNITTEST_START
|
|||
happens */
|
||||
for(byte = 1 ; byte < 255; byte += 17) {
|
||||
for(i = 0; i < 45; i++) {
|
||||
char backup = cert[i];
|
||||
unsigned char backup = cert[i];
|
||||
cert[i] = (unsigned char) (byte & 0xff);
|
||||
(void) Curl_extract_certinfo(data, 0, beg, end);
|
||||
cert[i] = backup;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue