From: Dmitry V. Levin Date: Tue, 24 May 2016 01:04:56 +0000 (+0000) Subject: btrfs.c: cleanup struct btrfs_ioctl_get_dev_stats.nr_items check X-Git-Tag: v4.12~85 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=92b90621cc225813c56221c2546cc4188e718a3a;p=strace btrfs.c: cleanup struct btrfs_ioctl_get_dev_stats.nr_items check * btrfs.c (btrfs_ioctl): Cleanup check of iterator of btrfs_ioctl_get_dev_stats.values array. --- diff --git a/btrfs.c b/btrfs.c index 10625c7c..1eed651c 100644 --- a/btrfs.c +++ b/btrfs.c @@ -782,7 +782,7 @@ btrfs_ioctl(struct tcb *tcp, const unsigned int code, const long arg) case BTRFS_IOC_GET_DEV_STATS: { /* RW */ struct btrfs_ioctl_get_dev_stats args; - uint64_t i, max_nr_items; + uint64_t i; if (entering(tcp)) tprints(", "); @@ -812,17 +812,15 @@ btrfs_ioctl(struct tcb *tcp, const unsigned int code, const long arg) * go off into the middle of nowhere with a bad nr_items * value. */ - max_nr_items = sizeof(args) - offsetof(typeof(args), values); - tprints(", ["); for (i = 0; i < args.nr_items; i++) { - const char *name = xlookup(btrfs_dev_stats_values, i); if (i) tprints(", "); - if (i > max_nr_items) { - tprints("/* overflow */"); + if (i >= ARRAY_SIZE(args.values)) { + tprints("..."); break; } + const char *name = xlookup(btrfs_dev_stats_values, i); if (name) tprintf("/* %s */ ", name); tprintf("%" PRI__u64, args.values[i]);