Skip to content

Commit d63780a

Browse files
authored
Merge pull request #22217 from krzysztof-cabaj/treewide-fix-static-tests
core & examples: fix static tests warnings form github actions
2 parents 3e219a0 + e2ab822 commit d63780a

11 files changed

Lines changed: 59 additions & 29 deletions

File tree

core/include/cond.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/*
2+
* SPDX-FileCopyrightText: 2018 Sam Kumar
23
* SPDX-License-Identifier: LGPL-2.1-only
34
*/
45

core/lib/include/bitarithm.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,15 @@ static inline uint8_t bitarithm_clzb(uint8_t x)
173173
{
174174
#if defined(BITARITHM_HAS_CLZ)
175175
/* clz operates on `unsigned int`, so `x` will be promoted to the size
176-
of an `unsigned int` */
176+
* of an `unsigned int` */
177177
return __builtin_clz(x) - 8 * (sizeof(unsigned) - 1);
178178
#else
179-
uint8_t l = 0;
179+
uint8_t number = 0;
180180
while (!(x & 0x80)) {
181-
++l;
181+
++number;
182182
x <<= 1;
183183
}
184-
return l;
184+
return number;
185185
#endif
186186
}
187187

core/lib/include/log.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,19 @@ enum {
8686
*/
8787
#ifdef __clang__ /* following pragmas required for clang 3.8.0 */
8888
#define LOG(level, ...) do { \
89-
_Pragma("clang diagnostic push") \
90-
_Pragma("clang diagnostic ignored \"-Wtautological-compare\"") \
91-
if ((level) <= LOG_LEVEL) LOG_WRITE((level), __VA_ARGS__); } while (0U) \
89+
_Pragma("clang diagnostic push") \
90+
_Pragma("clang diagnostic ignored \"-Wtautological-compare\"") \
91+
if ((level) <= LOG_LEVEL) { \
92+
LOG_WRITE((level), __VA_ARGS__); \
93+
} \
94+
} while (0U) \
9295
_Pragma("clang diagnostic pop")
9396
#else
9497
#define LOG(level, ...) do { \
95-
if ((level) <= LOG_LEVEL) LOG_WRITE((level), __VA_ARGS__); } while (0U)
98+
if ((level) <= LOG_LEVEL) { \
99+
LOG_WRITE((level), __VA_ARGS__); \
100+
} \
101+
} while (0U)
96102
#endif /* __clang__ */
97103

98104
/**

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);

0 commit comments

Comments
 (0)