Skip to contentSkip to conversation

libsepol: do not use handle when it is marked unused

PATCH Applied Nicolas Iooss 2 participants 4 messages May 31, 2017 – Jun 1, 2017 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 libsepol: do not use handle when it is marked unused

Assigning NULL to handle does not perform anything useful and clang complains about this:

    ibendports.c:122:2: error: 'handle' was marked unused but was used
    [-Werror,-Wused-but-marked-unused]
        handle = NULL;
        ^
    ibpkeys.c:115:2: error: 'handle' was marked unused but was used
    [-Werror,-Wused-but-marked-unused]
        handle = NULL;
        ^
---
 libsepol/src/ibendports.c | 1 -
 libsepol/src/ibpkeys.c    | 1 -
 2 files changed, 2 deletions(-)
libsepol/src/ibendports.c +0 -1
index 0438093e3053..6d56c9a1793f 100644
@@ -119,7 +119,6 @@ extern int sepol_ibendport_count(sepol_handle_t *handle __attribute__ ((unused))
 
 	*response = count;
 
-	handle = NULL;
 	return STATUS_SUCCESS;
 }
 
libsepol/src/ibpkeys.c +0 -1
index ad6c07fe2c2d..682bf5db210c 100644
@@ -112,7 +112,6 @@ extern int sepol_ibpkey_count(sepol_handle_t *handle __attribute__ ((unused)),
 
 	*response = count;
 
-	handle = NULL;
 	return STATUS_SUCCESS;
 }
 
Signature · 1 line
2.12.2
#1 lore raw

PATCH 2/2 libsepol: do not mark db as unused when it is used

---
 libsepol/cil/src/cil_build_ast.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
libsepol/cil/src/cil_build_ast.c +2 -2
index 0a9a5e57491a..7fcee61042c5 100644
@@ -4256,7 +4256,7 @@ void cil_destroy_filecon(struct cil_filecon *filecon)
 	free(filecon);
 }
 
-int cil_gen_ibpkeycon(__attribute__((unused)) struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
+int cil_gen_ibpkeycon(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
 {
 	enum cil_syntax syntax[] = {
 		CIL_SYN_STRING,
@@ -4667,7 +4667,7 @@ void cil_destroy_netifcon(struct cil_netifcon *netifcon)
 	free(netifcon);
 }
 
-int cil_gen_ibendportcon(__attribute__((unused)) struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
+int cil_gen_ibendportcon(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
 {
 	enum cil_syntax syntax[] = {
 		CIL_SYN_STRING,
Signature · 1 line
2.12.2
#2 lore raw

Re: [PATCH 2/2] libsepol: do not mark db as unused when it is used

Quoted 19 lines · Nicolas Iooss
---
  libsepol/cil/src/cil_build_ast.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
libsepol/cil/src/cil_build_ast.c +1 -1
index 0a9a5e57491a..7fcee61042c5 100644
@@ -4256,7 +4256,7 @@ void cil_destroy_filecon(struct cil_filecon *filecon)
  	free(filecon);
  }
 
-int cil_gen_ibpkeycon(__attribute__((unused)) struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
+int cil_gen_ibpkeycon(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
  {
  	enum cil_syntax syntax[] = {
  		CIL_SYN_STRING,

libsepol/cil/src/cil_build_ast.c void cil_destroy_netifcon(struct cil_netifcon *netifcon) · line 4673

Quoted 8 lines
libsepol/cil/src/cil_build_ast.c +1 -1
@@ -4667,7 +4667,7 @@ void cil_destroy_netifcon(struct cil_netifcon *netifcon)
  	free(netifcon);
  }
 
-int cil_gen_ibendportcon(__attribute__((unused)) struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
+int cil_gen_ibendportcon(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
  {
  	enum cil_syntax syntax[] = {
  		CIL_SYN_STRING,

In both cases, the only use of db is to check that it is not null. Better to just remove those checks.

Thanks for the bug report.

Signature · 2 lines
James Carter <[email protected]>
National Security Agency
Applied
#3 lore raw
In reply to Nicolas Iooss
Quoted 12 lines · Nicolas Iooss

Assigning NULL to handle does not perform anything useful and clang complains about this:

     ibendports.c:122:2: error: 'handle' was marked unused but was used
     [-Werror,-Wused-but-marked-unused]
         handle = NULL;
         ^
     ibpkeys.c:115:2: error: 'handle' was marked unused but was used
     [-Werror,-Wused-but-marked-unused]
         handle = NULL;
         ^
Quoted 1 line

Applied.

Thanks,
Jim

Quoted 30 lines
---
  libsepol/src/ibendports.c | 1 -
  libsepol/src/ibpkeys.c    | 1 -
  2 files changed, 2 deletions(-)
libsepol/src/ibendports.c +0 -1
index 0438093e3053..6d56c9a1793f 100644
@@ -119,7 +119,6 @@ extern int sepol_ibendport_count(sepol_handle_t *handle __attribute__ ((unused))
 
  	*response = count;
 
-	handle = NULL;
  	return STATUS_SUCCESS;
  }
 
libsepol/src/ibpkeys.c +0 -1
index ad6c07fe2c2d..682bf5db210c 100644
@@ -112,7 +112,6 @@ extern int sepol_ibpkey_count(sepol_handle_t *handle __attribute__ ((unused)),
 
  	*response = count;
 
-	handle = NULL;
  	return STATUS_SUCCESS;
  }
 
Signature · 2 lines
James Carter <[email protected]>
National Security Agency