diff mbox series

libsepol: use explicit type for function parameters

Message ID 20230714182918.30917-1-cgzones@googlemail.com (mailing list archive)
State Not Applicable
Delegated to: Petr Lautrbach
Headers show
Series libsepol: use explicit type for function parameters | expand

Commit Message

Christian Göttsche July 14, 2023, 6:29 p.m. UTC
Use a pointer to the explicit type struct policy_file instead of void
for increased type safety and readability.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 libsepol/include/sepol/policydb/avtab.h | 2 +-
 libsepol/src/avtab.c                    | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

Comments

James Carter July 31, 2023, 7:54 p.m. UTC | #1
On Fri, Jul 14, 2023 at 2:46 PM Christian Göttsche
<cgzones@googlemail.com> wrote:
>
> Use a pointer to the explicit type struct policy_file instead of void
> for increased type safety and readability.
>
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>

Acked-by: James Carter <jwcart2@gmail.com>

> ---
>  libsepol/include/sepol/policydb/avtab.h | 2 +-
>  libsepol/src/avtab.c                    | 6 +++---
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/libsepol/include/sepol/policydb/avtab.h b/libsepol/include/sepol/policydb/avtab.h
> index 7d892879..2bb583f5 100644
> --- a/libsepol/include/sepol/policydb/avtab.h
> +++ b/libsepol/include/sepol/policydb/avtab.h
> @@ -158,7 +158,7 @@ extern int avtab_insert_filename_trans(avtab_t *a, avtab_key_t *key,
>                                        uint32_t otype, const char *name,
>                                        uint8_t name_match,
>                                        uint32_t *present_otype);
> -extern int avtab_filename_trans_read(void *fp, uint32_t vers, avtab_t *a);
> +extern int avtab_filename_trans_read(struct policy_file *fp, uint32_t vers, avtab_t *a);
>
>  #ifdef __cplusplus
>  }
> diff --git a/libsepol/src/avtab.c b/libsepol/src/avtab.c
> index 99fdaa87..7a35fc17 100644
> --- a/libsepol/src/avtab.c
> +++ b/libsepol/src/avtab.c
> @@ -843,7 +843,7 @@ bad:
>         return rc;
>  }
>
> -static int filename_trans_read_one(avtab_t *a, void *fp)
> +static int filename_trans_read_one(avtab_t *a, struct policy_file *fp)
>  {
>         int rc;
>         uint32_t buf[4], len, otype;
> @@ -882,7 +882,7 @@ err:
>         return SEPOL_ERR;
>  }
>
> -static int filename_trans_comp_read_one(avtab_t *a, void *fp)
> +static int filename_trans_comp_read_one(avtab_t *a, struct policy_file *fp)
>  {
>         int rc;
>         uint32_t buf[3], len, ndatum, i, bit, otype;
> @@ -941,7 +941,7 @@ err:
>         return rc;
>  }
>
> -int avtab_filename_trans_read(void *fp, uint32_t vers, avtab_t *a)
> +int avtab_filename_trans_read(struct policy_file *fp, uint32_t vers, avtab_t *a)
>  {
>         uint32_t buf[1], nel, i;
>         int rc;
> --
> 2.40.1
>
James Carter Aug. 7, 2023, 1:41 p.m. UTC | #2
On Mon, Jul 31, 2023 at 3:54 PM James Carter <jwcart2@gmail.com> wrote:
>
> On Fri, Jul 14, 2023 at 2:46 PM Christian Göttsche
> <cgzones@googlemail.com> wrote:
> >
> > Use a pointer to the explicit type struct policy_file instead of void
> > for increased type safety and readability.
> >
> > Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
>
> Acked-by: James Carter <jwcart2@gmail.com>
>

This patch was for the prefix/suffix patches, so it is no longer applicable.
Jim

> > ---
> >  libsepol/include/sepol/policydb/avtab.h | 2 +-
> >  libsepol/src/avtab.c                    | 6 +++---
> >  2 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/libsepol/include/sepol/policydb/avtab.h b/libsepol/include/sepol/policydb/avtab.h
> > index 7d892879..2bb583f5 100644
> > --- a/libsepol/include/sepol/policydb/avtab.h
> > +++ b/libsepol/include/sepol/policydb/avtab.h
> > @@ -158,7 +158,7 @@ extern int avtab_insert_filename_trans(avtab_t *a, avtab_key_t *key,
> >                                        uint32_t otype, const char *name,
> >                                        uint8_t name_match,
> >                                        uint32_t *present_otype);
> > -extern int avtab_filename_trans_read(void *fp, uint32_t vers, avtab_t *a);
> > +extern int avtab_filename_trans_read(struct policy_file *fp, uint32_t vers, avtab_t *a);
> >
> >  #ifdef __cplusplus
> >  }
> > diff --git a/libsepol/src/avtab.c b/libsepol/src/avtab.c
> > index 99fdaa87..7a35fc17 100644
> > --- a/libsepol/src/avtab.c
> > +++ b/libsepol/src/avtab.c
> > @@ -843,7 +843,7 @@ bad:
> >         return rc;
> >  }
> >
> > -static int filename_trans_read_one(avtab_t *a, void *fp)
> > +static int filename_trans_read_one(avtab_t *a, struct policy_file *fp)
> >  {
> >         int rc;
> >         uint32_t buf[4], len, otype;
> > @@ -882,7 +882,7 @@ err:
> >         return SEPOL_ERR;
> >  }
> >
> > -static int filename_trans_comp_read_one(avtab_t *a, void *fp)
> > +static int filename_trans_comp_read_one(avtab_t *a, struct policy_file *fp)
> >  {
> >         int rc;
> >         uint32_t buf[3], len, ndatum, i, bit, otype;
> > @@ -941,7 +941,7 @@ err:
> >         return rc;
> >  }
> >
> > -int avtab_filename_trans_read(void *fp, uint32_t vers, avtab_t *a)
> > +int avtab_filename_trans_read(struct policy_file *fp, uint32_t vers, avtab_t *a)
> >  {
> >         uint32_t buf[1], nel, i;
> >         int rc;
> > --
> > 2.40.1
> >
diff mbox series

Patch

diff --git a/libsepol/include/sepol/policydb/avtab.h b/libsepol/include/sepol/policydb/avtab.h
index 7d892879..2bb583f5 100644
--- a/libsepol/include/sepol/policydb/avtab.h
+++ b/libsepol/include/sepol/policydb/avtab.h
@@ -158,7 +158,7 @@  extern int avtab_insert_filename_trans(avtab_t *a, avtab_key_t *key,
 				       uint32_t otype, const char *name,
 				       uint8_t name_match,
 				       uint32_t *present_otype);
-extern int avtab_filename_trans_read(void *fp, uint32_t vers, avtab_t *a);
+extern int avtab_filename_trans_read(struct policy_file *fp, uint32_t vers, avtab_t *a);
 
 #ifdef __cplusplus
 }
diff --git a/libsepol/src/avtab.c b/libsepol/src/avtab.c
index 99fdaa87..7a35fc17 100644
--- a/libsepol/src/avtab.c
+++ b/libsepol/src/avtab.c
@@ -843,7 +843,7 @@  bad:
 	return rc;
 }
 
-static int filename_trans_read_one(avtab_t *a, void *fp)
+static int filename_trans_read_one(avtab_t *a, struct policy_file *fp)
 {
 	int rc;
 	uint32_t buf[4], len, otype;
@@ -882,7 +882,7 @@  err:
 	return SEPOL_ERR;
 }
 
-static int filename_trans_comp_read_one(avtab_t *a, void *fp)
+static int filename_trans_comp_read_one(avtab_t *a, struct policy_file *fp)
 {
 	int rc;
 	uint32_t buf[3], len, ndatum, i, bit, otype;
@@ -941,7 +941,7 @@  err:
 	return rc;
 }
 
-int avtab_filename_trans_read(void *fp, uint32_t vers, avtab_t *a)
+int avtab_filename_trans_read(struct policy_file *fp, uint32_t vers, avtab_t *a)
 {
 	uint32_t buf[1], nel, i;
 	int rc;