]> granicus.if.org Git - strace/commitdiff
tests: replace init_magic with fill_memory
authorDmitry V. Levin <ldv@altlinux.org>
Thu, 5 Jan 2017 01:34:24 +0000 (01:34 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 5 Jan 2017 01:34:24 +0000 (01:34 +0000)
Use the same fill_memory/fill_memory_ex interface in all affected tests.

* tests/ioctl_block.c (init_magic): Remove.
(main): Replace init_magic with fill_memory.
* tests/ioctl_evdev.c: Likewise.
* tests/ioctl_v4l2.c: Likewise.
* tests/ioctl_mtd.c (magic, init_magic): Remove.
(main): Replace init_magic with fill_memory.
* tests/ioctl_rtc.c: Likewise.

tests/ioctl_block.c
tests/ioctl_evdev.c
tests/ioctl_mtd.c
tests/ioctl_rtc.c
tests/ioctl_v4l2.c

index 82b89da9cdd4e6c38849294c00839872ad6fddbb..f62b0b36540d728943bd4b802a978db30cf61c25 100644 (file)
 static const unsigned int magic = 0xdeadbeef;
 static const unsigned long lmagic = (unsigned long) 0xdeadbeefbadc0dedULL;
 
-#if defined BLKTRACESETUP && defined HAVE_STRUCT_BLK_USER_TRACE_SETUP
-static void
-init_magic(void *addr, const unsigned int size)
-{
-       unsigned int *p = addr;
-       const unsigned int *end = addr + size - sizeof(int);
-
-       for (; p <= end; ++p)
-               *(unsigned int *) p = magic + (p - (unsigned int *) addr);
-}
-#endif
-
 static struct xlat block_argless[] = {
        XLAT(BLKRRPART),
        XLAT(BLKFLSBUF),
@@ -190,7 +178,7 @@ main(void)
 
 #if defined BLKTRACESETUP && defined HAVE_STRUCT_BLK_USER_TRACE_SETUP
        struct blk_user_trace_setup *const buts = tail_alloc(sizeof(*buts));
-       init_magic(buts, sizeof(*buts));
+       fill_memory(buts, sizeof(*buts));
 
        ioctl(-1, BLKTRACESETUP, buts);
        printf("ioctl(-1, BLKTRACESETUP, {act_mask=%hu, buf_size=%u, buf_nr=%u"
index 74aac0d3a4efab11179d07e09538773ad8a6879d..d12323ee2daf294125a9fe7b7a8df8c37a713de7 100644 (file)
 static const unsigned int magic = 0xdeadbeef;
 static const unsigned long lmagic = (unsigned long) 0xdeadbeefbadc0dedULL;
 
-static void
-init_magic(void *addr, const unsigned int size)
-{
-       unsigned int *p = addr;
-       const unsigned int *end = addr + size - sizeof(int);
-
-       for (; p <= end; ++p)
-               *(unsigned int *) p = magic;
-}
-
 # if VERBOSE
 static void
 print_envelope(const struct ff_envelope *const e)
@@ -156,7 +146,7 @@ main(void)
 
        const unsigned int size = get_page_size();
        void *const page = tail_alloc(size);
-       init_magic(page, size);
+       fill_memory(page, size);
 
        int *const val_int = tail_alloc(sizeof(*val_int));
        *val_int = magic;
@@ -183,7 +173,7 @@ main(void)
 
 # ifdef EVIOCSKEYCODE_V2
        struct input_keymap_entry *const ike = tail_alloc(sizeof(*ike));
-       init_magic(ike, sizeof(*ike));
+       fill_memory(ike, sizeof(*ike));
        ike->keycode = 2;
 
        ioctl(-1, EVIOCSKEYCODE_V2, ike);
@@ -207,7 +197,7 @@ main(void)
 # endif
 
        struct ff_effect *const ffe = tail_alloc(sizeof(*ffe));
-       init_magic(ffe, sizeof(*ffe));
+       fill_memory(ffe, sizeof(*ffe));
 
        ffe->type = FF_CONSTANT;
        ioctl(-1, EVIOCSFF, ffe);
index e28bcc9d5451fe6cf456e2214a57ea1bef878e3d..a37d5d0f0a48bd52e338c454fcf855c9d0134d56 100644 (file)
 # include <mtd/mtd-abi.h>
 #endif
 
-static const unsigned int magic = 0xdeadbeef;
 static const unsigned long lmagic = (unsigned long) 0xdeadbeefbadc0dedULL;
 
-static void
-init_magic(void *addr, const unsigned int size)
-{
-       unsigned int *p = addr;
-       const unsigned int *end = addr + size - sizeof(int);
-
-       for (; p <= end; ++p)
-               *(unsigned int *) p = magic;
-}
-
 #define TEST_NULL_ARG(cmd) \
        do { \
                ioctl(-1, cmd, 0); \
@@ -113,7 +102,7 @@ main(void)
               " = -1 EBADF (%m)\n", (unsigned int) _IOC_NR(OTPSELECT));
 
        uint64_t *const v64 = tail_alloc(sizeof(*v64));
-       init_magic(v64, sizeof(*v64));
+       fill_memory(v64, sizeof(*v64));
 
        ioctl(-1, MEMGETBADBLOCK, v64);
        printf("ioctl(-1, MIXER_WRITE(%u) or MEMGETBADBLOCK, [%" PRIu64 "])"
@@ -126,7 +115,7 @@ main(void)
               (unsigned int) _IOC_NR(MEMSETBADBLOCK), *v64);
 
        struct region_info_user *const riu = tail_alloc(sizeof(*riu));
-       init_magic(riu, sizeof(*riu));
+       fill_memory(riu, sizeof(*riu));
        ioctl(-1, MEMGETREGIONINFO, riu);
        printf("ioctl(-1, %s, {regionindex=%#x}) = -1 EBADF (%m)\n",
               "MEMGETREGIONINFO"
@@ -136,7 +125,7 @@ main(void)
               , riu->regionindex);
 
        struct erase_info_user *const eiu = tail_alloc(sizeof(*eiu));
-       init_magic(eiu, sizeof(*eiu));
+       fill_memory(eiu, sizeof(*eiu));
 
        TEST_erase_info_user(MEMERASE, eiu);
        TEST_erase_info_user(MEMLOCK, eiu);
@@ -144,7 +133,7 @@ main(void)
        TEST_erase_info_user(MEMISLOCKED, eiu);
 
        struct erase_info_user64 *const eiu64 = tail_alloc(sizeof(*eiu64));
-       init_magic(eiu64, sizeof(*eiu64));
+       fill_memory(eiu64, sizeof(*eiu64));
        ioctl(-1, MEMERASE64, eiu64);
        printf("ioctl(-1, MIXER_WRITE(%u) or %s, {start=%#llx, length=%#llx})"
               " = -1 EBADF (%m)\n",
@@ -153,7 +142,7 @@ main(void)
               (unsigned long long) eiu64->length);
 
        struct mtd_oob_buf *const oob = tail_alloc(sizeof(*oob));
-       init_magic(oob, sizeof(*oob));
+       fill_memory(oob, sizeof(*oob));
 
        ioctl(-1, MEMWRITEOOB, oob);
        printf("ioctl(-1, MEMWRITEOOB, {start=%#x, length=%#x, ptr=%p})"
@@ -164,7 +153,7 @@ main(void)
               " = -1 EBADF (%m)\n", oob->start, oob->length, oob->ptr);
 
        struct mtd_oob_buf64 *const oob64 = tail_alloc(sizeof(*oob64));
-       init_magic(oob64, sizeof(*oob64));
+       fill_memory(oob64, sizeof(*oob64));
 
        ioctl(-1, MEMWRITEOOB64, oob64);
        printf("ioctl(-1, MEMWRITEOOB64"
@@ -180,14 +169,14 @@ main(void)
 
 
        struct otp_info *const oi = tail_alloc(sizeof(*oi));
-       init_magic(oi, sizeof(*oi));
+       fill_memory(oi, sizeof(*oi));
        ioctl(-1, OTPLOCK, oi);
        printf("ioctl(-1, MIXER_READ(%u) or OTPLOCK"
               ", {start=%#x, length=%#x, locked=%u}) = -1 EBADF (%m)\n",
               (unsigned int) _IOC_NR(OTPLOCK),  oi->start, oi->length, oi->locked);
 
        struct mtd_write_req *const wr = tail_alloc(sizeof(*wr));
-       init_magic(wr, sizeof(*wr));
+       fill_memory(wr, sizeof(*wr));
        wr->mode = MTD_OPS_PLACE_OOB;
        ioctl(-1, MEMWRITE, wr);
        printf("ioctl(-1, MEMWRITE, {start=%#llx, len=%#llx, ooblen=%#llx"
index 34264ce58641eb75a9fa7c19f4b45f3beea7fb09..49d7ec7b0af4d9c065a2fdb8a38dd06cd2b827f5 100644 (file)
 #include <linux/rtc.h>
 #include "xlat.h"
 
-static const unsigned int magic = 0xdeadbeef;
 static const unsigned long lmagic = (unsigned long) 0xdeadbeefbadc0dedULL;
 
-static void
-init_magic(void *addr, const unsigned int size)
-{
-       unsigned int *p = addr;
-       const unsigned int *end = addr + size - sizeof(int);
-
-       for (; p <= end; ++p)
-               *(unsigned int *) p = magic;
-}
-
 static void
 print_rtc_time(const struct rtc_time *rt)
 {
@@ -82,16 +71,16 @@ main(void)
        const unsigned int size = get_page_size();
 
        void *const page = tail_alloc(size);
-       init_magic(page, size);
+       fill_memory(page, size);
 
        struct rtc_time *rt = tail_alloc(sizeof(*rt));
-       init_magic(rt, sizeof(*rt));
+       fill_memory(rt, sizeof(*rt));
 
        struct rtc_wkalrm *wk = tail_alloc(sizeof(*wk));
-       init_magic(wk, sizeof(*wk));
+       fill_memory(wk, sizeof(*wk));
 
        struct rtc_pll_info *pll = tail_alloc(sizeof(*pll));
-       init_magic(pll, sizeof(*pll));
+       fill_memory(pll, sizeof(*pll));
 
        /* RTC_ALM_READ */
        ioctl(-1, RTC_ALM_READ, 0);
index a3b430b33c36354e530f89f0dd33ea8df876c863..af8c3419a71e03767c42a797ed2d2606c23d3513 100644 (file)
 #include <linux/types.h>
 #include <linux/videodev2.h>
 
-static const unsigned int magic = 0xdeadbeef;
-
-static void
-init_magic(void *addr, const unsigned int size)
-{
-       unsigned int *p = addr;
-       const unsigned int *end = addr + size;
-
-       for (; p < end; ++p)
-               *(unsigned int *) p = magic;
-}
-
 #if WORDS_BIGENDIAN
 # define cc0(arg) ((unsigned int) (unsigned char) ((unsigned int) (arg) >> 24))
 # define cc1(arg) ((unsigned int) (unsigned char) ((unsigned int) (arg) >> 16))
@@ -66,12 +54,14 @@ init_magic(void *addr, const unsigned int size)
         ((unsigned int)(a3) << 24))
 #endif
 
+static const unsigned int magic = 0xdeadbeef;
+
 int
 main(void )
 {
        const unsigned int size = get_page_size();
        void *const page = tail_alloc(size);
-       init_magic(page, size);
+       fill_memory(page, size);
 
        unsigned char cc[sizeof(int)] = { 'A', '\'', '\\', '\xfa' };