Skip to content

Commit 46416a9

Browse files
committed
test: move _cleanup_free_ to util.h
Moving _cleanup_free_ to util.h such that it can be reused in all ioctl test classes. Signed-off-by: Dennis Maisenbacher <[email protected]>
1 parent bdb79ef commit 46416a9

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

test/ioctl/misc.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,6 @@
88
#include <nvme/ioctl.h>
99
#include <nvme/types.h>
1010
#include <string.h>
11-
#include <stdlib.h>
12-
13-
#define __cleanup__(fn) __attribute__((cleanup(fn)))
14-
15-
static inline void freep(void *p)
16-
{
17-
free(*(void **)p);
18-
}
19-
#define _cleanup_free_ __cleanup__(freep)
2011

2112
#define TEST_FD 0xFD
2213
#define TEST_NSID 0x12345678

test/ioctl/util.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#define _LIBNVME_TEST_IOCTL_UTIL_H
55

66
#include <stddef.h>
7+
#include <stdlib.h>
78
#include <stdnoreturn.h>
89

910
noreturn void fail(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
@@ -16,4 +17,12 @@ void arbitrary(void *buf, size_t len);
1617

1718
size_t arbitrary_range(size_t max);
1819

20+
#define __cleanup__(fn) __attribute__((cleanup(fn)))
21+
22+
static inline void freep(void *p)
23+
{
24+
free(*(void **)p);
25+
}
26+
#define _cleanup_free_ __cleanup__(freep)
27+
1928
#endif /* #ifndef _LIBNVME_TEST_IOCTL_UTIL_H */

0 commit comments

Comments
 (0)