1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-27 10:25:13 +03:00

Cleanup test compile warning

Add some declaration and cast to cleanup gcc warnings.
Add missing dm_config_destroy() to cleanup pool leak report.
This commit is contained in:
Zdenek Kabelac 2011-12-13 12:08:42 +00:00
parent 4e73e7ac16
commit c6958856f8
4 changed files with 26 additions and 22 deletions

View File

@ -24,17 +24,17 @@ enum {
static struct dm_pool *mem;
int bitset_init() {
int bitset_init(void) {
mem = dm_pool_create("bitset test", 1024);
return mem == NULL;
}
int bitset_fini() {
int bitset_fini(void) {
dm_pool_destroy(mem);
return 0;
}
static void test_get_next()
static void test_get_next(void)
{
int i, j, last = 0, first;
dm_bitset_t bs = dm_bitset_create(mem, NR_BITS);
@ -68,7 +68,7 @@ static void bit_flip(dm_bitset_t bs, int bit)
dm_bit_set(bs, bit);
}
static void test_equal()
static void test_equal(void)
{
dm_bitset_t bs1 = dm_bitset_create(mem, NR_BITS);
dm_bitset_t bs2 = dm_bitset_create(mem, NR_BITS);
@ -92,7 +92,7 @@ static void test_equal()
}
}
static void test_and()
static void test_and(void)
{
dm_bitset_t bs1 = dm_bitset_create(mem, NR_BITS);
dm_bitset_t bs2 = dm_bitset_create(mem, NR_BITS);
@ -131,4 +131,3 @@ CU_TestInfo bitset_list[] = {
{ (char*)"and", test_and },
CU_TEST_INFO_NULL
};

View File

@ -15,14 +15,17 @@
#include "libdevmapper.h"
#include <CUnit/CUnit.h>
int config_init(void);
int config_fini(void);
static struct dm_pool *mem;
int config_init() {
int config_init(void) {
mem = dm_pool_create("config test", 1024);
return mem == NULL;
}
int config_fini() {
int config_fini(void) {
dm_pool_destroy(mem);
return 0;
}
@ -45,12 +48,12 @@ static const char *conf =
" }\n"
"}\n";
static void test_parse()
static void test_parse(void)
{
struct dm_config_tree *tree = dm_config_from_string(conf);
struct dm_config_value *value;
const struct dm_config_value *value;
CU_ASSERT(tree);
CU_ASSERT((long) tree);
CU_ASSERT(dm_config_has_node(tree->root, "id"));
CU_ASSERT(dm_config_has_node(tree->root, "physical_volumes"));
CU_ASSERT(dm_config_has_node(tree->root, "physical_volumes/pv0"));
@ -77,11 +80,11 @@ static void test_parse()
dm_config_destroy(tree);
}
static void test_clone()
static void test_clone(void)
{
struct dm_config_tree *tree = dm_config_from_string(conf);
struct dm_config_node *n = dm_config_clone_node(tree, tree->root, 1);
struct dm_config_value *value;
const struct dm_config_value *value;
/* Check that the nodes are actually distinct. */
CU_ASSERT(n != tree->root);
@ -112,6 +115,8 @@ static void test_clone()
CU_ASSERT(value->next == NULL); /* an empty list */
CU_ASSERT(dm_config_get_list(n, "status", &value));
CU_ASSERT(value->next != NULL); /* a non-empty list */
dm_config_destroy(tree);
}
CU_TestInfo config_list[] = {
@ -119,4 +124,3 @@ CU_TestInfo config_list[] = {
{ (char*)"clone", test_clone },
CU_TEST_INFO_NULL
};

View File

@ -33,27 +33,28 @@ int regex_fini(void);
static struct dm_pool *mem = NULL;
int regex_init() {
int regex_init(void) {
mem = dm_pool_create("bitset test", 1024);
return mem == NULL;
}
int regex_fini() {
int regex_fini(void) {
dm_pool_destroy(mem);
return 0;
}
static struct dm_regex *make_scanner(const char **rx)
{
struct dm_regex *scanner;
int nrx = 0;
for (; rx[nrx]; ++nrx);
struct dm_regex *scanner = dm_regex_create(mem, rx, nrx);
scanner = dm_regex_create(mem, rx, nrx);
CU_ASSERT_FATAL(scanner != NULL);
return scanner;
}
static void test_fingerprints() {
static void test_fingerprints(void) {
struct dm_regex *scanner;
scanner = make_scanner(dev_patterns);
@ -63,7 +64,7 @@ static void test_fingerprints() {
CU_ASSERT_EQUAL(dm_regex_fingerprint(scanner), 0xeed8ceb8);
}
static void test_matching() {
static void test_matching(void) {
struct dm_regex *scanner;
int i;

View File

@ -3,8 +3,8 @@
#define DECL(n) \
extern CU_TestInfo n ## _list[]; \
int n ## _init(); \
int n ## _fini();
int n ## _init(void); \
int n ## _fini(void);
#define USE(n) { (char*) #n, n##_init, n##_fini, n##_list }
DECL(bitset);
@ -18,7 +18,7 @@ CU_SuiteInfo suites[] = {
CU_SUITE_INFO_NULL
};
int main() {
int main(int argc, char **argv) {
CU_initialize_registry();
CU_register_suites(suites);
CU_basic_set_mode(CU_BRM_VERBOSE);