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 4cf2c81817f150a475d27787ecb20f222376f5bc Author: Marco Casaroli <[email protected]> AuthorDate: Mon Oct 12 08:44:17 2026 +0200 apps: Fix the nxstyle errors in the files that the next commit changes. The next commit adds includes to these files, and checkpatch checks each changed file as a whole. So fix their old nxstyle errors first: the indentation of case labels and other lines, blank lines after declarations, a long comment, and a long string (split in two, with the same output). Only the layout changes. codespell also checks the whole files: fix "Types" and "transfer" in sb_main.c, "corresponds" in hx711_main.c and "primitive" in i8sak_acceptassoc.c, and add the path line of testing/drivers/ser/ser.c to .codespell-ignore-lines ("ser" is not a typo there). Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- .codespell-ignore-lines | 1 + boot/nxboot/loader/boot.c | 5 +- examples/audio_rttl/audio_rttl_main.c | 27 ++-- examples/fbcon/fbcon_main.c | 80 ++++++----- examples/hx711/hx711_main.c | 70 +++++----- examples/mqttc/mqttc_pub.c | 4 +- examples/nimble_blecent/nimble_blecent_main.c | 4 +- examples/nxterm/nxterm_main.c | 2 +- examples/watched/watched.c | 4 + fsutils/passwd/passwd_delete.c | 11 +- netutils/netlib/netlib_ip6tables.c | 4 + netutils/netlib/netlib_iptables.c | 4 + netutils/plcatool/plcatool.c | 20 ++- system/iptables/ip6tables.c | 2 + system/iptables/iptables.c | 1 + system/nxdiag/nxdiag.c | 1 + system/ofloader/ofloader.c | 2 + system/sensorscope/sensorscope_main.c | 2 + system/ymodem/rb_main.c | 5 +- system/ymodem/sb_main.c | 6 +- testing/drivers/drivertest/drivertest_block.c | 2 + testing/drivers/drivertest/drivertest_i2c_spi.c | 2 + testing/drivers/drivertest/drivertest_pm_smp.c | 7 + testing/drivers/pcitest/pcitest.c | 171 ++++++++++++------------ testing/drivers/ser/ser.c | 2 +- testing/drivers/setest/setest.c | 30 +++-- testing/fs/fdsantest/fdsantest_simple.c | 2 + testing/mm/cachetest/cachetest_main.c | 2 + wireless/ieee802154/i8sak/i8sak_acceptassoc.c | 2 +- 29 files changed, 277 insertions(+), 198 deletions(-) diff --git a/.codespell-ignore-lines b/.codespell-ignore-lines index 5902decae..11d7d038b 100644 --- a/.codespell-ignore-lines +++ b/.codespell-ignore-lines @@ -14,3 +14,4 @@ MUSIC("messag"), MUSIC("count2"), MUSIC("ddtbl3"), MUSIC("ampie"), MUSIC("tense"), MUSIC("shawn3"), MUSIC("openin"), MUSIC("evil"), /* ANS service */ + * apps/testing/drivers/ser/ser.c diff --git a/boot/nxboot/loader/boot.c b/boot/nxboot/loader/boot.c index c4f936d23..54ac92678 100644 --- a/boot/nxboot/loader/boot.c +++ b/boot/nxboot/loader/boot.c @@ -55,6 +55,7 @@ static inline void get_image_header(int fd, struct nxboot_img_header *header) { int ret; + ret = flash_partition_read(fd, header, sizeof *header, 0); if (ret < 0) { @@ -257,6 +258,7 @@ static bool compare_versions(struct nxboot_img_version *v1, { #ifndef CONFIG_NXBOOT_PREVENT_DOWNGRADE int i; + if (v1->major != v2->major || v1->minor != v2->minor || v1->patch != v2->patch) @@ -301,6 +303,7 @@ static enum nxboot_update_type { nxboot_progress(nxboot_progress_start, validate_primary); bool primary_valid = validate_image(primary); + nxboot_progress(nxboot_progress_end); nxboot_progress(nxboot_progress_start, validate_update); @@ -314,7 +317,7 @@ static enum nxboot_update_type return NXBOOT_UPDATE_TYPE_UPDATE; } - flash_partition_erase_first_sector(update); + flash_partition_erase_first_sector(update); } nxboot_progress(nxboot_progress_end); diff --git a/examples/audio_rttl/audio_rttl_main.c b/examples/audio_rttl/audio_rttl_main.c index 5e9e7e960..4c0389bd7 100644 --- a/examples/audio_rttl/audio_rttl_main.c +++ b/examples/audio_rttl/audio_rttl_main.c @@ -171,6 +171,7 @@ static void play_pwm(struct rtttl_tone sound) static void teardown_pwm(void) { int fd = *((int *)g_player.arg); + close(fd); } #endif /* CONFIG_PWM */ @@ -215,19 +216,19 @@ int main(int argc, FAR char *argv[]) { switch (c) { - case 'h': - print_usage(stdout); - break; - case 's': - song = optarg; - break; - case 'f': - file = optarg; - break; - case '?': - fprintf(stderr, "Unknown option -%c\n", optopt); - print_usage(stderr); - return EXIT_FAILURE; + case 'h': + print_usage(stdout); + break; + case 's': + song = optarg; + break; + case 'f': + file = optarg; + break; + case '?': + fprintf(stderr, "Unknown option -%c\n", optopt); + print_usage(stderr); + return EXIT_FAILURE; } } diff --git a/examples/fbcon/fbcon_main.c b/examples/fbcon/fbcon_main.c index 7736d36e6..40edc91f8 100644 --- a/examples/fbcon/fbcon_main.c +++ b/examples/fbcon/fbcon_main.c @@ -828,7 +828,7 @@ static void fbcon_freeglyph(FAR struct fbcon_glyph_s *glyph) free(glyph->bitmap); } - memset(glyph, 0, sizeof(struct fbcon_glyph_s)); + memset(glyph, 0, sizeof(struct fbcon_glyph_s)); } /**************************************************************************** @@ -937,13 +937,14 @@ static FAR struct fbcon_glyph_s * for (i = 0; i < st->maxglyphs; i++) { FAR struct fbcon_glyph_s *glyph = &st->glyph[i]; + if (glyph->usecnt > 0 && glyph->code == ch) { /* Increment the use count (unless it is already at the max) */ if (glyph->usecnt < MAX_USECNT) { - glyph->usecnt++; + glyph->usecnt++; } /* And return the glyph that we found */ @@ -1929,56 +1930,56 @@ static void fbcon_write(FAR struct fbcon_state_s *st, fbcon_putc(st, (uint8_t)ch); } - break; + break; - /* The full VT100 escape sequence was processed (and the new - * character was consumed) - */ + /* The full VT100 escape sequence was processed (and the new + * character was consumed) + */ - case VT100_PROCESSED: + case VT100_PROCESSED: - /* Character was consumed as part of the VT100 escape processing - * (but the escape sequence is still incomplete. - */ + /* Character was consumed as part of the VT100 escape + * processing (but the escape sequence is still incomplete. + */ - case VT100_CONSUMED: - { - /* Do nothing... the VT100 logic owns the character */ - } - break; + case VT100_CONSUMED: + { + /* Do nothing... the VT100 logic owns the character */ + } + break; - /* Invalid/unsupported character in escape sequence */ + /* Invalid/unsupported character in escape sequence */ - case VT100_ABORT: - { - int i; + case VT100_ABORT: + { + int i; - /* Add the first unhandled character to the window */ + /* Add the first unhandled character to the window */ - fbcon_putc(st, (uint8_t)st->seq[0]); + fbcon_putc(st, (uint8_t)st->seq[0]); - /* Move all buffer characters down one */ + /* Move all buffer characters down one */ - for (i = 1; i < st->nseq; i++) - { - st->seq[i - 1] = st->seq[i]; - } + for (i = 1; i < st->nseq; i++) + { + st->seq[i - 1] = st->seq[i]; + } - st->nseq--; + st->nseq--; - /* Then loop again and check if what remains is part of a - * VT100 escape sequence. We could speed this up by - * checking if st->seq[0] == ASCII_ESC. - */ - } - break; + /* Then loop again and check if what remains is part of a + * VT100 escape sequence. We could speed this up by + * checking if st->seq[0] == ASCII_ESC. + */ + } + break; } } while (state == VT100_ABORT); #else - /* Just output the character */ + /* Just output the character */ - fbcon_putc(st, ch); + fbcon_putc(st, ch); #endif /* CONFIG_EXAMPLES_FBCON_VT100_DECODE */ } @@ -2006,6 +2007,7 @@ static int fbdev_get_pinfo(int fd, FAR struct fb_planeinfo_s *pinfo) if (ioctl(fd, FBIOGET_PLANEINFO, (unsigned long)((uintptr_t)pinfo)) < 0) { int errcode = errno; + gerr("ERROR: ioctl(FBIOGET_PLANEINFO) failed: %d\n", errcode); return EXIT_FAILURE; } @@ -2223,6 +2225,7 @@ static bool has_input(int fd) /* Poll the File Descriptor for input */ struct pollfd fdp; + fdp.fd = fd; fdp.events = POLLIN; ret = poll(&fdp, /* File Descriptors */ @@ -2330,6 +2333,7 @@ static void poll_std_streams(FAR struct fbcon_state_s *st) ssize_t num = 0; char ch; + num_ch = read(STDIN_FILENO, &ch, 1); if (num_ch != 1) @@ -2427,6 +2431,7 @@ int main(int argc, FAR char *argv[]) if (st->fd_fb < 0) { int errcode = errno; + gerr("ERROR: Failed to open %s: %d\n", fbdev, errcode); return FBCON_EXIT_FD; } @@ -2438,6 +2443,7 @@ int main(int argc, FAR char *argv[]) if (ret < 0) { int errcode = errno; + fprintf(stderr, "ERROR: ioctl(FBIOGET_VIDEOINFO) failed: %d\n", errcode); exitcode = FBCON_EXIT_GETVINFO; @@ -2453,6 +2459,7 @@ int main(int argc, FAR char *argv[]) if (ret < 0) { int errcode = errno; + gerr("ERROR: ioctl(FBIO_SELECT_OVERLAY) failed: %d\n", errcode); ret = FBCON_EXIT_FBIO_SELECT_OVERLAY goto errout; @@ -2466,6 +2473,7 @@ int main(int argc, FAR char *argv[]) if (ret < 0) { int errcode = errno; + gerr("ERROR: ioctl(FBIOGET_OVERLAYINFO) failed: %d\n", errcode); ret = FBCON_EXIT_FBIO_OVERLAY_INFO goto errout; @@ -2477,6 +2485,7 @@ int main(int argc, FAR char *argv[]) if (ret < 0) { int errcode = errno; + gerr("ERROR: ioctl(FBIO_SELECT_OVERLAY) failed: %d\n", errcode); ret = FBCON_EXIT_FBIO_SELECT_OVERLAY goto errout; @@ -2641,6 +2650,7 @@ int main(int argc, FAR char *argv[]) if (ret < 0) { int errcode = errno; + gerr("ERROR: posix_spawn failed: %d\n", errcode); exitcode = FBCON_EXIT_POSIX_SPAWN_FAILED; } diff --git a/examples/hx711/hx711_main.c b/examples/hx711/hx711_main.c index 3e9f1755c..28258dc5d 100644 --- a/examples/hx711/hx711_main.c +++ b/examples/hx711/hx711_main.c @@ -74,7 +74,7 @@ static void hx711_print_help(const char *progname) "\t If you set value per unit, precision is in units, " "otherwise it's raw values.\n" "\t If units are used, float can be passed like 0.1\n" - "\t-v<val> value read that coresponds to one unit. This value " + "\t-v<val> value read that corresponds to one unit. This value " "has to be\n" "\t calibrated first before it's known\n" "\t-s reverse sign, if values decreses when mass increases, " @@ -113,49 +113,49 @@ static int hx711_parse_args(int argc, FAR char *argv[]) { switch (opt) { - case 'h': - hx711_print_help(argv[0]); - return 1; + case 'h': + hx711_print_help(argv[0]); + return 1; - case 'd': - strcpy(g_hx711_config.dev, optarg); - break; + case 'd': + strcpy(g_hx711_config.dev, optarg); + break; - case 't': - g_hx711_config.precision = atof(optarg); - break; + case 't': + g_hx711_config.precision = atof(optarg); + break; - case 'D': - g_hx711_config.dump = 1; - break; + case 'D': + g_hx711_config.dump = 1; + break; - case 'a': - g_hx711_config.average = atoi(optarg); - break; + case 'a': + g_hx711_config.average = atoi(optarg); + break; - case 'c': - g_hx711_config.channel = optarg[0]; - break; + case 'c': + g_hx711_config.channel = optarg[0]; + break; - case 'g': - g_hx711_config.gain = atoi(optarg); - break; + case 'g': + g_hx711_config.gain = atoi(optarg); + break; - case 'r': - g_hx711_config.loops = atoi(optarg); - break; + case 'r': + g_hx711_config.loops = atoi(optarg); + break; - case 's': - g_hx711_config.sign = -1; - break; + case 's': + g_hx711_config.sign = -1; + break; - case 'v': - g_hx711_config.val_per_unit = atoi(optarg); - break; + case 'v': + g_hx711_config.val_per_unit = atoi(optarg); + break; - default: - fprintf(stderr, "Invalid option, run with -h for help\n"); - return 1; + default: + fprintf(stderr, "Invalid option, run with -h for help\n"); + return 1; } } @@ -230,7 +230,7 @@ int hx711_set_options(int fd) } } - /* Set what value coresponds to 1 unit */ + /* Set what value corresponds to 1 unit */ if (g_hx711_config.val_per_unit > 0) { diff --git a/examples/mqttc/mqttc_pub.c b/examples/mqttc/mqttc_pub.c index d979fb24a..0e5999599 100644 --- a/examples/mqttc/mqttc_pub.c +++ b/examples/mqttc/mqttc_pub.c @@ -175,7 +175,7 @@ static void parsearg(int argc, FAR char *argv[], case 2L: cfg->qos = MQTT_PUBLISH_QOS_2; break; - } + } break; #ifdef MQTT_USE_MBEDTLS @@ -304,6 +304,7 @@ static int init_conn(FAR const struct mqttc_cfg_s *cfg, for (; ; ) { uint32_t want = 0; + ret = mbedtls_ssl_handshake(ssl_ctx); if (ret == MBEDTLS_ERR_SSL_WANT_READ) { @@ -346,6 +347,7 @@ static int init_conn(FAR const struct mqttc_cfg_s *cfg, const char *buf = ""; #else char buf[512]; + mbedtls_x509_crt_verify_info(buf, sizeof(buf), "\t", result); #endif printf("Certificate verification failed (%0" PRIx32 ")\n%s\n", diff --git a/examples/nimble_blecent/nimble_blecent_main.c b/examples/nimble_blecent/nimble_blecent_main.c index 5af9d2b03..1d78e6d11 100644 --- a/examples/nimble_blecent/nimble_blecent_main.c +++ b/examples/nimble_blecent/nimble_blecent_main.c @@ -511,9 +511,11 @@ static int blecent_gap_event(FAR struct ble_gap_event *event, FAR void *arg) OS_MBUF_PKTLEN(event->notify_rx.om)); uint8_t notif_data[100]; /* Size depending on the actual size of the - notification data you have */ + * notification data you have + */ uint16_t notif_len; int offset = 0; + notif_len = OS_MBUF_PKTLEN(event->notify_rx.om); os_mbuf_copydata(event->notify_rx.om, offset, notif_len, notif_data); diff --git a/examples/nxterm/nxterm_main.c b/examples/nxterm/nxterm_main.c index a2250eb4e..afe6f34ba 100644 --- a/examples/nxterm/nxterm_main.c +++ b/examples/nxterm/nxterm_main.c @@ -108,7 +108,7 @@ static int nxterm_initialize(void) g_nxterm_vars.hnx = nx_connect(); if (g_nxterm_vars.hnx) { - pthread_attr_t attr; + pthread_attr_t attr; #ifdef CONFIG_VNCSERVER /* Setup the VNC server to support keyboard/mouse inputs */ diff --git a/examples/watched/watched.c b/examples/watched/watched.c index cad7095c0..9013590a0 100644 --- a/examples/watched/watched.c +++ b/examples/watched/watched.c @@ -89,6 +89,7 @@ int watched_read_watcher_info(struct watched_info_s *info) if (fp == NULL) { int errcode = errno; + fprintf(stderr, "ERROR: Failed to open %s: %d\n", g_watcher_info.info_file_name, errcode); ret = errcode; @@ -132,6 +133,7 @@ int watched_subscribe(struct watched_info_s *info) if (ret == ERROR) { int errcode = errno; + fprintf(stderr, "subscribe: error %d\n", errcode); ret = errcode; } @@ -151,6 +153,7 @@ int watched_unsubscribe(struct watched_info_s *info) if (ret == ERROR) { int errcode = errno; + fprintf(stderr, "unsubscribe: error %d\n", errcode); ret = errcode; } @@ -170,6 +173,7 @@ int watched_feed_dog(struct watched_info_s *info) if (ret == ERROR) { int errcode = errno; + fprintf(stderr, "watched_feed_dog: error %d\n", errcode); ret = errcode; } diff --git a/fsutils/passwd/passwd_delete.c b/fsutils/passwd/passwd_delete.c index cb9562c4e..3dbc49fdd 100644 --- a/fsutils/passwd/passwd_delete.c +++ b/fsutils/passwd/passwd_delete.c @@ -98,6 +98,7 @@ static int passwd_copyfile(FAR char *iobuffer, FILE *instream, /* Read error */ int errcode = errno; + DEBUGASSERT(errcode > 0); if (errcode != EINTR) @@ -109,10 +110,10 @@ static int passwd_copyfile(FAR char *iobuffer, FILE *instream, { /* End of file encountered. * - * This occurs normally when copying to the end-of-the file. - * In that case, the caller just sticks a huge number in for - * copysize and lets the end-of-file indication terminate the - * copy. + * This occurs normally when copying to the end-of-the + * file. In that case, the caller just sticks a huge + * number in for copysize and lets the end-of-file + * indication terminate the copy. */ eof = true; @@ -154,6 +155,7 @@ static int passwd_copyfile(FAR char *iobuffer, FILE *instream, /* Write error */ int errcode = errno; + DEBUGASSERT(errcode > 0); if (errcode != EINTR) @@ -257,6 +259,7 @@ int passwd_delete(off_t offset) for (; ; ) { int ch = fgetc(instream); + if (ch == EOF) { if (feof(instream)) diff --git a/netutils/netlib/netlib_ip6tables.c b/netutils/netlib/netlib_ip6tables.c index d966e432d..564de741b 100644 --- a/netutils/netlib/netlib_ip6tables.c +++ b/netutils/netlib/netlib_ip6tables.c @@ -695,6 +695,7 @@ FAR struct ip6t_entry *netlib_ip6t_filter_entry(FAR const char *target, case 0: { FAR struct ip6t_filter_entry_s *entry = zalloc(sizeof(*entry)); + if (entry == NULL) { return NULL; @@ -708,6 +709,7 @@ FAR struct ip6t_entry *netlib_ip6t_filter_entry(FAR const char *target, case IPPROTO_TCP: { FAR struct ip6t_filter_tcp_entry_s *entry = zalloc(sizeof(*entry)); + if (entry == NULL) { return NULL; @@ -722,6 +724,7 @@ FAR struct ip6t_entry *netlib_ip6t_filter_entry(FAR const char *target, case IPPROTO_UDP: { FAR struct ip6t_filter_udp_entry_s *entry = zalloc(sizeof(*entry)); + if (entry == NULL) { return NULL; @@ -737,6 +740,7 @@ FAR struct ip6t_entry *netlib_ip6t_filter_entry(FAR const char *target, { FAR struct ip6t_filter_icmp_entry_s *entry = zalloc(sizeof(*entry)); + if (entry == NULL) { return NULL; diff --git a/netutils/netlib/netlib_iptables.c b/netutils/netlib/netlib_iptables.c index e27576a33..887c45f36 100644 --- a/netutils/netlib/netlib_iptables.c +++ b/netutils/netlib/netlib_iptables.c @@ -747,6 +747,7 @@ FAR struct ipt_entry *netlib_ipt_filter_entry(FAR const char *target, case 0: { FAR struct ipt_filter_entry_s *entry = zalloc(sizeof(*entry)); + if (entry == NULL) { return NULL; @@ -760,6 +761,7 @@ FAR struct ipt_entry *netlib_ipt_filter_entry(FAR const char *target, case IPPROTO_TCP: { FAR struct ipt_filter_tcp_entry_s *entry = zalloc(sizeof(*entry)); + if (entry == NULL) { return NULL; @@ -774,6 +776,7 @@ FAR struct ipt_entry *netlib_ipt_filter_entry(FAR const char *target, case IPPROTO_UDP: { FAR struct ipt_filter_udp_entry_s *entry = zalloc(sizeof(*entry)); + if (entry == NULL) { return NULL; @@ -788,6 +791,7 @@ FAR struct ipt_entry *netlib_ipt_filter_entry(FAR const char *target, case IPPROTO_ICMP: { FAR struct ipt_filter_icmp_entry_s *entry = zalloc(sizeof(*entry)); + if (entry == NULL) { return NULL; diff --git a/netutils/plcatool/plcatool.c b/netutils/plcatool/plcatool.c index 9d170968b..90edf2b57 100644 --- a/netutils/plcatool/plcatool.c +++ b/netutils/plcatool/plcatool.c @@ -123,6 +123,7 @@ static void plcatool_usage(bool err); static int get_num(FAR const char *str, FAR int *result) { FAR char *endptr; + *result = (int)strtol(str, &endptr, 0); if (*endptr != '\0') @@ -447,6 +448,7 @@ static int verify_support(FAR struct plcatool_cfg_s *cfg, FAR bool *supported) { uint16_t reg; + if (read_plca_mmd(cfg->ifname, cfg->phy, OA_TC14_IDVER_ADDR, ®)) { return ERROR; @@ -487,6 +489,7 @@ static int plcatool_set(FAR struct plcatool_cfg_s *cfg) if (cfg->node_cnt) { int val = PLCATOOL_CFG_VAL(cfg, node_cnt); + reg &= ~OA_TC14_CTRL1_NCNT_MASK; reg |= oa_tc14_field(val, CTRL1_NCNT); } @@ -494,6 +497,7 @@ static int plcatool_set(FAR struct plcatool_cfg_s *cfg) if (cfg->node_id) { int val = PLCATOOL_CFG_VAL(cfg, node_id); + reg &= ~OA_TC14_CTRL1_ID_MASK; reg |= oa_tc14_field(val, CTRL1_ID); } @@ -509,6 +513,7 @@ static int plcatool_set(FAR struct plcatool_cfg_s *cfg) if (cfg->to_tmr) { int val = PLCATOOL_CFG_VAL(cfg, to_tmr); + reg = oa_tc14_field(val, TOTMR_TOT); if (write_plca_mmd(cfg->ifname, cfg->phy, OA_TC14_TOTMR_ADDR, reg)) @@ -529,6 +534,7 @@ static int plcatool_set(FAR struct plcatool_cfg_s *cfg) if (cfg->burst_cnt) { int val = PLCATOOL_CFG_VAL(cfg, burst_cnt); + reg &= ~OA_TC14_BURST_MAXBC_MASK; reg |= oa_tc14_field(val, BURST_MAXBC); } @@ -536,6 +542,7 @@ static int plcatool_set(FAR struct plcatool_cfg_s *cfg) if (cfg->burst_tmr) { int val = PLCATOOL_CFG_VAL(cfg, burst_tmr); + reg &= ~OA_TC14_BURST_BTMR_MASK; reg |= oa_tc14_field(val, BURST_BTMR); } @@ -551,6 +558,7 @@ static int plcatool_set(FAR struct plcatool_cfg_s *cfg) if (cfg->enable) { int val; + if (read_plca_mmd(cfg->ifname, cfg->phy, OA_TC14_CTRL0_ADDR, ®)) { return EIO; @@ -684,9 +692,11 @@ static void plcatool_usage(bool err) int main(int argc, FAR char *argv[]) { struct plcatool_cfg_s cfg; + memset(&cfg, 0, sizeof(cfg)); int err = parse_args(argc, argv, &cfg); + if (err) { plcatool_usage(err); @@ -696,17 +706,17 @@ int main(int argc, FAR char *argv[]) switch (cfg.cmd) { case PLCA_CMD_SET: - return plcatool_set(&cfg); + return plcatool_set(&cfg); case PLCA_CMD_GET: - return plcatool_get(&cfg); + return plcatool_get(&cfg); case PLCA_CMD_STATUS: - return plcatool_status(&cfg); + return plcatool_status(&cfg); case PLCA_CMD_HELP: - plcatool_usage(false); - break; + plcatool_usage(false); + break; } return OK; diff --git a/system/iptables/ip6tables.c b/system/iptables/ip6tables.c index e29d92301..e15e26685 100644 --- a/system/iptables/ip6tables.c +++ b/system/iptables/ip6tables.c @@ -57,9 +57,11 @@ static FAR char *ip6tables_addr2str(net_ipv6addr_t addr, net_ipv6addr_t msk, FAR char *buf, size_t bufflen) { unsigned int preflen = netlib_ipv6netmask2prefix(msk); + if (preflen != 0) { char ipbuf[INET6_ADDRSTRLEN]; + inet_ntop(AF_INET6, addr, ipbuf, INET6_ADDRSTRLEN); snprintf(buf, bufflen, "%s/%d", ipbuf, preflen); } diff --git a/system/iptables/iptables.c b/system/iptables/iptables.c index 367519a34..ad0eec099 100644 --- a/system/iptables/iptables.c +++ b/system/iptables/iptables.c @@ -102,6 +102,7 @@ static FAR char *iptables_addr2str(struct in_addr addr, struct in_addr msk, FAR char *buf, size_t bufflen) { unsigned int preflen = popcount(msk.s_addr); + if (preflen != 0) { snprintf(buf, bufflen, "%s/%d", inet_ntoa(addr), preflen); diff --git a/system/nxdiag/nxdiag.c b/system/nxdiag/nxdiag.c index c10ebeca3..062cc8f56 100644 --- a/system/nxdiag/nxdiag.c +++ b/system/nxdiag/nxdiag.c @@ -256,6 +256,7 @@ int main(int argc, char *argv[]) search_str_in_arr(argc, argv, "--all")) { char hostname[HOST_NAME_MAX]; + gethostname(hostname, HOST_NAME_MAX); hostname[HOST_NAME_MAX - 1] = '\0'; diff --git a/system/ofloader/ofloader.c b/system/ofloader/ofloader.c index 6648a66b0..fe6ca12e3 100644 --- a/system/ofloader/ofloader.c +++ b/system/ofloader/ofloader.c @@ -163,6 +163,7 @@ static ssize_t read_safe(int fd, FAR uint8_t *buff, size_t size) while (i < size) { ssize_t ret = read(fd, buff + i, size - i); + if (ret < 0) { return -errno; @@ -181,6 +182,7 @@ static ssize_t write_safe(int fd, FAR uint8_t *buff, size_t size) while (i < size) { ssize_t ret = write(fd, buff + i, size - i); + if (ret < 0) { return -errno; diff --git a/system/sensorscope/sensorscope_main.c b/system/sensorscope/sensorscope_main.c index 9430ab08c..ddccf1d87 100644 --- a/system/sensorscope/sensorscope_main.c +++ b/system/sensorscope/sensorscope_main.c @@ -132,9 +132,11 @@ static void nxscope_samples_put(FAR struct nxscope_thr_env_s *envp, { #ifdef CONFIG_SENSORS_USE_B16 FAR b16_t *data = (b16_t *)&tmp->data[offset]; + nxscope_put_vb16(&envp->nxs, tmp->chanid, data, tmp->info->dim); #else FAR float *data = (float *)&tmp->data[offset]; + nxscope_put_vfloat(&envp->nxs, tmp->chanid, data, tmp->info->dim); #endif } diff --git a/system/ymodem/rb_main.c b/system/ymodem/rb_main.c index 983cc84b4..b282aa341 100644 --- a/system/ymodem/rb_main.c +++ b/system/ymodem/rb_main.c @@ -74,6 +74,7 @@ static int flush_data(FAR struct ymodem_priv_s *priv) while (i < size) { ssize_t ret = write(priv->fd, buffer + i, size - i); + if (ret < 0) { return -errno; @@ -124,6 +125,7 @@ static int write_data(FAR struct ymodem_priv_s *priv, while (i < size) { ssize_t ret = circbuf_write(&priv->circ, data + i, size - i); + if (ret < 0) { pthread_mutex_unlock(&priv->mutex); @@ -156,6 +158,7 @@ static int write_data(FAR struct ymodem_priv_s *priv, while (i < size) { ssize_t ret = write(priv->fd, data + i, size - i); + if (ret < 0) { return -errno; @@ -477,7 +480,7 @@ int main(int argc, FAR char *argv[]) goto out; } - ctx.sendfd = ctx.recvfd; + ctx.sendfd = ctx.recvfd; } else { diff --git a/system/ymodem/sb_main.c b/system/ymodem/sb_main.c index 7a5c447e4..971dac4ac 100644 --- a/system/ymodem/sb_main.c +++ b/system/ymodem/sb_main.c @@ -36,7 +36,7 @@ #include "ymodem.h" /**************************************************************************** - * Private Typess + * Private Types ****************************************************************************/ struct ymodem_priv_s @@ -284,7 +284,7 @@ static void show_usage(FAR const char *progname) "\t-r|--retry <retry>: Number of retries." "Will try <retry> times to transmitting, Default:100\n"); fprintf(stderr, - "\t-k <size>: Use a custom size to tansfer, Default: 1kB\n"); + "\t-k <size>: Use a custom size to transfer, Default: 1kB\n"); exit(EXIT_FAILURE); } @@ -359,7 +359,7 @@ int main(int argc, FAR char *argv[]) return -errno; } - ctx.sendfd = ctx.recvfd; + ctx.sendfd = ctx.recvfd; } else { diff --git a/testing/drivers/drivertest/drivertest_block.c b/testing/drivers/drivertest/drivertest_block.c index cc88a9d09..2a111ce93 100644 --- a/testing/drivers/drivertest/drivertest_block.c +++ b/testing/drivers/drivertest/drivertest_block.c @@ -127,6 +127,7 @@ static void parse_commandline(int argc, FAR char **argv, static inline char blktest_randchar(void) { int value = rand() % 63; + if (value == 0) { return '0'; @@ -155,6 +156,7 @@ static void blktest_randcontext(uint32_t size, FAR void *input) int i; FAR char *tmp; + tmp = input; for (i = 0; i < size - 1; i++) { diff --git a/testing/drivers/drivertest/drivertest_i2c_spi.c b/testing/drivers/drivertest/drivertest_i2c_spi.c index 870304325..7fc8a63d8 100644 --- a/testing/drivers/drivertest/drivertest_i2c_spi.c +++ b/testing/drivers/drivertest/drivertest_i2c_spi.c @@ -80,6 +80,7 @@ static void show_usage(FAR const char *progname, static int setup(FAR void **state) { FAR struct test_state_s *test_state; + test_state = (FAR struct test_state_s *)*state; test_state->fd = open(test_state->dev_path, O_RDONLY); assert_true(test_state->fd > 0); @@ -94,6 +95,7 @@ static int setup(FAR void **state) static int teardown(FAR void **state) { FAR struct test_state_s *test_state; + test_state = (FAR struct test_state_s *)*state; assert_int_equal(close(test_state->fd), 0); return 0; diff --git a/testing/drivers/drivertest/drivertest_pm_smp.c b/testing/drivers/drivertest/drivertest_pm_smp.c index 41115d18f..0373301ca 100644 --- a/testing/drivers/drivertest/drivertest_pm_smp.c +++ b/testing/drivers/drivertest/drivertest_pm_smp.c @@ -117,6 +117,7 @@ static int test_pm_fake_driver_init(void) for (int i = 0; i < CONFIG_SMP_NCPUS; i++) { struct test_pm_entry_s *entry = &g_test_pm_smp.entry[i]; + entry->cpu = i; CPU_ZERO(&entry->cpuset); CPU_SET(i, &entry->cpuset); @@ -127,6 +128,7 @@ static int test_pm_fake_driver_init(void) for (int state = 0; state < PM_COUNT; state++) { char name[32]; + snprintf(name, sizeof(name), "cpu%d-%s", i, test_pm_name[state]); pm_wakelock_init( &entry->wakelock[state], name, entry->domain, state); @@ -141,6 +143,7 @@ static int test_pm_callback_prepare(FAR struct pm_callback_s *cb, enum pm_state_e pmstate) { struct test_pm_entry_s *entry; + entry = container_of(cb, struct test_pm_entry_s, cb); if (entry->fail_request) { @@ -155,6 +158,7 @@ static void test_pm_callback_notify(FAR struct pm_callback_s *cb, enum pm_state_e pmstate) { struct test_pm_entry_s *entry; + entry = container_of(cb, struct test_pm_entry_s, cb); switch (pmstate) { @@ -187,6 +191,7 @@ static void test_pm_smp_yield(void) static void test_pm_smp_naps(void) { int r = random() % (TEST_SNAP_TICK_MAX * USEC_PER_TICK); + usleep(r + USEC_PER_TICK * 2); } @@ -438,6 +443,7 @@ static void drivertest_pm_smp(FAR void **argv) { struct test_pm_entry_s *entry = &g_test_pm_smp.entry[i]; pthread_attr_t attr; + pthread_attr_init(&attr); pthread_attr_setaffinity_np(&attr, sizeof(cpu_set_t), &entry->cpuset); attr.priority = CONFIG_SCHED_HPWORKPRIORITY + 1; @@ -449,6 +455,7 @@ static void drivertest_pm_smp(FAR void **argv) struct test_pm_entry_s *entry = &g_test_pm_smp.entry[i]; pthread_addr_t pthread_ret; int ret; + pthread_join(entry->tid, &pthread_ret); ret = (uintptr_t)pthread_ret; assert_int_equal(ret, 0); diff --git a/testing/drivers/pcitest/pcitest.c b/testing/drivers/pcitest/pcitest.c index 684498d24..79261b56f 100644 --- a/testing/drivers/pcitest/pcitest.c +++ b/testing/drivers/pcitest/pcitest.c @@ -286,93 +286,94 @@ int main(int argc, FAR char *argv[]) while ((c = getopt(argc, argv, "D:b:m:x:i:deIlhrwcs:")) != EOF) { - switch (c) - { - case 'D': - test->device = optarg; - continue; - case 'b': - test->barnum = atoi(optarg); - if (test->barnum < 0 || test->barnum > 5) - { - goto usage; - } - - continue; - case 'l': - test->legacyirq = true; - continue; - case 'm': - test->msinum = atoi(optarg); - if (test->msinum < 1 || test->msinum > 32) - { - goto usage; - } - - continue; - case 'x': - test->msixnum = atoi(optarg); - if (test->msixnum < 1 || test->msixnum > 2048) - { - goto usage; - } - - continue; - case 'i': - test->irqtype = atoi(optarg); - if (test->irqtype < 0 || test->irqtype > 2) - { - goto usage; - } - - test->set_irqtype = true; - continue; - case 'I': - test->get_irqtype = true; - continue; - case 'r': - test->read = true; - continue; - case 'w': - test->write = true; - continue; - case 'c': - test->copy = true; - continue; - case 'e': - test->clear_irq = true; - continue; - case 's': - test->size = strtoul(optarg, NULL, 0); - continue; - case 'd': - test->use_dma = true; - continue; - case 'h': - default: + switch (c) + { + case 'D': + test->device = optarg; + continue; + case 'b': + test->barnum = atoi(optarg); + if (test->barnum < 0 || test->barnum > 5) + { + goto usage; + } + + continue; + case 'l': + test->legacyirq = true; + continue; + case 'm': + test->msinum = atoi(optarg); + if (test->msinum < 1 || test->msinum > 32) + { + goto usage; + } + + continue; + case 'x': + test->msixnum = atoi(optarg); + if (test->msixnum < 1 || test->msixnum > 2048) + { + goto usage; + } + + continue; + case 'i': + test->irqtype = atoi(optarg); + if (test->irqtype < 0 || test->irqtype > 2) + { + goto usage; + } + + test->set_irqtype = true; + continue; + case 'I': + test->get_irqtype = true; + continue; + case 'r': + test->read = true; + continue; + case 'w': + test->write = true; + continue; + case 'c': + test->copy = true; + continue; + case 'e': + test->clear_irq = true; + continue; + case 's': + test->size = strtoul(optarg, NULL, 0); + continue; + case 'd': + test->use_dma = true; + continue; + case 'h': + default: usage: - fprintf(stderr, - "usage: %s [options]\n" - "Options:\n" - "\t-D <dev> \n" - "\t PCI e test device {default: /dev/pci-ep-test.0}\n" - "\t-b <bar num> BAR test (bar number between 0..5)\n" - "\t-m <msi num> MSI test (msi number between 1..32)\n" - "\t-x <msix num> \tMSI-X test (msix number between 1..2048)\n" - "\t-i <irq type> \n" - "\t Set IRQ type (0 - Legacy, 1 - MSI, 2 - MSI-X)\n" - "\t-e Clear IRQ\n" - "\t-I Get current IRQ type configured\n" - "\t-d Use DMA\n" - "\t-l Legacy IRQ test\n" - "\t-r Read buffer test\n" - "\t-w Write buffer test\n" - "\t-c Copy buffer test\n" - "\t-s <size> Size of buffer {default: 100KB}\n" - "\t-h Print this help message\n", - argv[0]); + fprintf(stderr, + "usage: %s [options]\n" + "Options:\n" + "\t-D <dev> \n" + "\t PCI e test device {default: /dev/pci-ep-test.0}\n" + "\t-b <bar num> BAR test (bar number between 0..5)\n" + "\t-m <msi num> MSI test (msi number between 1..32)\n" + "\t-x <msix num> \tMSI-X test " + "(msix number between 1..2048)\n" + "\t-i <irq type> \n" + "\t Set IRQ type (0 - Legacy, 1 - MSI, 2 - MSI-X)\n" + "\t-e Clear IRQ\n" + "\t-I Get current IRQ type configured\n" + "\t-d Use DMA\n" + "\t-l Legacy IRQ test\n" + "\t-r Read buffer test\n" + "\t-w Write buffer test\n" + "\t-c Copy buffer test\n" + "\t-s <size> Size of buffer {default: 100KB}\n" + "\t-h Print this help message\n", + argv[0]); return -EINVAL; - } + } } return run_test(test); diff --git a/testing/drivers/ser/ser.c b/testing/drivers/ser/ser.c index ca5820c74..00ed25bd0 100644 --- a/testing/drivers/ser/ser.c +++ b/testing/drivers/ser/ser.c @@ -78,7 +78,7 @@ int main(int argc, FAR char *argv[]) if (rcount.brk > scount.brk) { - printf("ERROR: break %d\n", rcount.brk - scount.brk); + printf("ERROR: break %d\n", rcount.brk - scount.brk); } if (rcount.buf_overrun > scount.buf_overrun) diff --git a/testing/drivers/setest/setest.c b/testing/drivers/setest/setest.c index 4ac3e3c88..3fd66ff1a 100644 --- a/testing/drivers/setest/setest.c +++ b/testing/drivers/setest/setest.c @@ -80,21 +80,22 @@ static int parse_arguments(int argc, FAR char *argv[], int result = 0; int opt; FAR char *prg = basename(argv[0]); + while (((opt = getopt(argc, argv, "b:h")) != -1) && (result == 0)) { switch (opt) { - case 'b': - settings->base_id = (uint32_t)strtoul(optarg, NULL, 0); - break; - case 'h': - print_usage(stdout, prg); - settings->skip_process = TRUE; - break; - default: - print_usage(stderr, prg); - result = -EINVAL; - break; + case 'b': + settings->base_id = (uint32_t)strtoul(optarg, NULL, 0); + break; + case 'h': + print_usage(stdout, prg); + settings->skip_process = TRUE; + break; + default: + print_usage(stderr, prg); + result = -EINVAL; + break; } } @@ -138,6 +139,7 @@ static int invert_result(int result) static int run_tests(int fd, FAR struct settings_t *settings) { int result = 0; + puts("Setup"); for (uint32_t id = get_se05x_id(settings, 1); id < get_se05x_id(settings, 5); id++) @@ -164,6 +166,7 @@ static int run_tests(int fd, FAR struct settings_t *settings) uint8_t public_key[300]; size_t public_key_size; + if (result == 0) { puts("Read from pub #1"); @@ -207,6 +210,7 @@ static int run_tests(int fd, FAR struct settings_t *settings) uint8_t signature[300]; size_t signature_content_size; + if (result == 0) { puts("Create signature with priv #1"); @@ -263,6 +267,7 @@ static int run_tests(int fd, FAR struct settings_t *settings) } uint8_t symm_key_a[32]; + if (result == 0) { puts("Derive symm key #a from priv #1 and pub #2"); @@ -280,6 +285,7 @@ static int run_tests(int fd, FAR struct settings_t *settings) } uint8_t symm_key_b[32]; + if (result == 0) { puts("Derive symm key #b from priv #2 and pub #1"); @@ -297,6 +303,7 @@ static int run_tests(int fd, FAR struct settings_t *settings) } uint8_t symm_key_c[32]; + if (result == 0) { puts("Derive symm key #c from priv #1 and pub #3"); @@ -350,6 +357,7 @@ int main(int argc, FAR char *argv[]) int result = parse_arguments(argc, argv, &settings); int fd; + if ((result == 0) && (!settings.skip_process)) { fd = open(settings.se05x_dev, O_RDONLY); diff --git a/testing/fs/fdsantest/fdsantest_simple.c b/testing/fs/fdsantest/fdsantest_simple.c index 114f0aeeb..a045fe7ff 100644 --- a/testing/fs/fdsantest/fdsantest_simple.c +++ b/testing/fs/fdsantest/fdsantest_simple.c @@ -100,9 +100,11 @@ static void test_case_overflow(void **state) static void test_case_vfork(void **state) { int fd = open("/dev/null", O_RDONLY); + android_fdsan_exchange_owner_tag(fd, 0, 0xbadc0de); pid_t rc = vfork(); + assert_int_not_equal(-1, rc); if (rc == 0) diff --git a/testing/mm/cachetest/cachetest_main.c b/testing/mm/cachetest/cachetest_main.c index 2916932c8..ddbf7951b 100644 --- a/testing/mm/cachetest/cachetest_main.c +++ b/testing/mm/cachetest/cachetest_main.c @@ -170,6 +170,7 @@ static void cachetest_teardown(FAR struct cachetest_s *info) static inline char cachetest_randchar(void) { int value = random() % 63; + if (value == 0) { return '0'; @@ -198,6 +199,7 @@ static void cachetest_randcontext(uint32_t size, FAR void *input) int i; FAR char *tmp; + tmp = input; for (i = 0; i < size - 1; i++) { diff --git a/wireless/ieee802154/i8sak/i8sak_acceptassoc.c b/wireless/ieee802154/i8sak/i8sak_acceptassoc.c index 42d54288d..beffea18f 100644 --- a/wireless/ieee802154/i8sak/i8sak_acceptassoc.c +++ b/wireless/ieee802154/i8sak/i8sak_acceptassoc.c @@ -162,7 +162,7 @@ static void acceptassoc_eventcb(FAR struct ieee802154_primitive_s *primitive, printf("i8sak: a device is trying to associate\n"); - /* Send a ASSOC.resp primtive to the MAC. Copy the association + /* Send a ASSOC.resp primitive to the MAC. Copy the association * indication address into the association response primitive */
