← Commit list

ac46392f44

Viktor Szakats
Viktor Szakats
2026-02-25
SUCCESS Duration: 639s

Subject

clang-tidy: enable `bugprone-signed-char-misuse`, fix fallouts

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

.clang-tidy.yml+1 -0
@@ -13,6 +13,7 @@ Checks:
- -clang-diagnostic-nullability-extension
- bugprone-macro-parentheses
- bugprone-redundant-branch-condition
+ - bugprone-signed-char-misuse
- bugprone-suspicious-realloc-usage
- misc-const-correctness
- misc-header-include-cycle
lib/curlx/inet_pton.c+2 -2
@@ -70,7 +70,7 @@ static int inet_pton4(const char *src, unsigned char *dst)
octets = 0;
tp = tmp;
*tp = 0;
- while((ch = *src++) != '\0') {
+ while((ch = (unsigned char)*src++) != '\0') {
if(ISDIGIT(ch)) {
unsigned int val = (*tp * 10) + (ch - '0');
@@ -129,7 +129,7 @@ static int inet_pton6(const char *src, unsigned char *dst)
curtok = src;
saw_xdigit = 0;
val = 0;
- while((ch = *src++) != '\0') {
+ while((ch = (unsigned char)*src++) != '\0') {
if(ISXDIGIT(ch)) {
val <<= 4;
val |= curlx_hexval(ch);
lib/mime.c+1 -1
@@ -464,7 +464,7 @@ static size_t encoder_qp_read(char *buffer, size_t size, bool ateof,
while(st->bufbeg < st->bufend) {
size_t len = 1;
size_t consumed = 1;
- int i = st->buf[st->bufbeg];
+ int i = (unsigned char)st->buf[st->bufbeg];
buf[0] = (char)i;
buf[1] = aschex[(i >> 4) & 0xF];
buf[2] = aschex[i & 0xF];
lib/vtls/openssl.c+5 -3
@@ -2592,18 +2592,20 @@ static void ossl_trace(int direction, int ssl_ver, int content_type,
if(content_type == SSL3_RT_CHANGE_CIPHER_SPEC) {
if(len) {
- msg_type = *(const char *)buf;
+ msg_type = *(const unsigned char *)buf;
msg_name = "Change cipher spec";
}
}
else if(content_type == SSL3_RT_ALERT) {
if(len >= 2) {
- msg_type = (((const char *)buf)[0] << 8) + ((const char *)buf)[1];
+ msg_type =
+ (((const unsigned char *)buf)[0] << 8) +
+ ((const unsigned char *)buf)[1];
msg_name = SSL_alert_desc_string_long(msg_type);
}
}
else if(len) {
- msg_type = *(const char *)buf;
+ msg_type = *(const unsigned char *)buf;
msg_name = ssl_msg_type(ssl_ver, msg_type);
}
src/tool_urlglob.c+2 -2
@@ -269,8 +269,8 @@ static CURLcode glob_range(struct URLGlob *glob, const char **patternp,
/* if there was a ":[num]" thing, use that as step or else use 1 */
pat->c.ascii.step = step;
- pat->c.ascii.letter = pat->c.ascii.min = min_c;
- pat->c.ascii.max = max_c;
+ pat->c.ascii.letter = pat->c.ascii.min = (unsigned char)min_c;
+ pat->c.ascii.max = (unsigned char)max_c;
if(multiply(amount, (((pat->c.ascii.max - pat->c.ascii.min) /
pat->c.ascii.step) + 1)))
tests/libtest/first.c+1 -1
@@ -83,7 +83,7 @@ int cgetopt(int argc, const char * const argv[], const char *optstring)
}
else {
const char *opt = strchr(optstring, arg[optpos]);
- coptopt = arg[optpos];
+ coptopt = (unsigned char)arg[optpos];
if(!opt) {
if(!arg[++optpos]) {
coptind++;
tests/server/mqttd.c+2 -2
@@ -503,7 +503,7 @@ static curl_socket_t mqttit(curl_socket_t fd)
conn_flags = buffer[7];
start_usr = client_id_offset + payload_len;
- if(usr_flag == (unsigned char)(conn_flags & usr_flag)) {
+ if(usr_flag == (conn_flags & usr_flag)) {
logmsg("User flag is present in CONN flag");
payload_len += (size_t)(buffer[start_usr] << 8) |
buffer[start_usr + 1];
@@ -511,7 +511,7 @@ static curl_socket_t mqttit(curl_socket_t fd)
}
start_passwd = client_id_offset + payload_len;
- if(passwd_flag == (char)(conn_flags & passwd_flag)) {
+ if(passwd_flag == (conn_flags & passwd_flag)) {
logmsg("Password flag is present in CONN flags");
payload_len += (size_t)(buffer[start_passwd] << 8) |
buffer[start_passwd + 1];
tests/server/tftpd.c+2 -2
@@ -359,7 +359,7 @@ static void read_ahead(struct testcase *test,
}
else {
if(test->rcount) {
- c = test->rptr[0];
+ c = (unsigned char)test->rptr[0];
test->rptr++;
test->rcount--;
}
@@ -451,7 +451,7 @@ static ssize_t write_behind(struct testcase *test, int convert)
p = writebuf;
ct = count;
while(ct--) { /* loop over the buffer */
- c = *p++; /* pick up a character */
+ c = (unsigned char)*p++; /* pick up a character */
if(prevchar == '\r') { /* if prev char was cr */
if(c == '\n') /* if have cr,lf then just */
curl_lseek(test->ofile, -1, SEEK_CUR); /* smash lf on top of the cr */