]> granicus.if.org Git - strace/commitdiff
btrfs.c: cleanup struct btrfs_ioctl_get_dev_stats.nr_items check
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 24 May 2016 01:04:56 +0000 (01:04 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 24 May 2016 14:52:27 +0000 (14:52 +0000)
* btrfs.c (btrfs_ioctl): Cleanup check of iterator of
btrfs_ioctl_get_dev_stats.values array.

btrfs.c

diff --git a/btrfs.c b/btrfs.c
index 10625c7cad9c17a0ab0d73a55687d9504d3a4616..1eed651ccfd1d6a0b659755bccbebe0329a57ac2 100644 (file)
--- 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]);