checkpolicy: use calloc() so no need to do memset()
PATCH v3 1/1 checkpolicy: use calloc() so no need to do memset()
Signed-off-by Kalevi Kolttonen <[email protected]>
--- checkpolicy/checkpolicy.c | 4 +--- checkpolicy/module_compiler.c | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-)
checkpolicy/checkpolicy.c +1 -3
@@ -235,13 +235,11 @@ static int identify_equiv_types(void)* Create a list of access vector rules for each type * from the access vector table. */ - type_rules =malloc (sizeof (struct avtab_node ) * policydb.p_types.nprim); + type_rules =calloc (policydb.p_types.nprim,sizeof (struct avtab_node ));if (!type_rules) {fprintf (stderr,"out of memory\n" );exit (1 ); } -memset (type_rules,0 , -sizeof (struct avtab_node ) * policydb.p_types.nprim);if (avtab_map (&policydb.te_avtab, create_type_rules, type_rules))exit (1 );
checkpolicy/module_compiler.c +1 -2
@@ -842,12 +842,11 @@ int require_class(int pass)return -1 ; } allocated =1 ; -if ((perm =malloc (sizeof (*perm))) ==NULL ) { +if ((perm =calloc (1 ,sizeof (*perm))) ==NULL ) {yyerror ("Out of memory!" );free (perm_id);return -1 ; } -memset (perm,0 ,sizeof (*perm)); ret =hashtab_insert (datum->permissions.table, perm_id, perm);
Signature · 1 line
2.54.0
Quoted 2 lines · Kalevi Kolttonen
Signed-off-by Kalevi Kolttonen <[email protected]>
Acked-by James Carter <[email protected]>
Quoted 46 lines
--- checkpolicy/checkpolicy.c | 4 +--- checkpolicy/module_compiler.c | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-)checkpolicy/checkpolicy.c +1
-3@@ -235,13 +235,11 @@ static int identify_equiv_types(void)* Create a list of access vector rules for each type * from the access vector table. */ - type_rules =malloc (sizeof (struct avtab_node ) * policydb.p_types.nprim); + type_rules =calloc (policydb.p_types.nprim,sizeof (struct avtab_node ));if (!type_rules) {fprintf (stderr,"out of memory\n" );exit (1 ); } -memset (type_rules,0 , -sizeof (struct avtab_node ) * policydb.p_types.nprim);if (avtab_map (&policydb.te_avtab, create_type_rules, type_rules))exit (1 );checkpolicy/module_compiler.c +1
-3@@ -842,12 +842,11 @@ int require_class(int pass)return -1 ; } allocated =1 ; -if ((perm =malloc (sizeof (*perm))) ==NULL ) { +if ((perm =calloc (1 ,sizeof (*perm))) ==NULL ) {yyerror ("Out of memory!" );free (perm_id);return -1 ; } -memset (perm,0 ,sizeof (*perm)); ret =hashtab_insert (datum->permissions.table, perm_id, perm); --2.54.0
Quoted 7 lines · James Carter
Quoted 2 lines · Kalevi Kolttonen
Signed-off-by Kalevi Kolttonen <[email protected]>Acked-by James Carter <[email protected]>
Merged.
Thanks,
Jim
Quoted 46 lines
Quoted 46 lines
--- checkpolicy/checkpolicy.c | 4 +--- checkpolicy/module_compiler.c | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-)checkpolicy/checkpolicy.c +1
-3@@ -235,13 +235,11 @@ static int identify_equiv_types(void)* Create a list of access vector rules for each type * from the access vector table. */ - type_rules =malloc (sizeof (struct avtab_node ) * policydb.p_types.nprim); + type_rules =calloc (policydb.p_types.nprim,sizeof (struct avtab_node ));if (!type_rules) {fprintf (stderr,"out of memory\n" );exit (1 ); } -memset (type_rules,0 , -sizeof (struct avtab_node ) * policydb.p_types.nprim);if (avtab_map (&policydb.te_avtab, create_type_rules, type_rules))exit (1 );checkpolicy/module_compiler.c +1
-3@@ -842,12 +842,11 @@ int require_class(int pass)return -1 ; } allocated =1 ; -if ((perm =malloc (sizeof (*perm))) ==NULL ) { +if ((perm =calloc (1 ,sizeof (*perm))) ==NULL ) {yyerror ("Out of memory!" );free (perm_id);return -1 ; } -memset (perm,0 ,sizeof (*perm)); ret =hashtab_insert (datum->permissions.table, perm_id, perm); --2.54.0