Re: [PATCH 5/6] libsepol/cil: Remove path field from cil_tree_node struct

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 04/20/2016 10:48 AM, Steve Lawrence wrote:
On 04/19/2016 10:26 AM, James Carter wrote:
Remove path field from cil_tree_node struct and all references
to it in CIL. This will reduce memory usage by 5%.

Signed-off-by: James Carter <jwcart2@xxxxxxxxxxxxx>
---
  libsepol/cil/src/cil_binary.c    | 14 +++++++++++++-
  libsepol/cil/src/cil_build_ast.c |  2 --
  libsepol/cil/src/cil_copy_ast.c  |  1 -
  libsepol/cil/src/cil_parser.c    | 23 +++++++++++------------
  libsepol/cil/src/cil_tree.c      |  1 -
  libsepol/cil/src/cil_tree.h      |  1 -
  6 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/libsepol/cil/src/cil_binary.c b/libsepol/cil/src/cil_binary.c
index 0a98ecd..9db42d5 100644
--- a/libsepol/cil/src/cil_binary.c
+++ b/libsepol/cil/src/cil_binary.c
@@ -4227,6 +4227,9 @@ exit:
  static avrule_t *__cil_init_sepol_avrule(uint32_t kind, struct cil_tree_node *node)
  {
  	avrule_t *avrule;
+	struct cil_tree_node *source_node;
+	char *source_path;
+	int is_cil;

  	avrule = cil_malloc(sizeof(avrule_t));
  	avrule->specified = kind;
@@ -4235,8 +4238,17 @@ static avrule_t *__cil_init_sepol_avrule(uint32_t kind, struct cil_tree_node *no
  	__cil_init_sepol_type_set(&avrule->ttypes);
  	avrule->perms = NULL;
  	avrule->line = node->line;
-	avrule->source_filename = node->path;
+
+	avrule->source_filename = NULL;
  	avrule->source_line = node->line;
+	source_node = cil_tree_get_next_path(node, &source_path, &is_cil);
+	if (source_node) {
+		avrule->source_filename = source_path;
+		if (!is_cil) {
+			avrule->source_line = node->hll_line;

Can we not use ->line instead of ->hll_live when is_cil is true?


Actually, neither source_filename nor source_line will be used because CIL is using its own functions to print error messages.

+		}
+	}
+
  	avrule->next = NULL;
  	return avrule;
  }


--
James Carter <jwcart2@xxxxxxxxxxxxx>
National Security Agency
_______________________________________________
Selinux mailing list
Selinux@xxxxxxxxxxxxx
To unsubscribe, send email to Selinux-leave@xxxxxxxxxxxxx.
To get help, send an email containing "help" to Selinux-request@xxxxxxxxxxxxx.



[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux