* tests/tests.h [!DEFAULT_STRLEN] (DEFAULT_STRLEN): New macro.
* tests/mincore.c (DEFAULT_STRLEN): Remove.
* tests/mmsg_name.c: Likewise.
* tests/msg_control.c: Likewise.
* tests/netlink_protocol.c: Likewise.
* tests/nlattr.c: Likewise.
* tests/nlattr_inet_diag_msg.c: Likewise.
* tests/nlattr_netlink_diag_msg.c: Likewise.
* tests/nlattr_unix_diag_msg.c: Likewise.
* tests/printstr.c: Likewise.
* tests/xattr.c: Likewise.
* tests/execve.c: Likewise.
(main): Initialize str_a and str_b arrays at run time.
* tests/execveat.c: Likewise.
Suggested-by: JingPiao Chen <chenjingpiao@gmail.com>
#endif
);
- char str_a[] = "012345678901234567890123456789012";
- char str_b[] = "_abcdefghijklmnopqrstuvwxyz()[]{}";
-#define DEFAULT_STRLEN ((unsigned int) sizeof(str_a) - 2)
+ char *const str_a = tail_alloc(DEFAULT_STRLEN + 2);
+ fill_memory_ex(str_a, DEFAULT_STRLEN + 1, '0', 10);
+ str_a[DEFAULT_STRLEN + 1] = '\0';
+
+ char *const str_b = tail_alloc(DEFAULT_STRLEN + 2);
+ fill_memory_ex(str_b, DEFAULT_STRLEN + 1, '_', 32);
+ str_b[DEFAULT_STRLEN + 1] = '\0';
+
char **const a = tail_alloc(sizeof(*a) * (DEFAULT_STRLEN + 2));
char **const b = tail_alloc(sizeof(*b) * (DEFAULT_STRLEN + 2));
unsigned int i;
#endif
errno2name());
- char str_a[] = "012345678901234567890123456789012";
- char str_b[] = "_abcdefghijklmnopqrstuvwxyz()[]{}";
-#define DEFAULT_STRLEN ((unsigned int) sizeof(str_a) - 2)
+ char *const str_a = tail_alloc(DEFAULT_STRLEN + 2);
+ fill_memory_ex(str_a, DEFAULT_STRLEN + 1, '0', 10);
+ str_a[DEFAULT_STRLEN + 1] = '\0';
+
+ char *const str_b = tail_alloc(DEFAULT_STRLEN + 2);
+ fill_memory_ex(str_b, DEFAULT_STRLEN + 1, '_', 32);
+ str_b[DEFAULT_STRLEN + 1] = '\0';
+
char **const a = tail_alloc(sizeof(*a) * (DEFAULT_STRLEN + 2));
char **const b = tail_alloc(sizeof(*b) * (DEFAULT_STRLEN + 2));
unsigned int i;
#include <stdio.h>
#include <sys/mman.h>
-#define DEFAULT_STRLEN 32
-
static void
print_mincore(const unsigned int pages, void *const addr,
const size_t size, unsigned char *const vec)
#include "msghdr.h"
-#define DEFAULT_STRLEN 32
-
#define IOV_MAX1 (IOV_MAX + 1)
#ifndef TEST_NAME
return page - CMSG_ALIGN(len);
}
-#define DEFAULT_STRLEN 32
-
static void
print_fds(const struct cmsghdr *const cmsg, const size_t cmsg_len)
{
(unsigned) sizeof(*reqs), sprintrc(rc));
/* abbreviated output */
-# define DEFAULT_STRLEN 32
# define ABBREV_LEN (DEFAULT_STRLEN + 1)
const unsigned int msg_len = sizeof(struct nlmsghdr) * ABBREV_LEN;
struct nlmsghdr *const msgs = tail_alloc(msg_len);
fd, msg_len, nla->nla_len, msg_len, sprintrc(rc));
/* abbreviated output */
-#define DEFAULT_STRLEN 32
#define ABBREV_LEN (DEFAULT_STRLEN + 1)
msg_len = NLA_HDRLEN * ABBREV_LEN + NLMSG_SPACE(sizeof(msg->udm));
msg = tail_memdup(&c_msg, msg_len);
const unsigned int hdrlen = sizeof(struct inet_diag_msg);
void *const nlh0 = tail_alloc(NLMSG_SPACE(hdrlen));
-#define DEFAULT_STRLEN 32
static char pattern[DEFAULT_STRLEN];
fill_memory_ex(pattern, sizeof(pattern), 'a', 'z' - 'a' + 1);
const unsigned int hdrlen = sizeof(struct netlink_diag_msg);
void *const nlh0 = tail_alloc(NLMSG_SPACE(hdrlen));
-#define DEFAULT_STRLEN 32
static char pattern[DEFAULT_STRLEN];
fill_memory_ex(pattern, sizeof(pattern), 'a', 'z' - 'a' + 1);
const unsigned int hdrlen = sizeof(struct unix_diag_msg);
void *const nlh0 = tail_alloc(NLMSG_SPACE(hdrlen));
-#define DEFAULT_STRLEN 32
static char pattern[DEFAULT_STRLEN];
fill_memory_ex(pattern, sizeof(pattern), 'a', 'z' - 'a' + 1);
#include <unistd.h>
#include <sys/uio.h>
-#define DEFAULT_STRLEN 32
-
int
main(void)
{
# define VERBOSE 0
#endif
+#ifndef DEFAULT_STRLEN
+/* Default maximum # of bytes printed in printstr et al. */
+# define DEFAULT_STRLEN 32
+#endif
+
/* Cached sysconf(_SC_PAGESIZE). */
size_t get_page_size(void);
# define XATTR_SIZE_MAX 65536
# endif
-#define DEFAULT_STRLEN 32
-
int
main(void)
{