Browse Source

cfg framework: fix sanity checks (again)

The previous sanity check fix wrongly assumed that CFG_VAR_MASK
would return 1<<type and not type.
Andrei Pelinescu-Onciul 16 years ago
parent
commit
e06c100b97
1 changed files with 2 additions and 2 deletions
  1. 2 2
      cfg/cfg.c

+ 2 - 2
cfg/cfg.c

@@ -66,7 +66,7 @@ int cfg_declare(char *group_name, cfg_def_t *def, void *values, int def_size,
 		mapping[i].def = &(def[i]);
 		mapping[i].name_len = strlen(def[i].name);
 		/* record all the types for sanity checks */
-		types|=CFG_VAR_MASK(def[i].type);
+		types|=1 << CFG_VAR_MASK(def[i].type);
 
 		/* padding depends on the type of the next variable */
 		switch (CFG_VAR_MASK(def[i].type)) {
@@ -133,7 +133,7 @@ int cfg_declare(char *group_name, cfg_def_t *def, void *values, int def_size,
 
 	/* fix the computed size (char*, str or pointer members will force 
 	   structure padding to multiple of sizeof(pointer)) */
-	if (types & (CFG_VAR_STRING|CFG_VAR_STR|CFG_VAR_POINTER))
+	if (types & ((1<<CFG_VAR_STRING)|(1<<CFG_VAR_STR)|(1<<CFG_VAR_POINTER)))
 		size=ROUND_POINTER(size);
 	/* minor validation */
 	if (size != def_size) {