mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
codacy: fixes for warnings
This commit is contained in:
parent
e4a65c948e
commit
2d086db6e8
7 changed files with 38 additions and 33 deletions
|
@ -88,7 +88,7 @@ struct lws_udp {
|
|||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
/**
|
||||
* lws_adopt_descriptor_vhost() - adopt foreign socket or file descriptor
|
||||
* if socket descriptor, should already have been accepted from listen socket
|
||||
*
|
||||
|
|
|
@ -93,9 +93,11 @@ void lwsl_emit_optee(int level, const char *line)
|
|||
n = strlen(line);
|
||||
if ((unsigned int)n > sizeof(linecp) - 1)
|
||||
n = sizeof(linecp) - 1;
|
||||
if (n)
|
||||
if (n) {
|
||||
memcpy(linecp, line, n - 1);
|
||||
linecp[n - 1] = '\0';
|
||||
linecp[n - 1] = '\0';
|
||||
} else
|
||||
linecp[0] = '\0';
|
||||
EMSG("%c%s%s%s%c[0m", 27, colours[m], buf, linecp, 27);
|
||||
}
|
||||
|
||||
|
|
|
@ -141,7 +141,11 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi)
|
|||
m |= pt->context->tls_ops->fake_POLLIN_for_buffered(pt);
|
||||
#endif
|
||||
|
||||
if (!m && !n) { /* nothing to do */
|
||||
if (
|
||||
#if (defined(LWS_ROLE_WS) && !defined(LWS_WITHOUT_EXTENSIONS)) || defined(LWS_WITH_TLS)
|
||||
!m &&
|
||||
#endif
|
||||
!n) { /* nothing to do */
|
||||
lws_service_fd_tsi(context, NULL, tsi);
|
||||
lws_service_do_ripe_rxflow(pt);
|
||||
|
||||
|
|
|
@ -884,11 +884,21 @@ SSL *SSL_SSL_from_mbedtls_ssl_context(mbedtls_ssl_context *msc)
|
|||
|
||||
void SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx)
|
||||
{
|
||||
#if defined(LWS_HAVE_mbedtls_ssl_set_hs_authmode)
|
||||
#if defined(LWS_HAVE_mbedtls_ssl_set_hs_authmode) || \
|
||||
defined(LWS_HAVE_mbedtls_ssl_set_hs_ca_chain) || \
|
||||
defined(LWS_HAVE_mbedtls_ssl_set_hs_own_cert)
|
||||
struct ssl_pm *ssl_pm = ssl->ssl_pm;
|
||||
#endif
|
||||
#if defined(LWS_HAVE_mbedtls_ssl_set_hs_own_cert)
|
||||
struct x509_pm *x509_pm = (struct x509_pm *)ctx->cert->x509->x509_pm;
|
||||
#endif
|
||||
#if defined(LWS_HAVE_mbedtls_ssl_set_hs_ca_chain)
|
||||
struct x509_pm *x509_pm_ca = (struct x509_pm *)ctx->client_CA->x509_pm;
|
||||
#endif
|
||||
#if defined(LWS_HAVE_mbedtls_ssl_set_hs_own_cert)
|
||||
struct pkey_pm *pkey_pm = (struct pkey_pm *)ctx->cert->pkey->pkey_pm;
|
||||
#endif
|
||||
#if defined(LWS_HAVE_mbedtls_ssl_set_hs_authmode)
|
||||
int mode;
|
||||
#endif
|
||||
|
||||
|
@ -908,8 +918,6 @@ void SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx)
|
|||
mode = MBEDTLS_SSL_VERIFY_NONE;
|
||||
#endif
|
||||
|
||||
// printf("ssl: %p, client ca x509_crt %p, mbedtls mode %d\n", ssl, x509_pm_ca->x509_crt, mode);
|
||||
|
||||
/* apply new ctx cert to ssl */
|
||||
|
||||
ssl->verify_mode = ctx->verify_mode;
|
||||
|
|
|
@ -133,8 +133,6 @@ test_jwe_a1(struct lws_context *context)
|
|||
|
||||
/* we require a JOSE-formatted header to do the encryption */
|
||||
|
||||
if (temp_len < 256)
|
||||
goto bail;
|
||||
jwe.jws.map.buf[LJWS_JOSE] = temp;
|
||||
jwe.jws.map.len[LJWS_JOSE] = lws_snprintf(temp, temp_len,
|
||||
"{\"alg\":\"%s\",\"enc\":\"%s\"}", "RSA-OAEP", "A256GCM");
|
||||
|
@ -1979,8 +1977,6 @@ test_akw_encrypt(struct lws_context *context, const char *test_name,
|
|||
|
||||
/* we require a JOSE-formatted header to do the encryption */
|
||||
|
||||
if (temp_len < 256)
|
||||
goto bail;
|
||||
jwe.jws.map.buf[LJWS_JOSE] = temp;
|
||||
jwe.jws.map.len[LJWS_JOSE] = lws_snprintf(temp, temp_len,
|
||||
"{\"alg\":\"%s\", \"enc\":\"%s\"}", alg, enc);
|
||||
|
|
|
@ -19,11 +19,6 @@
|
|||
return encodeURI(s).replace(/@/g, "%40");
|
||||
}
|
||||
|
||||
function lws_urldecode(s)
|
||||
{
|
||||
return decodeURI(s).replace(/%40/g, "@");
|
||||
}
|
||||
|
||||
function trim(num)
|
||||
{
|
||||
var s = num.toString();
|
||||
|
@ -31,10 +26,10 @@
|
|||
if (!s.indexOf("."))
|
||||
return s;
|
||||
|
||||
while (s.length && s[s.length - 1] == "0")
|
||||
while (s.length && s[s.length - 1] === "0")
|
||||
s = s.substring(0, s.length - 1);
|
||||
|
||||
if (s[s.length - 1] == ".")
|
||||
if (s[s.length - 1] === ".")
|
||||
s = s.substring(0, s.length - 1);
|
||||
|
||||
return s;
|
||||
|
@ -90,7 +85,7 @@
|
|||
var formData = new FormData();
|
||||
var t = document.getElementById("ongoing");
|
||||
|
||||
formData.append('file', file);
|
||||
formData.append("file", file);
|
||||
|
||||
var row = t.insertRow(0), c1 = row.insertCell(0),
|
||||
c2 = row.insertCell(1), c3 = row.insertCell(2);
|
||||
|
@ -115,7 +110,7 @@
|
|||
return;
|
||||
|
||||
fetch("upload/" + lws_urlencode(file.name), {
|
||||
method: 'POST',
|
||||
method: "POST",
|
||||
body: formData
|
||||
})
|
||||
.then((e) => { /* this just means we got a response code */
|
||||
|
@ -144,7 +139,7 @@
|
|||
t.rows[n].cells[0] = "FAIL";
|
||||
break;
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function da_drop(e) {
|
||||
|
@ -155,7 +150,7 @@
|
|||
|
||||
clear_errors();
|
||||
|
||||
([...e.dataTransfer.files]).forEach(do_upload)
|
||||
([...e.dataTransfer.files]).forEach(do_upload);
|
||||
}
|
||||
|
||||
function upl_button(e) {
|
||||
|
@ -165,7 +160,7 @@
|
|||
clear_errors();
|
||||
e.preventDefault();
|
||||
|
||||
([...fi.files]).forEach(do_upload)
|
||||
([...fi.files]).forEach(do_upload);
|
||||
}
|
||||
|
||||
function body_drop(e) {
|
||||
|
@ -184,7 +179,7 @@
|
|||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
ws.send("{\"del\":\"" + lws_urldecode(e.target.getAttribute("file")) +
|
||||
ws.send("{\"del\":\"" + decodeURI(e.target.getAttribute("file")) +
|
||||
"\"}");
|
||||
}
|
||||
|
||||
|
@ -302,4 +297,4 @@
|
|||
}
|
||||
|
||||
});
|
||||
}());
|
||||
}());
|
||||
|
|
|
@ -26,10 +26,10 @@
|
|||
if (!s.indexOf("."))
|
||||
return s;
|
||||
|
||||
while (s.length && s[s.length - 1] == "0")
|
||||
while (s.length && s[s.length - 1] === "0")
|
||||
s = s.substring(0, s.length - 1);
|
||||
|
||||
if (s[s.length - 1] == ".")
|
||||
if (s[s.length - 1] === ".")
|
||||
s = s.substring(0, s.length - 1);
|
||||
|
||||
return s;
|
||||
|
@ -85,7 +85,7 @@
|
|||
var formData = new FormData();
|
||||
var t = document.getElementById("ongoing");
|
||||
|
||||
formData.append('file', file);
|
||||
formData.append("file", file);
|
||||
|
||||
var row = t.insertRow(0), c1 = row.insertCell(0),
|
||||
c2 = row.insertCell(1), c3 = row.insertCell(2);
|
||||
|
@ -110,7 +110,7 @@
|
|||
return;
|
||||
|
||||
fetch("upload/" + lws_urlencode(file.name), {
|
||||
method: 'POST',
|
||||
method: "POST",
|
||||
body: formData
|
||||
})
|
||||
.then((e) => { /* this just means we got a response code */
|
||||
|
@ -139,7 +139,7 @@
|
|||
t.rows[n].cells[0] = "FAIL";
|
||||
break;
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function da_drop(e) {
|
||||
|
@ -150,7 +150,7 @@
|
|||
|
||||
clear_errors();
|
||||
|
||||
([...e.dataTransfer.files]).forEach(do_upload)
|
||||
([...e.dataTransfer.files]).forEach(do_upload);
|
||||
}
|
||||
|
||||
function upl_button(e) {
|
||||
|
@ -160,7 +160,7 @@
|
|||
clear_errors();
|
||||
e.preventDefault();
|
||||
|
||||
([...fi.files]).forEach(do_upload)
|
||||
([...fi.files]).forEach(do_upload);
|
||||
}
|
||||
|
||||
function body_drop(e) {
|
||||
|
@ -297,4 +297,4 @@
|
|||
}
|
||||
|
||||
});
|
||||
}());
|
||||
}());
|
||||
|
|
Loading…
Add table
Reference in a new issue