[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Confuse-devel] [PATCH 4/4] tests: initializer element is not computable
From: |
Carlo Marcelo Arenas Belon |
Subject: |
[Confuse-devel] [PATCH 4/4] tests: initializer element is not computable at load time |
Date: |
Sun, 4 Jan 2009 00:09:34 -0800 |
ISO C90 (until C99) requires that all initializer be constant values
but a pointer to an automatic variable is not kwnown at load time.
make all pointers used as part of CFG_SIMPLE_* and CFG_SEC macros in
the examples and tests, point to a static variable so it can be
considered constant
Signed-off-by: Carlo Marcelo Arenas Belon <address@hidden>
---
examples/ftpconf.c | 2 +-
examples/reread.c | 2 +-
examples/simple.c | 10 +++++-----
tests/section_title_dupes.c | 2 +-
tests/suite_dup.c | 2 +-
tests/suite_list.c | 4 ++--
tests/suite_single.c | 6 +++---
tests/suite_validate.c | 6 +++---
8 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/examples/ftpconf.c b/examples/ftpconf.c
index c8497c3..a46db92 100644
--- a/examples/ftpconf.c
+++ b/examples/ftpconf.c
@@ -68,7 +68,7 @@ int conf_validate_bookmark(cfg_t *cfg, cfg_opt_t *opt)
cfg_t *parse_conf(const char *filename)
{
- cfg_opt_t bookmark_opts[] = {
+ static cfg_opt_t bookmark_opts[] = {
CFG_STR("host", 0, CFGF_NODEFAULT),
CFG_INT("port", 21, CFGF_NONE),
CFG_STR("login", "anonymous", CFGF_NONE),
diff --git a/examples/reread.c b/examples/reread.c
index fb60776..5fa1042 100644
--- a/examples/reread.c
+++ b/examples/reread.c
@@ -8,7 +8,7 @@ const char *config_filename = "./reread.conf";
void read_config(void)
{
- cfg_opt_t arg_opts[] = {
+ static cfg_opt_t arg_opts[] = {
CFG_STR("value", "default", CFGF_NONE),
CFG_END()
};
diff --git a/examples/simple.c b/examples/simple.c
index 9f47ec7..9a6ee51 100644
--- a/examples/simple.c
+++ b/examples/simple.c
@@ -4,10 +4,10 @@
int main(void)
{
- cfg_bool_t verbose = cfg_false;
- char *server = NULL;
- double delay = 1.356e-32;
- char *username = NULL;
+ static cfg_bool_t verbose = cfg_false;
+ static char *server = NULL;
+ static double delay = 1.356e-32;
+ static char *username = NULL;
/* Although the macro used to specify an integer option is called
* CFG_SIMPLE_INT(), it actually expects a long int. On a 64 bit system
@@ -18,7 +18,7 @@ int main(void)
* cfg_getint(), this is not a problem as the data types are implicitly
* cast.
*/
- long int debug = 1;
+ static long int debug = 1;
cfg_opt_t opts[] = {
CFG_SIMPLE_BOOL("verbose", &verbose),
diff --git a/tests/section_title_dupes.c b/tests/section_title_dupes.c
index ba8b93f..88b0436 100644
--- a/tests/section_title_dupes.c
+++ b/tests/section_title_dupes.c
@@ -3,7 +3,7 @@
int main(void)
{
- cfg_opt_t section_opts[] = {
+ static cfg_opt_t section_opts[] = {
CFG_STR("prop", 0, CFGF_NONE),
CFG_END()
};
diff --git a/tests/suite_dup.c b/tests/suite_dup.c
index 8a125fc..189be2a 100644
--- a/tests/suite_dup.c
+++ b/tests/suite_dup.c
@@ -3,7 +3,7 @@
static cfg_t *create_config(void)
{
- cfg_opt_t sec_opts[] =
+ static cfg_opt_t sec_opts[] =
{
CFG_INT("a", 1, CFGF_NONE),
CFG_INT("b", 2, CFGF_NONE),
diff --git a/tests/suite_list.c b/tests/suite_list.c
index 862782a..e1e44cf 100644
--- a/tests/suite_list.c
+++ b/tests/suite_list.c
@@ -6,7 +6,7 @@ static int numopts = 0;
static void list_setup(void)
{
- cfg_opt_t subsec_opts[] =
+ static cfg_opt_t subsec_opts[] =
{
CFG_STR_LIST("subsubstring", 0, CFGF_NONE),
CFG_INT_LIST("subsubinteger", 0, CFGF_NONE),
@@ -15,7 +15,7 @@ static void list_setup(void)
CFG_END()
};
- cfg_opt_t sec_opts[] =
+ static cfg_opt_t sec_opts[] =
{
CFG_STR_LIST("substring", "{subdefault1, subdefault2}", CFGF_NONE),
CFG_INT_LIST("subinteger", "{17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
27, 28, 29, 300}", CFGF_NONE), /* 14 values */
diff --git a/tests/suite_single.c b/tests/suite_single.c
index cb749d6..ded643f 100644
--- a/tests/suite_single.c
+++ b/tests/suite_single.c
@@ -65,7 +65,7 @@ int parse_ether_address(cfg_t *cfg, cfg_opt_t *opt, const
char *value, void *res
void single_setup(void)
{
- cfg_opt_t subsec_opts[] =
+ static cfg_opt_t subsec_opts[] =
{
CFG_STR("subsubstring", "subsubdefault", CFGF_NONE),
CFG_INT("subsubinteger", -42, CFGF_NONE),
@@ -74,7 +74,7 @@ void single_setup(void)
CFG_END()
};
- cfg_opt_t sec_opts[] =
+ static cfg_opt_t sec_opts[] =
{
CFG_STR("substring", "subdefault", CFGF_NONE),
CFG_INT("subinteger", 17, CFGF_NONE),
@@ -84,7 +84,7 @@ void single_setup(void)
CFG_END()
};
- cfg_opt_t nodef_opts[] =
+ static cfg_opt_t nodef_opts[] =
{
CFG_STR("string", "defvalue", CFGF_NONE),
CFG_INT("int", -17, CFGF_NODEFAULT),
diff --git a/tests/suite_validate.c b/tests/suite_validate.c
index a914bfa..e29f511 100644
--- a/tests/suite_validate.c
+++ b/tests/suite_validate.c
@@ -13,7 +13,7 @@ static cfg_t *cfg = 0;
#define ACTION_CRAWL 3
#define ACTION_JUMP 4
-int parse_action(cfg_t *cfg, cfg_opt_t *opt, const char *value, void *result)
+static int parse_action(cfg_t *cfg, cfg_opt_t *opt, const char *value, void
*result)
{
if(strcmp(value, "run") == 0)
*(int *)result = ACTION_RUN;
@@ -87,7 +87,7 @@ void validate_setup(void)
{
cfg_opt_t *opt = 0;
- cfg_opt_t action_opts[] =
+ static cfg_opt_t action_opts[] =
{
CFG_INT("speed", 0, CFGF_NONE),
CFG_STR("name", 0, CFGF_NONE),
@@ -95,7 +95,7 @@ void validate_setup(void)
CFG_END()
};
- cfg_opt_t multi_opts[] =
+ static cfg_opt_t multi_opts[] =
{
CFG_INT_LIST("speeds", 0, CFGF_NONE),
CFG_SEC("options", action_opts, CFGF_NONE),