diff mbox series

[1/4] libsepol: validate: use fixed sized integers

Message ID 20230714184414.40724-1-cgzones@googlemail.com (mailing list archive)
State Accepted
Commit 511f43478f4f
Delegated to: Petr Lautrbach
Headers show
Series [1/4] libsepol: validate: use fixed sized integers | expand

Commit Message

Christian Göttsche July 14, 2023, 6:44 p.m. UTC
Avoid issues on architectures where unsigned int and uint32_t are not of
the same size.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 libsepol/src/policydb_validate.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

James Carter July 20, 2023, 1:55 p.m. UTC | #1
On Fri, Jul 14, 2023 at 2:53 PM Christian Göttsche
<cgzones@googlemail.com> wrote:
>
> Avoid issues on architectures where unsigned int and uint32_t are not of
> the same size.
>
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>

For this series of four patches:
Acked-by: James Carter <jwcart2@gmail.com>

> ---
>  libsepol/src/policydb_validate.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/libsepol/src/policydb_validate.c b/libsepol/src/policydb_validate.c
> index 08b4a477..7db4ad35 100644
> --- a/libsepol/src/policydb_validate.c
> +++ b/libsepol/src/policydb_validate.c
> @@ -23,7 +23,7 @@ typedef struct map_arg {
>
>  static int create_gap_ebitmap(char **val_to_name, uint32_t nprim, ebitmap_t *gaps)
>  {
> -       unsigned int i;
> +       uint32_t i;
>
>         ebitmap_init(gaps);
>
> @@ -180,7 +180,7 @@ static int validate_scope(__attribute__ ((unused)) hashtab_key_t k, hashtab_datu
>  {
>         const scope_datum_t *scope_datum = (scope_datum_t *)d;
>         const uint32_t *nprim = (uint32_t *)args;
> -       unsigned int i;
> +       uint32_t i;
>
>         switch (scope_datum->scope) {
>         case SCOPE_REQ:
> @@ -205,7 +205,7 @@ static int validate_scopes(sepol_handle_t *handle, const symtab_t scopes[], cons
>  {
>         const avrule_decl_t *decl;
>         unsigned int i;
> -       unsigned int num_decls = 0;
> +       uint32_t num_decls = 0;
>
>         for (; block != NULL; block = block->next) {
>                 for (decl = block->branch_list; decl; decl = decl->next) {
> @@ -685,7 +685,7 @@ static int validate_bool_datum_wrapper(__attribute__((unused)) hashtab_key_t k,
>
>  static int validate_datum_array_gaps(sepol_handle_t *handle, const policydb_t *p, validate_t flavors[])
>  {
> -       unsigned int i;
> +       uint32_t i;
>
>         for (i = 0; i < p->p_classes.nprim; i++) {
>                 if (bool_xnor(p->class_val_to_struct[i], ebitmap_get_bit(&flavors[SYM_CLASSES].gaps, i)))
> @@ -1377,7 +1377,7 @@ bad:
>  static int validate_permissives(sepol_handle_t *handle, const policydb_t *p, validate_t flavors[])
>  {
>         ebitmap_node_t *node;
> -       unsigned i;
> +       uint32_t i;
>
>         ebitmap_for_each_positive_bit(&p->permissive_map, node, i) {
>                 if (validate_simpletype(i, p, flavors))
> @@ -1429,7 +1429,7 @@ static int validate_range_transitions(sepol_handle_t *handle, const policydb_t *
>  static int validate_typeattr_map(sepol_handle_t *handle, const policydb_t *p, validate_t flavors[])
>  {
>         const ebitmap_t *maps = p->type_attr_map;
> -       unsigned int i;
> +       uint32_t i;
>
>         if (p->policy_type == POLICY_KERN) {
>                 for (i = 0; i < p->p_types.nprim; i++) {
> --
> 2.40.1
>
James Carter Aug. 7, 2023, 2:59 p.m. UTC | #2
On Thu, Jul 20, 2023 at 9:55 AM James Carter <jwcart2@gmail.com> wrote:
>
> On Fri, Jul 14, 2023 at 2:53 PM Christian Göttsche
> <cgzones@googlemail.com> wrote:
> >
> > Avoid issues on architectures where unsigned int and uint32_t are not of
> > the same size.
> >
> > Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
>
> For this series of four patches:
> Acked-by: James Carter <jwcart2@gmail.com>
>

This series of four patches has been merged.
Thanks,
Jim

> > ---
> >  libsepol/src/policydb_validate.c | 12 ++++++------
> >  1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/libsepol/src/policydb_validate.c b/libsepol/src/policydb_validate.c
> > index 08b4a477..7db4ad35 100644
> > --- a/libsepol/src/policydb_validate.c
> > +++ b/libsepol/src/policydb_validate.c
> > @@ -23,7 +23,7 @@ typedef struct map_arg {
> >
> >  static int create_gap_ebitmap(char **val_to_name, uint32_t nprim, ebitmap_t *gaps)
> >  {
> > -       unsigned int i;
> > +       uint32_t i;
> >
> >         ebitmap_init(gaps);
> >
> > @@ -180,7 +180,7 @@ static int validate_scope(__attribute__ ((unused)) hashtab_key_t k, hashtab_datu
> >  {
> >         const scope_datum_t *scope_datum = (scope_datum_t *)d;
> >         const uint32_t *nprim = (uint32_t *)args;
> > -       unsigned int i;
> > +       uint32_t i;
> >
> >         switch (scope_datum->scope) {
> >         case SCOPE_REQ:
> > @@ -205,7 +205,7 @@ static int validate_scopes(sepol_handle_t *handle, const symtab_t scopes[], cons
> >  {
> >         const avrule_decl_t *decl;
> >         unsigned int i;
> > -       unsigned int num_decls = 0;
> > +       uint32_t num_decls = 0;
> >
> >         for (; block != NULL; block = block->next) {
> >                 for (decl = block->branch_list; decl; decl = decl->next) {
> > @@ -685,7 +685,7 @@ static int validate_bool_datum_wrapper(__attribute__((unused)) hashtab_key_t k,
> >
> >  static int validate_datum_array_gaps(sepol_handle_t *handle, const policydb_t *p, validate_t flavors[])
> >  {
> > -       unsigned int i;
> > +       uint32_t i;
> >
> >         for (i = 0; i < p->p_classes.nprim; i++) {
> >                 if (bool_xnor(p->class_val_to_struct[i], ebitmap_get_bit(&flavors[SYM_CLASSES].gaps, i)))
> > @@ -1377,7 +1377,7 @@ bad:
> >  static int validate_permissives(sepol_handle_t *handle, const policydb_t *p, validate_t flavors[])
> >  {
> >         ebitmap_node_t *node;
> > -       unsigned i;
> > +       uint32_t i;
> >
> >         ebitmap_for_each_positive_bit(&p->permissive_map, node, i) {
> >                 if (validate_simpletype(i, p, flavors))
> > @@ -1429,7 +1429,7 @@ static int validate_range_transitions(sepol_handle_t *handle, const policydb_t *
> >  static int validate_typeattr_map(sepol_handle_t *handle, const policydb_t *p, validate_t flavors[])
> >  {
> >         const ebitmap_t *maps = p->type_attr_map;
> > -       unsigned int i;
> > +       uint32_t i;
> >
> >         if (p->policy_type == POLICY_KERN) {
> >                 for (i = 0; i < p->p_types.nprim; i++) {
> > --
> > 2.40.1
> >
diff mbox series

Patch

diff --git a/libsepol/src/policydb_validate.c b/libsepol/src/policydb_validate.c
index 08b4a477..7db4ad35 100644
--- a/libsepol/src/policydb_validate.c
+++ b/libsepol/src/policydb_validate.c
@@ -23,7 +23,7 @@  typedef struct map_arg {
 
 static int create_gap_ebitmap(char **val_to_name, uint32_t nprim, ebitmap_t *gaps)
 {
-	unsigned int i;
+	uint32_t i;
 
 	ebitmap_init(gaps);
 
@@ -180,7 +180,7 @@  static int validate_scope(__attribute__ ((unused)) hashtab_key_t k, hashtab_datu
 {
 	const scope_datum_t *scope_datum = (scope_datum_t *)d;
 	const uint32_t *nprim = (uint32_t *)args;
-	unsigned int i;
+	uint32_t i;
 
 	switch (scope_datum->scope) {
 	case SCOPE_REQ:
@@ -205,7 +205,7 @@  static int validate_scopes(sepol_handle_t *handle, const symtab_t scopes[], cons
 {
 	const avrule_decl_t *decl;
 	unsigned int i;
-	unsigned int num_decls = 0;
+	uint32_t num_decls = 0;
 
 	for (; block != NULL; block = block->next) {
 		for (decl = block->branch_list; decl; decl = decl->next) {
@@ -685,7 +685,7 @@  static int validate_bool_datum_wrapper(__attribute__((unused)) hashtab_key_t k,
 
 static int validate_datum_array_gaps(sepol_handle_t *handle, const policydb_t *p, validate_t flavors[])
 {
-	unsigned int i;
+	uint32_t i;
 
 	for (i = 0; i < p->p_classes.nprim; i++) {
 		if (bool_xnor(p->class_val_to_struct[i], ebitmap_get_bit(&flavors[SYM_CLASSES].gaps, i)))
@@ -1377,7 +1377,7 @@  bad:
 static int validate_permissives(sepol_handle_t *handle, const policydb_t *p, validate_t flavors[])
 {
 	ebitmap_node_t *node;
-	unsigned i;
+	uint32_t i;
 
 	ebitmap_for_each_positive_bit(&p->permissive_map, node, i) {
 		if (validate_simpletype(i, p, flavors))
@@ -1429,7 +1429,7 @@  static int validate_range_transitions(sepol_handle_t *handle, const policydb_t *
 static int validate_typeattr_map(sepol_handle_t *handle, const policydb_t *p, validate_t flavors[])
 {
 	const ebitmap_t *maps = p->type_attr_map;
-	unsigned int i;
+	uint32_t i;
 
 	if (p->policy_type == POLICY_KERN) {
 		for (i = 0; i < p->p_types.nprim; i++) {