mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
Fix strict aliasing issue that triggered a bug in the parser_symtab unit
tests. I don't like the solution because it exposes a data structure definition outside of the only file that should know it's layout. Also, fixed the Makefile to fail the build when one of the unit test programs fails. :-(
This commit is contained in:
parent
2a0df39961
commit
3b9b2158c1
2 changed files with 9 additions and 13 deletions
|
@ -214,7 +214,7 @@ check: tests
|
||||||
|
|
||||||
.SILENT: tests
|
.SILENT: tests
|
||||||
tests: ${TESTS}
|
tests: ${TESTS}
|
||||||
for test in ${TESTS} ; do echo "*** running $${test}" && ./$${test} $(BUILD_OUTPUT) ; done
|
sh -e -c 'for test in ${TESTS} ; do echo "*** running $${test}" && ./$${test} $(BUILD_OUTPUT) ; done'
|
||||||
$(Q)make -s -C tst tests
|
$(Q)make -s -C tst tests
|
||||||
|
|
||||||
.SILENT: check
|
.SILENT: check
|
||||||
|
|
|
@ -33,11 +33,6 @@ enum var_type {
|
||||||
sd_set,
|
sd_set,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct set_value {
|
|
||||||
char *val;
|
|
||||||
struct set_value *next;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct symtab {
|
struct symtab {
|
||||||
char *var_name;
|
char *var_name;
|
||||||
enum var_type type;
|
enum var_type type;
|
||||||
|
@ -288,7 +283,7 @@ out:
|
||||||
|
|
||||||
/* returns a pointer to the value list, which should be used as the
|
/* returns a pointer to the value list, which should be used as the
|
||||||
* argument to the get_next_set_value() function. */
|
* argument to the get_next_set_value() function. */
|
||||||
void *get_set_var(const char *var)
|
struct set_value *get_set_var(const char *var)
|
||||||
{
|
{
|
||||||
struct symtab *result;
|
struct symtab *result;
|
||||||
struct set_value *valuelist = NULL;
|
struct set_value *valuelist = NULL;
|
||||||
|
@ -321,16 +316,17 @@ out:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* iterator to walk the list of set values */
|
/* iterator to walk the list of set values */
|
||||||
char *get_next_set_value(void **list)
|
char *get_next_set_value(struct set_value **list)
|
||||||
{
|
{
|
||||||
struct set_value **valuelist = (struct set_value **) list;
|
struct set_value *next;
|
||||||
char *ret;
|
char *ret;
|
||||||
|
|
||||||
if (!valuelist || !(*valuelist))
|
if (!list || !(*list))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ret = (*valuelist)->val;
|
ret = (*list)->val;
|
||||||
(*valuelist) = (*valuelist)->next;
|
next = (*list)->next;
|
||||||
|
(*list) = next;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -569,7 +565,7 @@ int main(void)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
int retval;
|
int retval;
|
||||||
void *retptr;
|
struct set_value *retptr;
|
||||||
struct symtab *a, *b;
|
struct symtab *a, *b;
|
||||||
|
|
||||||
a = new_symtab_entry("blah");
|
a = new_symtab_entry("blah");
|
||||||
|
|
Loading…
Add table
Reference in a new issue