diff mbox series

[1/3] libsepol: remove unused files

Message ID 20210203085846.6680-1-nicolas.iooss@m4x.org (mailing list archive)
State Accepted
Headers show
Series [1/3] libsepol: remove unused files | expand

Commit Message

Nicolas Iooss Feb. 3, 2021, 8:58 a.m. UTC
libsepol/src/roles.c contains functions which do not match its header
file libsepol/include/sepol/roles.h:

    // In roles.c
    int sepol_role_exists(sepol_handle_t * handle __attribute__ ((unused)),
                          sepol_policydb_t * p, const char *role, int *response)
    // In roles.h
    extern int sepol_role_exists(const sepol_policydb_t * policydb,
                                 const char *role, int *response);

and:

    // In roles.c
    int sepol_role_list(sepol_handle_t * handle,
                        sepol_policydb_t * p, char ***roles, unsigned int *nroles)
    // In roles.h
    extern int sepol_role_list(const sepol_policydb_t * policydb,
                               char ***roles, unsigned int *nroles);

Instead of fixing the parameter type (using sepol_handle_t or
sepol_policydb_t but not different ones), remove these functions, as
they appear not to be used. They are not exported in libsepol.so.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
 libsepol/include/sepol/roles.h | 18 ------------
 libsepol/src/roles.c           | 53 ----------------------------------
 2 files changed, 71 deletions(-)
 delete mode 100644 libsepol/include/sepol/roles.h
 delete mode 100644 libsepol/src/roles.c

Comments

James Carter Feb. 4, 2021, 7:26 p.m. UTC | #1
On Wed, Feb 3, 2021 at 4:00 AM Nicolas Iooss <nicolas.iooss@m4x.org> wrote:
>
> libsepol/src/roles.c contains functions which do not match its header
> file libsepol/include/sepol/roles.h:
>
>     // In roles.c
>     int sepol_role_exists(sepol_handle_t * handle __attribute__ ((unused)),
>                           sepol_policydb_t * p, const char *role, int *response)
>     // In roles.h
>     extern int sepol_role_exists(const sepol_policydb_t * policydb,
>                                  const char *role, int *response);
>
> and:
>
>     // In roles.c
>     int sepol_role_list(sepol_handle_t * handle,
>                         sepol_policydb_t * p, char ***roles, unsigned int *nroles)
>     // In roles.h
>     extern int sepol_role_list(const sepol_policydb_t * policydb,
>                                char ***roles, unsigned int *nroles);
>
> Instead of fixing the parameter type (using sepol_handle_t or
> sepol_policydb_t but not different ones), remove these functions, as
> they appear not to be used. They are not exported in libsepol.so.
>
> Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>

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

> ---
>  libsepol/include/sepol/roles.h | 18 ------------
>  libsepol/src/roles.c           | 53 ----------------------------------
>  2 files changed, 71 deletions(-)
>  delete mode 100644 libsepol/include/sepol/roles.h
>  delete mode 100644 libsepol/src/roles.c
>
> diff --git a/libsepol/include/sepol/roles.h b/libsepol/include/sepol/roles.h
> deleted file mode 100644
> index e750078c8dab..000000000000
> --- a/libsepol/include/sepol/roles.h
> +++ /dev/null
> @@ -1,18 +0,0 @@
> -#ifndef _SEPOL_ROLES_H_
> -#define _SEPOL_ROLES_H_
> -
> -#ifdef __cplusplus
> -extern "C" {
> -#endif
> -
> -extern int sepol_role_exists(const sepol_policydb_t * policydb,
> -                            const char *role, int *response);
> -
> -extern int sepol_role_list(const sepol_policydb_t * policydb,
> -                          char ***roles, unsigned int *nroles);
> -
> -#ifdef __cplusplus
> -}
> -#endif
> -
> -#endif
> diff --git a/libsepol/src/roles.c b/libsepol/src/roles.c
> deleted file mode 100644
> index 4540cee80e19..000000000000
> --- a/libsepol/src/roles.c
> +++ /dev/null
> @@ -1,53 +0,0 @@
> -#include <stdlib.h>
> -#include <string.h>
> -
> -#include <sepol/policydb/hashtab.h>
> -#include <sepol/policydb/policydb.h>
> -
> -#include "debug.h"
> -#include "handle.h"
> -
> -/* Check if a role exists */
> -int sepol_role_exists(sepol_handle_t * handle __attribute__ ((unused)),
> -                     sepol_policydb_t * p, const char *role, int *response)
> -{
> -
> -       policydb_t *policydb = &p->p;
> -       *response = (hashtab_search(policydb->p_roles.table, role) != NULL);
> -
> -       return STATUS_SUCCESS;
> -}
> -
> -/* Fill an array with all valid roles */
> -int sepol_role_list(sepol_handle_t * handle,
> -                   sepol_policydb_t * p, char ***roles, unsigned int *nroles)
> -{
> -
> -       policydb_t *policydb = &p->p;
> -       unsigned int tmp_nroles = policydb->p_roles.nprim;
> -       char **tmp_roles = (char **)malloc(tmp_nroles * sizeof(char *));
> -       char **ptr;
> -       unsigned int i;
> -       if (!tmp_roles)
> -               goto omem;
> -
> -       for (i = 0; i < tmp_nroles; i++) {
> -               tmp_roles[i] = strdup(policydb->p_role_val_to_name[i]);
> -               if (!tmp_roles[i])
> -                       goto omem;
> -       }
> -
> -       *nroles = tmp_nroles;
> -       *roles = tmp_roles;
> -
> -       return STATUS_SUCCESS;
> -
> -      omem:
> -       ERR(handle, "out of memory, could not list roles");
> -
> -       ptr = tmp_roles;
> -       while (ptr && *ptr)
> -               free(*ptr++);
> -       free(tmp_roles);
> -       return STATUS_ERR;
> -}
> --
> 2.30.0
>
Nicolas Iooss Feb. 5, 2021, 9:41 a.m. UTC | #2
On Thu, Feb 4, 2021 at 8:21 PM James Carter <jwcart2@gmail.com> wrote:
>
> On Wed, Feb 3, 2021 at 4:00 AM Nicolas Iooss <nicolas.iooss@m4x.org> wrote:
> >
> > libsepol/src/roles.c contains functions which do not match its header
> > file libsepol/include/sepol/roles.h:
> >
> >     // In roles.c
> >     int sepol_role_exists(sepol_handle_t * handle __attribute__ ((unused)),
> >                           sepol_policydb_t * p, const char *role, int *response)
> >     // In roles.h
> >     extern int sepol_role_exists(const sepol_policydb_t * policydb,
> >                                  const char *role, int *response);
> >
> > and:
> >
> >     // In roles.c
> >     int sepol_role_list(sepol_handle_t * handle,
> >                         sepol_policydb_t * p, char ***roles, unsigned int *nroles)
> >     // In roles.h
> >     extern int sepol_role_list(const sepol_policydb_t * policydb,
> >                                char ***roles, unsigned int *nroles);
> >
> > Instead of fixing the parameter type (using sepol_handle_t or
> > sepol_policydb_t but not different ones), remove these functions, as
> > they appear not to be used. They are not exported in libsepol.so.
> >
> > Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
>
> Acked-by: James Carter <jwcart2@gmail.com>

Merged.
Nicolas

> > ---
> >  libsepol/include/sepol/roles.h | 18 ------------
> >  libsepol/src/roles.c           | 53 ----------------------------------
> >  2 files changed, 71 deletions(-)
> >  delete mode 100644 libsepol/include/sepol/roles.h
> >  delete mode 100644 libsepol/src/roles.c
> >
> > diff --git a/libsepol/include/sepol/roles.h b/libsepol/include/sepol/roles.h
> > deleted file mode 100644
> > index e750078c8dab..000000000000
> > --- a/libsepol/include/sepol/roles.h
> > +++ /dev/null
> > @@ -1,18 +0,0 @@
> > -#ifndef _SEPOL_ROLES_H_
> > -#define _SEPOL_ROLES_H_
> > -
> > -#ifdef __cplusplus
> > -extern "C" {
> > -#endif
> > -
> > -extern int sepol_role_exists(const sepol_policydb_t * policydb,
> > -                            const char *role, int *response);
> > -
> > -extern int sepol_role_list(const sepol_policydb_t * policydb,
> > -                          char ***roles, unsigned int *nroles);
> > -
> > -#ifdef __cplusplus
> > -}
> > -#endif
> > -
> > -#endif
> > diff --git a/libsepol/src/roles.c b/libsepol/src/roles.c
> > deleted file mode 100644
> > index 4540cee80e19..000000000000
> > --- a/libsepol/src/roles.c
> > +++ /dev/null
> > @@ -1,53 +0,0 @@
> > -#include <stdlib.h>
> > -#include <string.h>
> > -
> > -#include <sepol/policydb/hashtab.h>
> > -#include <sepol/policydb/policydb.h>
> > -
> > -#include "debug.h"
> > -#include "handle.h"
> > -
> > -/* Check if a role exists */
> > -int sepol_role_exists(sepol_handle_t * handle __attribute__ ((unused)),
> > -                     sepol_policydb_t * p, const char *role, int *response)
> > -{
> > -
> > -       policydb_t *policydb = &p->p;
> > -       *response = (hashtab_search(policydb->p_roles.table, role) != NULL);
> > -
> > -       return STATUS_SUCCESS;
> > -}
> > -
> > -/* Fill an array with all valid roles */
> > -int sepol_role_list(sepol_handle_t * handle,
> > -                   sepol_policydb_t * p, char ***roles, unsigned int *nroles)
> > -{
> > -
> > -       policydb_t *policydb = &p->p;
> > -       unsigned int tmp_nroles = policydb->p_roles.nprim;
> > -       char **tmp_roles = (char **)malloc(tmp_nroles * sizeof(char *));
> > -       char **ptr;
> > -       unsigned int i;
> > -       if (!tmp_roles)
> > -               goto omem;
> > -
> > -       for (i = 0; i < tmp_nroles; i++) {
> > -               tmp_roles[i] = strdup(policydb->p_role_val_to_name[i]);
> > -               if (!tmp_roles[i])
> > -                       goto omem;
> > -       }
> > -
> > -       *nroles = tmp_nroles;
> > -       *roles = tmp_roles;
> > -
> > -       return STATUS_SUCCESS;
> > -
> > -      omem:
> > -       ERR(handle, "out of memory, could not list roles");
> > -
> > -       ptr = tmp_roles;
> > -       while (ptr && *ptr)
> > -               free(*ptr++);
> > -       free(tmp_roles);
> > -       return STATUS_ERR;
> > -}
> > --
> > 2.30.0
> >
diff mbox series

Patch

diff --git a/libsepol/include/sepol/roles.h b/libsepol/include/sepol/roles.h
deleted file mode 100644
index e750078c8dab..000000000000
--- a/libsepol/include/sepol/roles.h
+++ /dev/null
@@ -1,18 +0,0 @@ 
-#ifndef _SEPOL_ROLES_H_
-#define _SEPOL_ROLES_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern int sepol_role_exists(const sepol_policydb_t * policydb,
-			     const char *role, int *response);
-
-extern int sepol_role_list(const sepol_policydb_t * policydb,
-			   char ***roles, unsigned int *nroles);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/libsepol/src/roles.c b/libsepol/src/roles.c
deleted file mode 100644
index 4540cee80e19..000000000000
--- a/libsepol/src/roles.c
+++ /dev/null
@@ -1,53 +0,0 @@ 
-#include <stdlib.h>
-#include <string.h>
-
-#include <sepol/policydb/hashtab.h>
-#include <sepol/policydb/policydb.h>
-
-#include "debug.h"
-#include "handle.h"
-
-/* Check if a role exists */
-int sepol_role_exists(sepol_handle_t * handle __attribute__ ((unused)),
-		      sepol_policydb_t * p, const char *role, int *response)
-{
-
-	policydb_t *policydb = &p->p;
-	*response = (hashtab_search(policydb->p_roles.table, role) != NULL);
-
-	return STATUS_SUCCESS;
-}
-
-/* Fill an array with all valid roles */
-int sepol_role_list(sepol_handle_t * handle,
-		    sepol_policydb_t * p, char ***roles, unsigned int *nroles)
-{
-
-	policydb_t *policydb = &p->p;
-	unsigned int tmp_nroles = policydb->p_roles.nprim;
-	char **tmp_roles = (char **)malloc(tmp_nroles * sizeof(char *));
-	char **ptr;
-	unsigned int i;
-	if (!tmp_roles)
-		goto omem;
-
-	for (i = 0; i < tmp_nroles; i++) {
-		tmp_roles[i] = strdup(policydb->p_role_val_to_name[i]);
-		if (!tmp_roles[i])
-			goto omem;
-	}
-
-	*nroles = tmp_nroles;
-	*roles = tmp_roles;
-
-	return STATUS_SUCCESS;
-
-      omem:
-	ERR(handle, "out of memory, could not list roles");
-
-	ptr = tmp_roles;
-	while (ptr && *ptr)
-		free(*ptr++);
-	free(tmp_roles);
-	return STATUS_ERR;
-}