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


Ignore:
Timestamp:
2017-12-22T15:08:49Z (8 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/burst_tests.c

    racb9aa7 r59958992  
    4040#include <getopt.h>
    4141#include <usbdiag_iface.h>
     42#include <macros.h>
    4243#include "commands.h"
    4344#include "tf.h"
     
    115116        { .prefix = 'G', .factor = 1ul << 30 },
    116117        { .prefix = 'M', .factor = 1ul << 20 },
    117         { .prefix = 'k', .factor = 1ul << 10 },
    118         { /* NULL-terminated */ }
     118        { .prefix = 'k', .factor = 1ul << 10 }
    119119};
    120120
    121121static char * format_size(double size, const char *fmt)
    122122{
    123         int i;
    124         for (i = 0; units[i].prefix; ++i) {
     123        unsigned i;
     124        for (i = 0; i < ARRAY_SIZE(units); ++i) {
    125125                if (units[i].factor <= size)
    126126                        break;
    127127        }
    128128
    129         char prefix[2] = { '\0', '\0' };
     129        char prefix[] = { '\0', '\0' };
    130130        double factor = 1;
    131131
    132         if (units[i].prefix) {
     132        if (i < ARRAY_SIZE(units)) {
    133133                prefix[0] = units[i].prefix;
    134134                factor = units[i].factor;
Note: See TracChangeset for help on using the changeset viewer.