Changeset 59958992 in mainline for uspace/app/tmon/main.c


Ignore:
Timestamp:
2017-12-22T15:08:49Z (6 years ago)
Author:
Petr Mánek <petr.manek@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8e16454
Parents:
acb9aa7
Message:

tmon: use ARRAY_SIZE to enumerate static arrays

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tmon/main.c

    racb9aa7 r59958992  
    3636
    3737#include <stdio.h>
     38#include <macros.h>
    3839#include "commands.h"
    3940
     
    8283                .description = "Write to isochronous endpoint as fast as possible.",
    8384                .action = tmon_burst_isoch_out,
    84         },
    85         { /* NULL-terminated */ }
     85        }
    8686};
    8787
     
    102102                .short_name = 's',
    103103                .description = "Set the data size transferred in a single cycle."
    104         },
    105         { /* NULL-terminated */ }
     104        }
    106105};
    107106
     
    111110        printf("Usage: %s command [device] [options]\n\n", app_name);
    112111
    113         for (int i = 0; commands[i].name; ++i) {
     112        for (unsigned i = 0; i < ARRAY_SIZE(commands); ++i) {
    114113                printf(INDENT "%s - %s\n", commands[i].name, commands[i].description);
    115114        }
    116115
    117116        puts("\n");
    118         for (int i = 0; options[i].long_name; ++i) {
     117        for (unsigned i = 0; i < ARRAY_SIZE(options); ++i) {
    119118                printf(INDENT "-%c --%s\n" INDENT INDENT "%s\n", options[i].short_name, options[i].long_name, options[i].description);
    120119        }
     
    127126        // Find a command to execute.
    128127        tmon_cmd_t *cmd = NULL;
    129         for (int i = 0; argc > 1 && commands[i].name; ++i) {
     128        for (unsigned i = 0; argc > 1 && i < ARRAY_SIZE(commands); ++i) {
    130129                if (str_cmp(argv[1], commands[i].name) == 0) {
    131130                        cmd = commands + i;
Note: See TracChangeset for help on using the changeset viewer.