This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit 9a733d410ea84f682a30f639b7517b32c50b9070 Author: Marco Casaroli <[email protected]> AuthorDate: Wed Oct 28 22:20:59 2026 +0100 apps: Fix the nxstyle and spelling errors in files that use bool. The next change adds an include line to these files. The checks of a change look at the whole of each file that it touches, and these files had older errors: alignment, braces and blank lines after declarations (nxstyle), and "writting" and "responde" in uart_lorawan_layer.c (codespell). Fix them. Apart from the two words, the change is layout only; no code changes. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- benchmarks/sd_bench/sd_bench_main.c | 74 ++++++----- examples/fxos8700cq_test/fxos8700cq_main.c | 6 +- examples/tcp_ipc_server/uart_lorawan_layer.c | 22 ++-- system/resmonitor/fillcpu.c | 4 + system/resmonitor/showinfo.c | 27 ++++ system/tcpdump/tcpdump.c | 1 + testing/drivers/drivertest/drivertest_i2c_read.c | 18 +-- testing/drivers/drivertest/drivertest_uart.c | 24 ++-- testing/drivers/sd_stress/sd_stress_main.c | 38 +++--- testing/drivers/setest/setest.c | 157 +++++++++++++++-------- testing/ostest/pthread_cleanup.c | 3 +- testing/ostest/pthread_rwlock_cancel.c | 4 +- 12 files changed, 237 insertions(+), 141 deletions(-) diff --git a/benchmarks/sd_bench/sd_bench_main.c b/benchmarks/sd_bench/sd_bench_main.c index 9822ac748..aa5b7256f 100644 --- a/benchmarks/sd_bench/sd_bench_main.c +++ b/benchmarks/sd_bench/sd_bench_main.c @@ -122,6 +122,7 @@ static void usage(void); static struct timespec get_abs_time(void) { struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); return ts; } @@ -130,6 +131,7 @@ static uint64_t get_time_delta_us(const struct timespec *start, const struct timespec *end) { uint64_t elapsed; + elapsed = (end->tv_sec * NSEC_PER_SEC) + end->tv_nsec; elapsed -= (start->tv_sec * NSEC_PER_SEC) + start->tv_nsec; return elapsed / 1000.; @@ -138,12 +140,14 @@ static uint64_t get_time_delta_us(const struct timespec *start, static uint64_t get_elapsed_time_us(const struct timespec *start) { struct timespec now = get_abs_time(); + return get_time_delta_us(start, &now); } static uint64_t time_fsync_us(int fd) { struct timespec start = get_abs_time(); + fsync(fd); return get_elapsed_time_us(&start); } @@ -393,38 +397,38 @@ int main(int argc, char *argv[]) { switch (ch) { - case 'b': - block_size = strtol(optarg, NULL, 0); - break; - - case 'r': - cfg.num_runs = strtol(optarg, NULL, 0); - break; - - case 'd': - cfg.run_duration = strtol(optarg, NULL, 0); - break; - - case 'k': - keep = !default_keep_test; - break; - - case 's': - cfg.synchronized = !default_fsync; - break; - - case 'a': - cfg.aligned = !default_aligned; - break; - - case 'v': - verify = !default_verify; - break; - - default: - usage(); - return -1; - break; + case 'b': + block_size = strtol(optarg, NULL, 0); + break; + + case 'r': + cfg.num_runs = strtol(optarg, NULL, 0); + break; + + case 'd': + cfg.run_duration = strtol(optarg, NULL, 0); + break; + + case 'k': + keep = !default_keep_test; + break; + + case 's': + cfg.synchronized = !default_fsync; + break; + + case 'a': + cfg.aligned = !default_aligned; + break; + + case 'v': + verify = !default_verify; + break; + + default: + usage(); + return -1; + break; } } @@ -497,9 +501,9 @@ int main(int argc, char *argv[]) close(bench_fd); if (!keep) - { - unlink(BENCHMARK_FILE); - } + { + unlink(BENCHMARK_FILE); + } return 0; } diff --git a/examples/fxos8700cq_test/fxos8700cq_main.c b/examples/fxos8700cq_test/fxos8700cq_main.c index b55ad7aef..e30d6f2ff 100644 --- a/examples/fxos8700cq_test/fxos8700cq_main.c +++ b/examples/fxos8700cq_test/fxos8700cq_main.c @@ -68,9 +68,9 @@ int main(int argc, FAR char *argv[]) ret = read(fd, &data, sizeof(fxos8700cq_data)); if (ret != sizeof(fxos8700cq_data)) { - fprintf(stderr, "Read failed : %d/%d@%d\n", - ret, sizeof(fxos8700cq_data), fd); - break; + fprintf(stderr, "Read failed : %d/%d@%d\n", + ret, sizeof(fxos8700cq_data), fd); + break; } printf("{\"accel\":[%d, %d, %d],\"magn\":[%d, %d, %d]}\n", data.accel.x, data.accel.y, data.accel.z, diff --git a/examples/tcp_ipc_server/uart_lorawan_layer.c b/examples/tcp_ipc_server/uart_lorawan_layer.c index dedafa08d..eefea9977 100644 --- a/examples/tcp_ipc_server/uart_lorawan_layer.c +++ b/examples/tcp_ipc_server/uart_lorawan_layer.c @@ -271,7 +271,7 @@ void lorawan_radioenge_init(config_lorawan_radioenge_t config_lorawan) if (bytes_written_at_cmd <= 0) { - perror("Error when writting Channel Mask to LoRaWAN module"); + perror("Error when writing Channel Mask to LoRaWAN module"); goto END_UART_LORAWAN_MODULE_INIT; } @@ -288,7 +288,7 @@ void lorawan_radioenge_init(config_lorawan_radioenge_t config_lorawan) if (bytes_written_at_cmd <= 0) { - perror("Error when writting Join Mode to LoRaWAN module"); + perror("Error when writing Join Mode to LoRaWAN module"); goto END_UART_LORAWAN_MODULE_INIT; } @@ -306,7 +306,7 @@ void lorawan_radioenge_init(config_lorawan_radioenge_t config_lorawan) if (bytes_written_at_cmd <= 0) { - perror("Error when writting device address to LoRaWAN module"); + perror("Error when writing device address to LoRaWAN module"); goto END_UART_LORAWAN_MODULE_INIT; } @@ -324,7 +324,7 @@ void lorawan_radioenge_init(config_lorawan_radioenge_t config_lorawan) if (bytes_written_at_cmd <= 0) { - perror("Error when writting application EUI to LoRaWAN module"); + perror("Error when writing application EUI to LoRaWAN module"); goto END_UART_LORAWAN_MODULE_INIT; } @@ -342,7 +342,7 @@ void lorawan_radioenge_init(config_lorawan_radioenge_t config_lorawan) if (bytes_written_at_cmd <= 0) { - perror("Error when writting application session key" + perror("Error when writing application session key" "to LoRaWAN module"); goto END_UART_LORAWAN_MODULE_INIT; } @@ -361,7 +361,7 @@ void lorawan_radioenge_init(config_lorawan_radioenge_t config_lorawan) if (bytes_written_at_cmd <= 0) { - perror("Error when writting network session key" + perror("Error when writing network session key" "to LoRaWAN module"); goto END_UART_LORAWAN_MODULE_INIT; } @@ -379,7 +379,7 @@ void lorawan_radioenge_init(config_lorawan_radioenge_t config_lorawan) if (bytes_written_at_cmd <= 0) { - perror("Error when writting ADR configuration to LoRaWAN module"); + perror("Error when writing ADR configuration to LoRaWAN module"); goto END_UART_LORAWAN_MODULE_INIT; } @@ -396,7 +396,7 @@ void lorawan_radioenge_init(config_lorawan_radioenge_t config_lorawan) if (bytes_written_at_cmd <= 0) { - perror("Error when writting DR configuration to LoRaWAN module"); + perror("Error when writing DR configuration to LoRaWAN module"); goto END_UART_LORAWAN_MODULE_INIT; } @@ -413,7 +413,7 @@ void lorawan_radioenge_init(config_lorawan_radioenge_t config_lorawan) if (bytes_written_at_cmd <= 0) { - perror("Error when writting LoRaWAN class to LoRaWAN module"); + perror("Error when writing LoRaWAN class to LoRaWAN module"); goto END_UART_LORAWAN_MODULE_INIT; } @@ -430,7 +430,7 @@ void lorawan_radioenge_init(config_lorawan_radioenge_t config_lorawan) if (bytes_written_at_cmd <= 0) { - perror("Error when writting send confirmation to LoRaWAN module"); + perror("Error when writing send confirmation to LoRaWAN module"); } sleep(TIME_BETWEEN_AT_CMDS); @@ -501,7 +501,7 @@ int lorawan_radioenge_send_msg(unsigned char * pt_uplink_hexstring, max_size_downlink, time_to_wait_ms); - /* If a AT_BUSY is received as command responde, command must + /* If a AT_BUSY is received as command response, command must * be sent again */ diff --git a/system/resmonitor/fillcpu.c b/system/resmonitor/fillcpu.c index b8e187ea8..28e6dab85 100644 --- a/system/resmonitor/fillcpu.c +++ b/system/resmonitor/fillcpu.c @@ -74,6 +74,7 @@ static float get_cpu(int pid) float cpu = 0; char filepath[20]; int ret; + if (pid <= 0) { ret = snprintf(filepath, 20, "%s/%s", PATH, CPULOAD); @@ -91,12 +92,14 @@ static float get_cpu(int pid) } FILE *fp = fopen(filepath, "r"); + if (!fp) { return cpu; } char buf[8]; + if (fgets(buf, 8, fp) != NULL) { sscanf(buf, "%f", &cpu); @@ -117,6 +120,7 @@ static int writefile(char *filepath, char *buffer1, char *buffer2) else { int fd; + memset(buffer1, '*', 1024); if ((fd = open(filepath, O_WRONLY | O_CREAT, 0700)) <= 0) { diff --git a/system/resmonitor/showinfo.c b/system/resmonitor/showinfo.c index 774f8fd22..bf2de6544 100644 --- a/system/resmonitor/showinfo.c +++ b/system/resmonitor/showinfo.c @@ -107,6 +107,7 @@ static void get_cpu(int pid, char *buf) { char filepath[FILELEN]; int ret; + if (pid <= 0) { ret = snprintf(filepath, FILELEN, "%s/%s", PATH, CPULOAD); @@ -125,6 +126,7 @@ static void get_cpu(int pid, char *buf) } FILE *fp = fopen(filepath, "r"); + if (!fp) { snprintf(buf, 8, "%.1f%%", 0.0); @@ -153,10 +155,12 @@ static void add_cpu(char *a, char *b, char *buf) float fa = 0; float fb = 0; + sscanf(a, "%f", &fa); sscanf(b, "%f", &fb); float sum = fa + fb; int ret = snprintf(buf, 8, "%.1f%%", sum); + if (ret < 0) { syslog(LOG_ERR, "add_cpu error\n"); @@ -168,23 +172,27 @@ static unsigned long get_heap(int pid) unsigned long heap = 0; char filepath[FILELEN]; int ret = snprintf(filepath, FILELEN, "%s/%d/%s", PATH, pid, HEAP); + if (ret < 0) { return heap; } FILE *fp = fopen(filepath, "r"); + if (!fp) { return heap; } char buf[25]; + while (fgets(buf, 25, fp) != NULL) { if (strstr(buf, "AllocSize")) { int idx = strcspn(buf, "0123456789"); + heap = strtoul(&buf[idx], NULL, 10); break; } @@ -199,23 +207,27 @@ static unsigned long get_stack(int pid) unsigned long stack = 0; char filepath[FILELEN]; int ret = snprintf(filepath, FILELEN, "%s/%d/%s", PATH, pid, STACK); + if (ret < 0) { return stack; } FILE *fp = fopen(filepath, "r"); + if (!fp) { return stack; } char buf[25]; + while (fgets(buf, 25, fp) != NULL) { if (strstr(buf, "StackUsed")) { int idx = strcspn(buf, "0123456789"); + stack = strtoul(&buf[idx], NULL, 10); break; } @@ -229,6 +241,7 @@ static int get_total_info(struct t_info *t_info) { memset(t_info, 0, sizeof(struct t_info)); struct mallinfo g_alloc_info = mallinfo(); + t_info->mem_total = g_alloc_info.arena; t_info->mem_used = g_alloc_info.uordblks; t_info->mem_free = g_alloc_info.fordblks; @@ -253,28 +266,33 @@ static int get_pid_info(struct p_info *p_info, int pid, bool all) { char filepath[FILELEN]; int ret = snprintf(filepath, FILELEN, "%s/%d/%s", PATH, pid, GROUP); + if (ret < 0) { return -1; } FILE *fp = fopen(filepath, "r"); + if (!fp) { return -1; } char buf[100]; + while (fgets(buf, 100, fp) != NULL) { if (strstr(buf, "Member IDs")) { int idx = strcspn(buf, ":"); char *p = strtok(&buf[idx], " "); + while ((p = strtok(NULL, " ")) != NULL) { int gpid = strtoul(p, NULL, 10); char gcpu[8] = "0.0%%"; + if (gpid > 0) { get_cpu(gpid, gcpu); @@ -303,10 +321,12 @@ print_result(struct t_info *t_info, struct p_info *p_info, char *logpath) time_t rawtime = 0; struct tm info; char date[30]; + time(&rawtime); localtime_r(&rawtime, &info); strftime(date, 30, "[%Y-%m-%d %H:%M:%S] ", &info); FILE *f; + if ((f = fopen(logpath, "a+")) != NULL) { if (p_head == 1) @@ -448,6 +468,7 @@ static void transfer(uintmax_t value, char *res, int len) if (value > 1024 * 1024) { int ret = snprintf(res, len, "%ju", value / 1024 / 1024); + if (ret < 0) { return; @@ -458,6 +479,7 @@ static void transfer(uintmax_t value, char *res, int len) else if (value > 1024) { int ret = snprintf(res, len, "%ju", value / 1024); + if (ret < 0) { return; @@ -468,6 +490,7 @@ static void transfer(uintmax_t value, char *res, int len) else { int ret = snprintf(res, len, "%ju", value); + if (ret < 0) { return; @@ -481,6 +504,7 @@ static void print_diskinfo(char *path, char *logpath) { struct statfs diskinfo; int ret = statfs(path, &diskinfo); + if (ret != 0) { syslog(LOG_ERR, "statfs fail!\n"); @@ -495,6 +519,7 @@ static void print_diskinfo(char *path, char *logpath) uintmax_t bavail = (uintmax_t)diskinfo.f_bavail; uintmax_t blocks = (uintmax_t)diskinfo.f_blocks; uintmax_t bfree = (uintmax_t)diskinfo.f_bfree; + transfer(bsize * blocks, c_tsize, 20); transfer(bsize * bavail, c_asize, 20); transfer(bsize * bfree, c_fsize, 20); @@ -504,10 +529,12 @@ static void print_diskinfo(char *path, char *logpath) time_t rawtime = 0; struct tm info; char date[30]; + time(&rawtime); localtime_r(&rawtime, &info); strftime(date, 30, "[%Y-%m-%d %H:%M:%S] ", &info); FILE *f; + if ((f = fopen(logpath, "a+")) != NULL) { if (d_head == 1) diff --git a/system/tcpdump/tcpdump.c b/system/tcpdump/tcpdump.c index 5f80ef510..b7d96fc71 100644 --- a/system/tcpdump/tcpdump.c +++ b/system/tcpdump/tcpdump.c @@ -223,6 +223,7 @@ static uint32_t get_linktype(FAR const char *ifname) struct ifreq req; uint32_t ret = LINKTYPE_RAW; int sockfd = socket(NET_SOCK_FAMILY, NET_SOCK_TYPE, NET_SOCK_PROTOCOL); + if (sockfd >= 0) { strlcpy(req.ifr_name, ifname, IFNAMSIZ); diff --git a/testing/drivers/drivertest/drivertest_i2c_read.c b/testing/drivers/drivertest/drivertest_i2c_read.c index 5b13b3c5e..ce0c812a7 100644 --- a/testing/drivers/drivertest/drivertest_i2c_read.c +++ b/testing/drivers/drivertest/drivertest_i2c_read.c @@ -148,15 +148,15 @@ static void parse_commandline(FAR struct i2c_state_s *i2c_state, break; case 4: - converted = atoi(argv[4]); - if (converted < 1 || converted > INT_MAX) - { - printf("signal out of range: %d\n", converted); - show_usage(argv[4], i2c_state, EXIT_FAILURE); - } + converted = atoi(argv[4]); + if (converted < 1 || converted > INT_MAX) + { + printf("signal out of range: %d\n", converted); + show_usage(argv[4], i2c_state, EXIT_FAILURE); + } - i2c_state->addr = (uint16_t)converted; - break; + i2c_state->addr = (uint16_t)converted; + break; default: printf("input error parameter\n"); @@ -275,6 +275,7 @@ static FAR void *slave_write_thread(FAR void *arg) while (true) { int n = poll(&rfds, 1, -1); + if (n == 0) { printf("time out\n"); @@ -319,6 +320,7 @@ int main(int argc, FAR char *argv[]) { pthread_t t_id1; pthread_t t_id2; + if (argc != 5) { printf("Error input\n"); diff --git a/testing/drivers/drivertest/drivertest_uart.c b/testing/drivers/drivertest/drivertest_uart.c index 247143861..41ac4cb72 100644 --- a/testing/drivers/drivertest/drivertest_uart.c +++ b/testing/drivers/drivertest/drivertest_uart.c @@ -174,6 +174,7 @@ static int setup(FAR void **state) FAR struct test_state_s *test_state = malloc(sizeof(struct test_state_s)); struct termios ti; int ret = 0; + assert_true(test_state != NULL); test_state->dev_path = confs->dev_path; @@ -243,6 +244,7 @@ static void drivertest_uart_read(FAR void **state) size_t buffer_size = sizeof(DEFAULT_CONTENT); int cnt = 0; FAR char *buffer = test_state->buffer; + assert_true(buffer != NULL); buffer[buffer_size - 1] = '\0'; @@ -379,17 +381,17 @@ int main(int argc, FAR char *argv[]) parse_args(argc, argv, &confs); switch (confs.test_case_id) - { - case 1: - drivertest_uart = drivertest_uart_read; - break; - case 2: - drivertest_uart = drivertest_uart_burst; - break; - default: - drivertest_uart = drivertest_uart_write; - break; - } + { + case 1: + drivertest_uart = drivertest_uart_read; + break; + case 2: + drivertest_uart = drivertest_uart_burst; + break; + default: + drivertest_uart = drivertest_uart_write; + break; + } const struct CMUnitTest tests[] = { diff --git a/testing/drivers/sd_stress/sd_stress_main.c b/testing/drivers/sd_stress/sd_stress_main.c index dffdd16c5..21a52e11d 100644 --- a/testing/drivers/sd_stress/sd_stress_main.c +++ b/testing/drivers/sd_stress/sd_stress_main.c @@ -214,6 +214,7 @@ static bool create_files(const char *dir, const char *name, size_t num_files, char *bytes, size_t num_bytes) { bool passed = true; + if (num_files > 999) { printf("too many files\n"); @@ -240,6 +241,7 @@ static bool create_files(const char *dir, const char *name, for (size_t i = 0; i < num_files; ++i) { char path[MAX_PATH_LEN]; + snprintf(path, MAX_PATH_LEN, "%s/%s%03zu", dir, name, i); memset(read_bytes, 0x0, num_bytes); @@ -339,6 +341,7 @@ static bool remove_files(const char *dir, const char *name, for (size_t i = 0; i < num_files; ++i) { char path[MAX_PATH_LEN]; + snprintf(path, MAX_PATH_LEN, "%s/%s%03zu", dir, name, i); int ret = unlink(path); @@ -371,6 +374,7 @@ static bool rename_dir(const char *old_dir, const char *new_dir) static struct timespec get_abs_time(void) { struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); return ts; } @@ -379,6 +383,7 @@ static uint64_t get_time_delta(const struct timespec *start, const struct timespec *end) { uint64_t elapsed; + elapsed = (end->tv_sec * NSEC_PER_SEC) + end->tv_nsec; elapsed -= (start->tv_sec * NSEC_PER_SEC) + start->tv_nsec; return elapsed / 1000; @@ -387,6 +392,7 @@ static uint64_t get_time_delta(const struct timespec *start, static float get_elapsed_time_ms(const struct timespec *start) { struct timespec now = get_abs_time(); + return get_time_delta(start, &now) / (float)USEC_PER_MSEC; } @@ -410,22 +416,22 @@ int main(int argc, char *argv[]) { switch (ch) { - case 'r': - num_runs = strtol(optarg, NULL, 0); - break; - - case 'b': - num_bytes = strtol(optarg, NULL, 0); - break; - - case 'f': - num_files = strtol(optarg, NULL, 0); - break; - - default: - usage(); - return -1; - break; + case 'r': + num_runs = strtol(optarg, NULL, 0); + break; + + case 'b': + num_bytes = strtol(optarg, NULL, 0); + break; + + case 'f': + num_files = strtol(optarg, NULL, 0); + break; + + default: + usage(); + return -1; + break; } } diff --git a/testing/drivers/setest/setest.c b/testing/drivers/setest/setest.c index ed2cb2b7f..fea5b23c2 100644 --- a/testing/drivers/setest/setest.c +++ b/testing/drivers/setest/setest.c @@ -156,8 +156,9 @@ static int run_tests(int fd, FAR struct settings_t *settings) for (uint32_t id = get_se05x_id(settings, 1); (id < get_se05x_id(settings, 4)) && (result == 0); id++) { - struct se05x_generate_keypair_s args = { - .id = id, .cipher = SE05X_ASYM_CIPHER_EC_NIST_P_256 + struct se05x_generate_keypair_s args = + { + .id = id, .cipher = SE05X_ASYM_CIPHER_EC_NIST_P_256 }; result = ioctl(fd, SEIOC_GENERATE_KEYPAIR, &args); @@ -172,11 +173,18 @@ static int run_tests(int fd, FAR struct settings_t *settings) { puts("Read from pub #1"); - struct se05x_key_transmission_s args = { - .entry = {.id = get_se05x_id(settings, 1), - .cipher = SE05X_ASYM_CIPHER_EC_NIST_P_256}, - .content = {.buffer = public_key, - .buffer_size = sizeof(public_key)} + struct se05x_key_transmission_s args = + { + .entry = + { + .id = get_se05x_id(settings, 1), + .cipher = SE05X_ASYM_CIPHER_EC_NIST_P_256 + }, + .content = + { + .buffer = public_key, + .buffer_size = sizeof(public_key) + } }; result = ioctl(fd, SEIOC_GET_KEY, &args); @@ -190,12 +198,19 @@ static int run_tests(int fd, FAR struct settings_t *settings) { puts("Write to pub #4"); - struct se05x_key_transmission_s args = { - .entry = {.id = get_se05x_id(settings, 4), - .cipher = SE05X_ASYM_CIPHER_EC_NIST_P_256}, - .content = {.buffer = public_key, - .buffer_size = public_key_size, - .buffer_content_size = public_key_size} + struct se05x_key_transmission_s args = + { + .entry = + { + .id = get_se05x_id(settings, 4), + .cipher = SE05X_ASYM_CIPHER_EC_NIST_P_256 + }, + .content = + { + .buffer = public_key, + .buffer_size = public_key_size, + .buffer_content_size = public_key_size + } }; result = ioctl(fd, SEIOC_SET_KEY, &args); @@ -203,10 +218,11 @@ static int run_tests(int fd, FAR struct settings_t *settings) print_result(result == 0); } - uint8_t hash[32] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 + uint8_t hash[32] = + { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 }; uint8_t signature[300]; @@ -216,14 +232,21 @@ static int run_tests(int fd, FAR struct settings_t *settings) { puts("Create signature with priv #1"); - struct se05x_signature_s args = { - .key_id = get_se05x_id(settings, 1), - .algorithm = SE05X_ALGORITHM_SHA256, - .tbs = {.buffer = hash, - .buffer_size = sizeof(hash), - .buffer_content_size = sizeof(hash)}, - .signature = {.buffer = signature, - .buffer_size = sizeof(signature)}, + struct se05x_signature_s args = + { + .key_id = get_se05x_id(settings, 1), + .algorithm = SE05X_ALGORITHM_SHA256, + .tbs = + { + .buffer = hash, + .buffer_size = sizeof(hash), + .buffer_content_size = sizeof(hash) + }, + .signature = + { + .buffer = signature, + .buffer_size = sizeof(signature) + }, }; result = ioctl(fd, SEIOC_CREATE_SIGNATURE, &args); @@ -235,14 +258,21 @@ static int run_tests(int fd, FAR struct settings_t *settings) { puts("Verify signature with pub #4"); - struct se05x_signature_s args = { - .key_id = get_se05x_id(settings, 4), - .algorithm = SE05X_ALGORITHM_SHA256, - .tbs = {.buffer = hash, - .buffer_size = sizeof(hash), - .buffer_content_size = sizeof(hash)}, - .signature = {.buffer = signature, - .buffer_content_size = signature_content_size}, + struct se05x_signature_s args = + { + .key_id = get_se05x_id(settings, 4), + .algorithm = SE05X_ALGORITHM_SHA256, + .tbs = + { + .buffer = hash, + .buffer_size = sizeof(hash), + .buffer_content_size = sizeof(hash) + }, + .signature = + { + .buffer = signature, + .buffer_content_size = signature_content_size + }, }; result = ioctl(fd, SEIOC_VERIFY_SIGNATURE, &args); @@ -254,12 +284,19 @@ static int run_tests(int fd, FAR struct settings_t *settings) { puts("Verification of signature with pub #2 should be dissapproved"); - struct se05x_signature_s args = { - .key_id = get_se05x_id(settings, 2), - .algorithm = SE05X_ALGORITHM_SHA256, - .tbs = {.buffer = hash, .buffer_size = sizeof(hash)}, - .signature = {.buffer = signature, - .buffer_content_size = signature_content_size}, + struct se05x_signature_s args = + { + .key_id = get_se05x_id(settings, 2), + .algorithm = SE05X_ALGORITHM_SHA256, + .tbs = + { + .buffer = hash, .buffer_size = sizeof(hash) + }, + .signature = + { + .buffer = signature, + .buffer_content_size = signature_content_size + }, }; result = invert_result(ioctl(fd, SEIOC_VERIFY_SIGNATURE, &args)); @@ -273,11 +310,15 @@ static int run_tests(int fd, FAR struct settings_t *settings) { puts("Derive symm key #a from priv #1 and pub #2"); - struct se05x_derive_key_s args = { - .private_key_id = get_se05x_id(settings, 1), - .public_key_id = get_se05x_id(settings, 2), - .content = {.buffer = symm_key_a, - .buffer_size = sizeof(symm_key_a)}, + struct se05x_derive_key_s args = + { + .private_key_id = get_se05x_id(settings, 1), + .public_key_id = get_se05x_id(settings, 2), + .content = + { + .buffer = symm_key_a, + .buffer_size = sizeof(symm_key_a) + }, }; result = ioctl(fd, SEIOC_DERIVE_SYMM_KEY, &args); @@ -291,11 +332,15 @@ static int run_tests(int fd, FAR struct settings_t *settings) { puts("Derive symm key #b from priv #2 and pub #1"); - struct se05x_derive_key_s args = { - .private_key_id = get_se05x_id(settings, 2), - .public_key_id = get_se05x_id(settings, 1), - .content = {.buffer = symm_key_b, - .buffer_size = sizeof(symm_key_b)}, + struct se05x_derive_key_s args = + { + .private_key_id = get_se05x_id(settings, 2), + .public_key_id = get_se05x_id(settings, 1), + .content = + { + .buffer = symm_key_b, + .buffer_size = sizeof(symm_key_b) + }, }; result = ioctl(fd, SEIOC_DERIVE_SYMM_KEY, &args); @@ -309,11 +354,15 @@ static int run_tests(int fd, FAR struct settings_t *settings) { puts("Derive symm key #c from priv #1 and pub #3"); - struct se05x_derive_key_s args = { - .private_key_id = get_se05x_id(settings, 1), - .public_key_id = get_se05x_id(settings, 3), - .content = {.buffer = symm_key_c, - .buffer_size = sizeof(symm_key_c)}, + struct se05x_derive_key_s args = + { + .private_key_id = get_se05x_id(settings, 1), + .public_key_id = get_se05x_id(settings, 3), + .content = + { + .buffer = symm_key_c, + .buffer_size = sizeof(symm_key_c) + }, }; result = ioctl(fd, SEIOC_DERIVE_SYMM_KEY, &args); diff --git a/testing/ostest/pthread_cleanup.c b/testing/ostest/pthread_cleanup.c index 00a6b91d4..774733ba7 100644 --- a/testing/ostest/pthread_cleanup.c +++ b/testing/ostest/pthread_cleanup.c @@ -109,7 +109,8 @@ static void test_cleanup(void) pthread_t thread1; int status; void *result; - struct sync_s sync = { + struct sync_s sync = + { PTHREAD_COND_INITIALIZER, PTHREAD_MUTEX_INITIALIZER }; diff --git a/testing/ostest/pthread_rwlock_cancel.c b/testing/ostest/pthread_rwlock_cancel.c index ab8e84c0c..7a99e8865 100644 --- a/testing/ostest/pthread_rwlock_cancel.c +++ b/testing/ostest/pthread_rwlock_cancel.c @@ -258,8 +258,8 @@ static void test_timeout(void) } #endif /* CONFIG_TLS_NCLEANUP > 0 && CONFIG_CANCELLATION_POINTS */ - pthread_rwlock_destroy(&write_lock); - pthread_rwlock_destroy(&read_lock); + pthread_rwlock_destroy(&write_lock); + pthread_rwlock_destroy(&read_lock); } /****************************************************************************
