Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Clang warnings #176

Merged
merged 3 commits into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deps/uv_link_t/src/uv_link_t.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void uv_link_propagate_close(uv_link_t* link, uv_link_t* source,


static void uv_link_recalculate_prefixes(uv_link_t* link) {
unsigned short prev;
unsigned prev;

prev = link->parent->err_prefix >> kErrorPrefixShift;
for (; link != NULL; link = link->child)
Expand Down
3 changes: 2 additions & 1 deletion include/tlsuv/src_t.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@ struct tlsuv_src_s {
}
#endif

#endif//TLSUV_SRC_T_H
#endif//TLSUV_SRC_T_H

3 changes: 2 additions & 1 deletion include/tlsuv/tcp_src.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,5 @@ void tcp_src_free(tcp_src_t *ts);
}
#endif

#endif//TLSUV_TCP_SRC_H
#endif//TLSUV_TCP_SRC_H

2 changes: 1 addition & 1 deletion src/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct msg {
STAILQ_ENTRY(msg) next;
};

tlsuv_BIO *tlsuv_BIO_new() {
tlsuv_BIO *tlsuv_BIO_new(void) {
tlsuv_BIO * bio = calloc(1, sizeof(tlsuv_BIO));
bio->available = 0;
bio->headoffset = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/bio.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ typedef struct tlsuv_bio_s {
} tlsuv_BIO;

// create new BIO
tlsuv_BIO *tlsuv_BIO_new();
tlsuv_BIO *tlsuv_BIO_new(void);
void tlsuv_BIO_free(tlsuv_BIO *bio);

int tlsuv_BIO_put(tlsuv_BIO *bio, const uint8_t *buf, size_t len);
Expand Down
6 changes: 3 additions & 3 deletions src/compression.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static void comp_free(void *ctx, void *p) {

#endif

static void init() {
static void init(void) {

#if _WIN32
// on WIN32 zlib is not usually available
Expand Down Expand Up @@ -106,7 +106,7 @@ goto on_error; \
return;
}

const char *um_available_encoding() {
const char *um_available_encoding(void) {
uv_once(&init_guard, init);
return encodings;
}
Expand Down Expand Up @@ -143,7 +143,7 @@ void um_free_inflater(http_inflater_t *inflater) {

int um_inflate(http_inflater_t *inflater, const char *compressed, size_t len) {
inflater->s.next_in = (uint8_t *)compressed;
inflater->s.avail_in = len;
inflater->s.avail_in = (uInt)len;
uint8_t decompressed[32 * 1024];
while(inflater->s.avail_in > 0) {
inflater->s.next_out = decompressed;
Expand Down
2 changes: 1 addition & 1 deletion src/compression.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extern "C" {
#endif
typedef void (*data_cb)(void *ct, const char* data, ssize_t datalen);

extern const char *um_available_encoding();
extern const char *um_available_encoding(void);
extern http_inflater_t* um_get_inflater(const char *encoding, data_cb cb, void *ctx);
extern int um_inflate_state(http_inflater_t *inflater);
extern void um_free_inflater(http_inflater_t *inflater);
Expand Down
8 changes: 4 additions & 4 deletions src/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#define DEFAULT_IDLE_TIMEOUT 0

extern tls_context *get_default_tls();
extern tls_context *get_default_tls(void);

static void http_read_cb(uv_link_t *link, ssize_t nread, const uv_buf_t *buf);

Expand Down Expand Up @@ -280,12 +280,12 @@
clt->src->cancel(clt->src);
}

static void req_write_cb(uv_link_t *source, int status, void *arg) {

Check warning on line 283 in src/http.c

View workflow job for this annotation

GitHub Actions / build (windows, openssl)

'source': unreferenced formal parameter

Check warning on line 283 in src/http.c

View workflow job for this annotation

GitHub Actions / build (windows, mbedtls)

'source': unreferenced formal parameter
UM_LOG(VERB, "request write completed: %d", status);
free(arg);
}

static void req_write_body_cb(uv_link_t *source, int status, void *arg) {

Check warning on line 288 in src/http.c

View workflow job for this annotation

GitHub Actions / build (windows, openssl)

'source': unreferenced formal parameter

Check warning on line 288 in src/http.c

View workflow job for this annotation

GitHub Actions / build (windows, mbedtls)

'source': unreferenced formal parameter
UM_LOG(VERB, "request body write completed: %d", status);
struct body_chunk_s *chunk = arg;
if (chunk->cb) {
Expand All @@ -294,7 +294,7 @@
free(chunk);
}

static void chunk_hdr_wcb(uv_link_t *l, int status, void *arg) {

Check warning on line 297 in src/http.c

View workflow job for this annotation

GitHub Actions / build (windows, openssl)

'status': unreferenced formal parameter

Check warning on line 297 in src/http.c

View workflow job for this annotation

GitHub Actions / build (windows, openssl)

'l': unreferenced formal parameter

Check warning on line 297 in src/http.c

View workflow job for this annotation

GitHub Actions / build (windows, mbedtls)

'status': unreferenced formal parameter

Check warning on line 297 in src/http.c

View workflow job for this annotation

GitHub Actions / build (windows, mbedtls)

'l': unreferenced formal parameter
if (arg != NULL) {
free(arg);
}
Expand All @@ -320,7 +320,7 @@
uv_link_write((uv_link_t *) &clt->http_link, &buf, 1, NULL, chunk_hdr_wcb, buf.base);

buf.base = (char*)b->chunk;
buf.len = b->len;

Check warning on line 323 in src/http.c

View workflow job for this annotation

GitHub Actions / build (windows, openssl)

'=': conversion from 'size_t' to 'ULONG', possible loss of data

Check warning on line 323 in src/http.c

View workflow job for this annotation

GitHub Actions / build (windows, mbedtls)

'=': conversion from 'size_t' to 'ULONG', possible loss of data
uv_link_write((uv_link_t *) &clt->http_link, &buf, 1, NULL, req_write_body_cb, b);

buf.base = "\r\n";
Expand All @@ -335,14 +335,14 @@
}
}
else {
buf = uv_buf_init((char*)b->chunk, b->len);
buf = uv_buf_init((char*)b->chunk, (unsigned int)b->len);
uv_link_write((uv_link_t *) &clt->http_link, &buf, 1, NULL, req_write_body_cb, b);
if (req->body_sent_size > req->req_body_size) {

Check warning on line 340 in src/http.c

View workflow job for this annotation

GitHub Actions / build (windows, openssl)

'>': signed/unsigned mismatch

Check warning on line 340 in src/http.c

View workflow job for this annotation

GitHub Actions / build (windows, mbedtls)

'>': signed/unsigned mismatch
UM_LOG(WARN, "Supplied data[%ld] is larger than provided Content-Length[%ld]",
req->body_sent_size, req->req_body_size);
}

if (req->body_sent_size >= req->req_body_size) {

Check warning on line 345 in src/http.c

View workflow job for this annotation

GitHub Actions / build (windows, openssl)

'>=': signed/unsigned mismatch

Check warning on line 345 in src/http.c

View workflow job for this annotation

GitHub Actions / build (windows, mbedtls)

'>=': signed/unsigned mismatch
req->state = body_sent;
}
}
Expand Down Expand Up @@ -496,7 +496,7 @@
port = u.port;
}

sprintf(clt->port, "%d", port);
snprintf(clt->port, sizeof(clt->port), "%d", port);

if (u.path != NULL) {
http_set_prefix(clt, u.path, u.path_len);
Expand Down Expand Up @@ -803,4 +803,4 @@
}

return 0;
}
}
4 changes: 2 additions & 2 deletions src/http_req.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ size_t http_req_write(tlsuv_http_req_t *req, char *buf, size_t maxlen) {
}
req->req_body_size = req_len;
char length_str[16];
sprintf(length_str, "%ld", req_len);
snprintf(length_str, sizeof(length_str), "%ld", req_len);
set_http_header(&req->req_headers, "Content-Length", length_str);
}
}
Expand Down Expand Up @@ -287,4 +287,4 @@ static int http_body_cb(llhttp_t *parser, const char *body, size_t len) {
}
}
return 0;
}
}
6 changes: 3 additions & 3 deletions src/mbedtls/engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static int mbedtls_close(tlsuv_engine_t engine, char *out, size_t *out_bytes, si

static int mbedtls_reset(tlsuv_engine_t engine);

static const char *mbedtls_version();
static const char *mbedtls_version(void);

static const char *mbedtls_eng_error(tlsuv_engine_t engine);

Expand Down Expand Up @@ -179,7 +179,7 @@ static int mbed_ssl_recv(void *ctx, uint8_t *buf, size_t len);

static int mbed_ssl_send(void *ctx, const uint8_t *buf, size_t len);

static const char* mbedtls_version() {
static const char* mbedtls_version(void) {
return MBEDTLS_VERSION_STRING_FULL;
}

Expand Down Expand Up @@ -967,4 +967,4 @@ static int generate_csr(tlsuv_private_key_t key, char **pem, size_t *pemlen, ...
}
mbedtls_x509write_csr_free(&csr);
return ret;
}
}
2 changes: 1 addition & 1 deletion src/mbedtls/keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,4 +288,4 @@ int gen_key(tlsuv_private_key_t *key) {
int load_key_p11(tlsuv_private_key_t *key, const char *lib, const char *slot, const char *pin, const char *id, const char *label) {
UM_LOG(WARN, "not implemented");
return -1;
}
}
4 changes: 2 additions & 2 deletions src/mbedtls/mbed_p11.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#include <string.h>

#define P11(op) do {\
int rc; rc = (op); \
if (rc != CKR_OK) return rc; \
CK_RV rc; rc = (op); \
if (rc != CKR_OK) return (int)rc; \
} while(0)


Expand Down
2 changes: 1 addition & 1 deletion src/mbedtls/p11_ecdsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,4 @@ static void p11_ecdsa_free(void *ctx) {
static size_t p11_ecdsa_bitlen(const void *ctx) {
mp11_key_ctx *p11key = (mp11_key_ctx *) ctx;
return (((mbedtls_ecdsa_context *) p11key->pub)->MBEDTLS_PRIVATE(grp).pbits);
}
}
4 changes: 2 additions & 2 deletions src/mbedtls/p11_rsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ static int p11_rsa_verify(void *ctx, mbedtls_md_type_t md_alg,
mp11_key_ctx *p11key = ctx;

#if MBEDTLS_VERSION_MAJOR == 3
return mbedtls_rsa_rsassa_pkcs1_v15_verify(p11key->pub, md_alg, hash_len, hash, sig);
return mbedtls_rsa_rsassa_pkcs1_v15_verify(p11key->pub, md_alg, (unsigned)hash_len, hash, sig);
#else
return mbedtls_rsa_rsassa_pkcs1_v15_verify(p11key->pub, NULL, NULL, MBEDTLS_RSA_PUBLIC, md_alg, hash_len, hash, sig);
#endif
Expand Down Expand Up @@ -202,4 +202,4 @@ static int get_md_prefix(mbedtls_md_type_t md, const char **prefix, size_t *len)
}

return 0;
}
}
4 changes: 2 additions & 2 deletions src/p11.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@


#define P11(op) do {\
int rc; rc = (op); \
CK_RV rc; rc = (op); \
if (rc != CKR_OK) { \
UM_LOG(WARN, "%s => %d/%s", #op, rc, p11_strerror(rc));\
return rc; \
return (int)rc; \
}\
} while(0)

Expand Down
2 changes: 1 addition & 1 deletion src/portable_endian.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,4 @@

#endif

#endif
#endif
2 changes: 1 addition & 1 deletion src/tls_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ tls_context *default_tls_context(const char *ca, size_t ca_len) {
return NULL;
}
return factory(ca, ca_len);
}
}
2 changes: 1 addition & 1 deletion src/tls_link.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static void tls_read_cb(uv_link_t *l, ssize_t nread, const uv_buf_t *b) {
UM_LOG(TRACE, "TLS(%p)[%d]: %zd", tls, hs_state, nread);

if (nread < 0) {
UM_LOG(ERR, "TLS read %d(%s)", nread, uv_strerror(nread));
UM_LOG(ERR, "TLS read %d(%s)", nread, uv_strerror((int)nread));
if (hs_state == TLS_HS_CONTINUE) {
tls->engine->reset(tls->engine);
tls->hs_cb(tls, TLS_HS_ERROR);
Expand Down
7 changes: 4 additions & 3 deletions src/tlsuv.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,22 @@

static tls_context *DEFAULT_TLS = NULL;

static void free_default_tls() {
static void free_default_tls(void) {
if (DEFAULT_TLS) {
DEFAULT_TLS->free_ctx(DEFAULT_TLS);
DEFAULT_TLS = NULL;
}
}

tls_context *get_default_tls() {
tls_context *get_default_tls(void) {
if (DEFAULT_TLS == NULL) {
DEFAULT_TLS = default_tls_context(NULL, 0);
atexit(free_default_tls);
}
return DEFAULT_TLS;
}

const char* tlsuv_version() {
const char* tlsuv_version(void) {
return TLSUV_VERS;
}

Expand Down Expand Up @@ -114,6 +114,7 @@
int tlsuv_stream_set_protocols(tlsuv_stream_t *clt, int count, const char *protocols[]) {
clt->alpn_count = count;
clt->alpn_protocols = protocols;
return 0;
}

const char* tlsuv_stream_get_protocol(tlsuv_stream_t *clt) {
Expand Down Expand Up @@ -205,7 +206,7 @@
return 0;
}

static void on_mbed_link_write(uv_link_t* l, int status, void *ctx) {

Check warning on line 209 in src/tlsuv.c

View workflow job for this annotation

GitHub Actions / build (windows, openssl)

'l': unreferenced formal parameter

Check warning on line 209 in src/tlsuv.c

View workflow job for this annotation

GitHub Actions / build (windows, mbedtls)

'l': unreferenced formal parameter
uv_write_t *wr = ctx;
wr->cb(wr, status);
}
Expand Down
2 changes: 1 addition & 1 deletion src/um_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ void um_log(int lvl, const char* file, unsigned int line, const char *fmt, ...)
void tlsuv_set_debug(int level, tlsuv_log_func output_f) {
um_log_level = level;
log_func = output_f;
}
}
6 changes: 3 additions & 3 deletions src/websocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ typedef struct ws_write_s {

} ws_write_t;

extern tls_context *get_default_tls();
extern tls_context *get_default_tls(void);

static void src_connect_cb(tlsuv_src_t *sl, int status, void *connect_ctx);
static void ws_read_cb(uv_link_t* link,
Expand Down Expand Up @@ -70,7 +70,7 @@ int tlsuv_websocket_init_with_src(uv_loop_t *loop, tlsuv_websocket_t *ws, tlsuv_
ws->req = calloc(1, sizeof(tlsuv_http_req_t));

time_t t;
srand(time(&t));
srand((unsigned)time(&t));
char key[25];
for (int i = 0; i < 22; i++) {
int v = rand() & 0x3f;
Expand Down Expand Up @@ -481,4 +481,4 @@ static void tls_hs_cb(tls_link_t *tls, int status) {
} else {
ws->conn_req->cb(ws->conn_req, UV_ECONNABORTED);
}
}
}
Loading