Skip to content

Commit bc4a46e

Browse files
examples: fix static tests warning
1 parent f817f29 commit bc4a46e

8 files changed

Lines changed: 44 additions & 21 deletions

File tree

examples/networking/coap/gcoap/server.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ static const credman_credential_t credential = {
6262
static ssize_t _encode_link(const coap_resource_t *resource, char *buf,
6363
size_t maxlen, coap_link_encoder_ctx_t *context);
6464
static ssize_t _stats_handler(coap_pkt_t* pdu, uint8_t *buf, size_t len, coap_request_ctx_t *ctx);
65-
static ssize_t _riot_board_handler(coap_pkt_t* pdu, uint8_t *buf, size_t len, coap_request_ctx_t *ctx);
65+
static ssize_t _riot_board_handler(coap_pkt_t* pdu, uint8_t *buf, size_t len,
66+
coap_request_ctx_t *ctx);
6667
#if IS_USED(MODULE_PERIPH_RTC)
6768
static ssize_t _rtc_handler(coap_pkt_t* pdu, uint8_t *buf, size_t len, coap_request_ctx_t *ctx);
6869
#endif
@@ -206,7 +207,8 @@ static ssize_t _stats_handler(coap_pkt_t* pdu, uint8_t *buf, size_t len, coap_re
206207
return 0;
207208
}
208209

209-
static ssize_t _riot_board_handler(coap_pkt_t *pdu, uint8_t *buf, size_t len, coap_request_ctx_t *ctx)
210+
static ssize_t _riot_board_handler(coap_pkt_t *pdu, uint8_t *buf, size_t len,
211+
coap_request_ctx_t *ctx)
210212
{
211213
(void)ctx;
212214
gcoap_resp_init(pdu, buf, len, COAP_CODE_CONTENT);

examples/networking/coap/gcoap_block_server/gcoap_block.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
#include "debug.h"
2828

2929
static ssize_t _sha256_handler(coap_pkt_t* pdu, uint8_t *buf, size_t len, coap_request_ctx_t *ctx);
30-
static ssize_t _riot_block2_handler(coap_pkt_t *pdu, uint8_t *buf, size_t len, coap_request_ctx_t *ctx);
30+
static ssize_t _riot_block2_handler(coap_pkt_t *pdu, uint8_t *buf, size_t len,
31+
coap_request_ctx_t *ctx);
3132

3233
/* CoAP resources */
3334
static const coap_resource_t _resources[] = {
@@ -45,7 +46,8 @@ static const uint8_t block2_intro[] = "This is RIOT (Version: ";
4546
static const uint8_t block2_board[] = " running on a ";
4647
static const uint8_t block2_mcu[] = " board with a ";
4748

48-
static ssize_t _riot_block2_handler(coap_pkt_t *pdu, uint8_t *buf, size_t len, coap_request_ctx_t *ctx)
49+
static ssize_t _riot_block2_handler(coap_pkt_t *pdu, uint8_t *buf, size_t len,
50+
coap_request_ctx_t *ctx)
4951
{
5052
(void)ctx;
5153
coap_block_slicer_t slicer;

examples/networking/coap/gcoap_dtls/server.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ static const credman_credential_t credential = {
6161
static ssize_t _encode_link(const coap_resource_t *resource, char *buf,
6262
size_t maxlen, coap_link_encoder_ctx_t *context);
6363
static ssize_t _stats_handler(coap_pkt_t* pdu, uint8_t *buf, size_t len, coap_request_ctx_t *ctx);
64-
static ssize_t _riot_board_handler(coap_pkt_t* pdu, uint8_t *buf, size_t len, coap_request_ctx_t *ctx);
64+
static ssize_t _riot_board_handler(coap_pkt_t* pdu, uint8_t *buf, size_t len,
65+
coap_request_ctx_t *ctx);
6566
#if IS_USED(MODULE_PERIPH_RTC)
6667
static ssize_t _rtc_handler(coap_pkt_t* pdu, uint8_t *buf, size_t len, coap_request_ctx_t *ctx);
6768
#endif
@@ -205,7 +206,8 @@ static ssize_t _stats_handler(coap_pkt_t* pdu, uint8_t *buf, size_t len, coap_re
205206
return 0;
206207
}
207208

208-
static ssize_t _riot_board_handler(coap_pkt_t *pdu, uint8_t *buf, size_t len, coap_request_ctx_t *ctx)
209+
static ssize_t _riot_board_handler(coap_pkt_t *pdu, uint8_t *buf, size_t len,
210+
coap_request_ctx_t *ctx)
209211
{
210212
(void)ctx;
211213
gcoap_resp_init(pdu, buf, len, COAP_CODE_CONTENT);

examples/networking/coap/nanocoap_server/coap_handler.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,16 @@ static ssize_t _echo_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len, coap_req
3838
(uint8_t *)sub_uri, sub_uri_len);
3939
}
4040

41-
static ssize_t _riot_board_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len, coap_request_ctx_t *context)
41+
static ssize_t _riot_board_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len,
42+
coap_request_ctx_t *context)
4243
{
4344
(void)context;
4445
return coap_reply_simple(pkt, COAP_CODE_205, buf, len,
4546
COAP_FORMAT_TEXT, (uint8_t*)RIOT_BOARD, strlen(RIOT_BOARD));
4647
}
4748

48-
static ssize_t _riot_block2_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len, coap_request_ctx_t *context)
49+
static ssize_t _riot_block2_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len,
50+
coap_request_ctx_t *context)
4951
{
5052
(void)context;
5153
coap_block_slicer_t slicer;
@@ -87,7 +89,8 @@ static ssize_t _riot_block2_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len, c
8789
return coap_builder_msg_size(&state);
8890
}
8991

90-
static ssize_t _riot_value_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len, coap_request_ctx_t *context)
92+
static ssize_t _riot_value_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len,
93+
coap_request_ctx_t *context)
9194
{
9295
(void) context;
9396

@@ -208,7 +211,8 @@ static void _send_response(void *ctx)
208211
response, sizeof(response));
209212
}
210213

211-
static ssize_t _separate_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len, coap_request_ctx_t *context)
214+
static ssize_t _separate_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len,
215+
coap_request_ctx_t *context)
212216
{
213217
static event_timeout_t event_timeout;
214218
static event_callback_t event_timed = EVENT_CALLBACK_INIT(_send_response, &_separate_ctx);

examples/networking/dtls/dtls-echo/dtls-client.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,9 @@ static int _read_from_peer_handler(struct dtls_context_t *ctx,
239239
(void) session;
240240

241241
printf("Client: got DTLS Data App -- ");
242-
for (size_t i = 0; i < len; i++)
242+
for (size_t i = 0; i < len; i++) {
243243
printf("%c", data[i]);
244+
}
244245
puts(" --");
245246

246247
/*

examples/networking/dtls/dtls-wolfssl/cert.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2019 Daniele Lacamera
3+
* SPDX-License-Identifier: LGPL-2.1-only
4+
*/
5+
16
/* Created from wolfssl-examples test certificate+keys, ECC/RSA. 28/08/2019 */
27

38
#ifdef MODULE_WOLFCRYPT_ECC

examples/networking/dtls/dtls-wolfssl/dtls-client.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ static inline unsigned int my_psk_client_cb(WOLFSSL* ssl, const char* hint,
7171
int b = 0x01;
7272

7373
for (i = 0; i < 32; i++, b += 0x22) {
74-
if (b >= 0x100)
74+
if (b >= 0x100) {
7575
b = 0x01;
76+
}
7677
key[i] = b;
7778
}
7879

@@ -143,31 +144,34 @@ static int _client_cmd(int argc, char **argv)
143144
wolfSSL_CTX_set_psk_client_callback(sk->ctx, my_psk_client_cb);
144145
#endif
145146

146-
if (sock_dtls_session_create(sk) < 0)
147+
if (sock_dtls_session_create(sk) < 0) {
147148
return -1;
149+
}
148150
wolfSSL_dtls_set_timeout_init(sk->ssl, 5);
149151
LOG(LOG_INFO, "connecting to server...\n");
150152
/* attempt to connect until the connection is successful */
151153
do {
152154
ret = wolfSSL_connect(sk->ssl);
153155
if ((ret != SSL_SUCCESS)) {
154-
if(wolfSSL_get_error(sk->ssl, ret) == SOCKET_ERROR_E) {
156+
if (wolfSSL_get_error(sk->ssl, ret) == SOCKET_ERROR_E) {
155157
LOG(LOG_WARNING, "Socket error: reconnecting...\n");
156158
sock_dtls_session_destroy(sk);
157159
connect_timeout = 0;
158-
if (sock_dtls_session_create(sk) < 0)
160+
if (sock_dtls_session_create(sk) < 0) {
159161
return -1;
162+
}
160163
}
161164
if ((wolfSSL_get_error(sk->ssl, ret) == WOLFSSL_ERROR_WANT_READ) &&
162165
(connect_timeout++ >= max_connect_timeouts)) {
163166
LOG(LOG_WARNING, "Server not responding: reconnecting...\n");
164167
sock_dtls_session_destroy(sk);
165168
connect_timeout = 0;
166-
if (sock_dtls_session_create(sk) < 0)
169+
if (sock_dtls_session_create(sk) < 0) {
167170
return -1;
171+
}
168172
}
169173
}
170-
} while(ret != SSL_SUCCESS);
174+
} while (ret != SSL_SUCCESS);
171175

172176
/* set remote endpoint */
173177
sock_dtls_set_endpoint(sk, &remote);

examples/networking/dtls/dtls-wolfssl/dtls-server.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ static inline unsigned int my_psk_server_cb(WOLFSSL* ssl, const char* identity,
5151
(void)key_max_len;
5252

5353
/* see internal.h MAX_PSK_ID_LEN for PSK identity limit */
54-
if (strncmp(identity, kIdentityStr, strlen(kIdentityStr)) != 0)
54+
if (strncmp(identity, kIdentityStr, strlen(kIdentityStr)) != 0) {
5555
return 0;
56+
}
5657

5758
if (wolfSSL_GetVersion(ssl) < WOLFSSL_TLSV1_3) {
5859
/* test key in hex is 0x1a2b3c4d , in decimal 439,041,101 , we're using
@@ -69,8 +70,9 @@ static inline unsigned int my_psk_server_cb(WOLFSSL* ssl, const char* identity,
6970
int b = 0x01;
7071

7172
for (i = 0; i < 32; i++, b += 0x22) {
72-
if (b >= 0x100)
73+
if (b >= 0x100) {
7374
b = 0x01;
75+
}
7476
key[i] = b;
7577
}
7678

@@ -126,14 +128,15 @@ static int _server_cmd(int argc, char **argv)
126128
}
127129

128130
LOG(LOG_INFO, "Listening on %d\n", SERVER_PORT);
129-
while(1) {
131+
while (1) {
130132
/* Wait until a new client connects */
131133
ret = wolfSSL_accept(sk->ssl);
132134
if (ret != SSL_SUCCESS) {
133135
if (wolfSSL_get_error(sk->ssl, ret) != WOLFSSL_ERROR_WANT_READ) {
134136
sock_dtls_session_destroy(sk);
135-
if (sock_dtls_session_create(sk) < 0)
137+
if (sock_dtls_session_create(sk) < 0) {
136138
return -1;
139+
}
137140
}
138141
continue;
139142
}

0 commit comments

Comments
 (0)