* fill_memory.c: New file. * Makefile.am (libtests_a_SOURCES): add fill_memory.c. * quotactl.h (fill_memory, fill_memory_ex): Moved to fill_memory.c. * tests.h: Add declarations of fill_memory, fill_memory_ex. --- tests/Makefile.am | 1 + tests/fill_memory.c | 18 ++++++++++++++++++ tests/quotactl.h | 17 ----------------- tests/tests.h | 10 ++++++++++ 4 files changed, 29 insertions(+), 17 deletions(-) create mode 100644 tests/fill_memory.c
diff --git a/tests/Makefile.am b/tests/Makefile.am index 0c24969..6138199 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -43,6 +43,7 @@ AM_LDFLAGS = $(ARCH_MFLAGS) libtests_a_SOURCES = \ errno2name.c \ error_msg.c \ + fill_memory.c \ get_page_size.c \ hexdump_strdup.c \ hexquote_strndup.c \ diff --git a/tests/fill_memory.c b/tests/fill_memory.c new file mode 100644 index 0000000..7a87817 --- /dev/null +++ b/tests/fill_memory.c @@ -0,0 +1,18 @@ +#include "tests.h" + +void +fill_memory_ex(char *ptr, size_t size, unsigned char start, + unsigned char period) +{ + size_t i; + + for (i = 0; i < size; i++) { + ptr[i] = start + i % period; + } +} + +void +fill_memory(char *ptr, size_t size) +{ + fill_memory_ex(ptr, size, 0x80, 0x80); +} diff --git a/tests/quotactl.h b/tests/quotactl.h index ab0993e..b97153f 100644 --- a/tests/quotactl.h +++ b/tests/quotactl.h @@ -92,23 +92,6 @@ enum check_quotactl_flags { static inline void -fill_memory_ex(char *ptr, size_t size, unsigned char start, - unsigned char period) -{ - size_t i; - - for (i = 0; i < size; i++) { - ptr[i] = start + i % period; - } -} - -static inline void -fill_memory(char *ptr, size_t size) -{ - fill_memory_ex(ptr, size, 0x80, 0x80); -} - -static inline void check_quota(uint32_t flags, int cmd, const char *cmd_str, const char *special, const char *special_str, ...) { diff --git a/tests/tests.h b/tests/tests.h index f3ddc85..a482876 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -67,6 +67,16 @@ void *tail_alloc(const size_t) void *tail_memdup(const void *, const size_t) ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE((2)); +/* + * Fill memory (pointed by ptr, having size bytes) with different bytes (with + * values starting with start and resetting every period) in order to catch + * sign, byte order and/or alignment errors. + */ +void fill_memory_ex(char *ptr, size_t size, unsigned char start, + unsigned char period); +/* Shortcut for fill_memory_ex(ptr, size, 0x80, 0x80) */ +void fill_memory(char *ptr, size_t size); + /* Close stdin, move stdout to a non-standard descriptor, and print. */ void tprintf(const char *, ...) ATTRIBUTE_FORMAT((printf, 1, 2)); -- 1.7.10.4 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel