Skip to content

Commit

Permalink
clean: avoid maybe-uninitialized
Browse files Browse the repository at this point in the history
  • Loading branch information
lws-team committed Jan 16, 2024
1 parent 9393dd3 commit 837db62
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 41 deletions.
3 changes: 2 additions & 1 deletion lib/core-net/wol.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ lws_wol(struct lws_context *ctx, const char *ip_or_NULL, uint8_t *mac_6_bytes)
ret = 0;

bail:
close(fd);
if (fd >= 0) /* coverity */
close(fd);

return ret;
}
6 changes: 3 additions & 3 deletions lib/core/logs.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,11 @@ __lws_lc_untag(struct lws_context *context, lws_lifecycle_t *lc)

//grp = lws_container_of(lc->list.owner, lws_lifecycle_group_t, owner);

lws_humanize(buf, sizeof(buf),
#if defined(LWS_LOG_TAG_LIFECYCLE)
if (lws_humanize(buf, sizeof(buf),
(uint64_t)lws_now_usecs() - lc->us_creation,
humanize_schema_us);
humanize_schema_us) > 0)

#if defined(LWS_LOG_TAG_LIFECYCLE)
lwsl_cx_notice(context, " -- %s (%d) %s", lc->gutag,
(int)lc->list.owner->count - 1, buf);
#endif
Expand Down
41 changes: 13 additions & 28 deletions lib/roles/http/client/client-http.c
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ static const char *digest_toks[] = {
"response", // 1 << 5
"opaque", // 1 << 6
"qop", // 1 << 7
"algorithm" // 1 << 8
"algorithm", // 1 << 8
"nc", // 1 << 9
"cnonce", // 1 << 10
"domain", // 1 << 11
Expand All @@ -604,7 +604,7 @@ enum lws_check_basic_auth_results
lws_http_digest_auth(struct lws* wsi)
{
uint8_t nonce[256], response[LWS_GENHASH_LARGEST], qop[32];
int seen = 0, n, pend = -1, skipping = 0;
int seen = 0, n, pend = -1;
char *tmp_digest = NULL;
struct lws_tokenize ts;
char resp_username[32];
Expand Down Expand Up @@ -677,8 +677,6 @@ lws_http_digest_auth(struct lws* wsi)
break;

case LWS_TOKZE_TOKEN_NAME_EQUALS:
if (skipping)
break;
if ((seen & (1 << 15)) == (1 << 15) || pend != -1)
/* no auth type token or disordered */
return LCBA_END_TRANSACTION;
Expand All @@ -704,8 +702,6 @@ lws_http_digest_auth(struct lws* wsi)
break;

case LWS_TOKZE_QUOTED_STRING:
if (skipping)
break;
if (pend < 0)
return LCBA_END_TRANSACTION;

Expand Down Expand Up @@ -757,20 +753,13 @@ lws_http_digest_auth(struct lws* wsi)

case LWS_TOKZE_DELIMITER:
if (*ts.token == ',') {
if (skipping)
break;
if (pend != PEND_DELIM)
return LCBA_END_TRANSACTION;

pend = PEND_NAME_EQ;
break;
}
if (*ts.token == ';') {
if (skipping) {
/* try again with this one */
skipping = 0;
break;
}
/* it's the end */
e = LWS_TOKZE_ENDED;
break;
Expand Down Expand Up @@ -1062,27 +1051,23 @@ lws_client_interpret_server_handshake(struct lws *wsi)
n = atoi(p);

#if defined(LWS_WITH_HTTP_DIGEST_AUTH)
if (n == 401 && lws_hdr_simple_ptr(wsi, WSI_TOKEN_HTTP_WWW_AUTHENTICATE)) {
if (!(wsi->stash && wsi->stash->cis[CIS_USERNAME] &&
wsi->stash->cis[CIS_PASSWORD])) {
lwsl_err(
"Digest auth requested by server but no credentials provided "
"by user\n");
return LCBA_FAILED_AUTH;
}

if (0 != lws_http_digest_auth(wsi)) {
if (wsi)
goto bail3;
return 1;
}
if (n == 401 && lws_hdr_simple_ptr(wsi, WSI_TOKEN_HTTP_WWW_AUTHENTICATE)) {
if (!(wsi->stash && wsi->stash->cis[CIS_USERNAME] &&
wsi->stash->cis[CIS_PASSWORD])) {
lwsl_err("Digest auth requested by server but no credentials provided by user\n");

return LCBA_FAILED_AUTH;
}

if (lws_http_digest_auth(wsi))
goto bail3;

opaque = wsi->a.opaque_user_data;
lws_close_free_wsi(wsi, LWS_CLOSE_STATUS_NOSTATUS, "digest_auth_step2");
wsi->a.opaque_user_data = opaque;

return -1;
}
}

ah = wsi->http.ah;
#endif
Expand Down
2 changes: 1 addition & 1 deletion lib/roles/http/date.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ lws_http_date_parse_unix(const char *b, size_t len, time_t *t)
#endif
#endif

return (int)*t == -1 ? -1 : 0;
return (int)(*t == -1 ? -1 : 0);
}

#if defined(LWS_WITH_CLIENT)
Expand Down
2 changes: 1 addition & 1 deletion lib/roles/http/server/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ _lws_vhost_init_server_af(struct vh_sock_args *a)
int n, opt = 1, limit = 1, san = 2;
lws_sockfd_type sockfd;
struct lws *wsi;
int m = 0, is;
int m = 0, is = 0;
#if defined(LWS_WITH_IPV6)
int value = 1;
#endif
Expand Down
9 changes: 4 additions & 5 deletions lib/system/smd/smd.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,17 +533,16 @@ _lws_smd_msg_deliver_peer(struct lws_context *ctx, lws_smd_peer_t *pr)

msg = lws_container_of(pr->tail, lws_smd_msg_t, list);


lwsl_cx_info(ctx, "deliver cl 0x%x, len %d, refc %d, to peer %p",
lwsl_cx_info(ctx, "deliver cl 0x%x, len %d, to peer %p",
(unsigned int)msg->_class, (int)msg->length,
(int)msg->refcount, pr);
pr);

pr->cb(pr->opaque, msg->_class, msg->timestamp,
((uint8_t *)&msg[1]) + LWS_SMD_SS_RX_HEADER_LEN_EFF,
(size_t)msg->length);

#if !defined(__COVERITY__)
assert(msg->refcount);

#endif
/*
* If there is one, move forward to the next queued
* message that meets the filters of this peer
Expand Down
4 changes: 2 additions & 2 deletions lib/tls/tls-network.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ lws_tls_check_cert_lifetime(struct lws_vhost *v)
return 1;

life = (ir.time - now) / (24 * 3600);
lwsl_vhost_notice(v, " vhost %s: cert expiry: %dd", v->name,
(int)life);
lwsl_vhost_notice(v, " vhost %s: cert expiry: %lldd", v->name,
(long long)life);
} else
lwsl_vhost_info(v, " vhost %s: no cert", v->name);

Expand Down

0 comments on commit 837db62

Please sign in to comment.