Skip to contentSkip to conversation

libsepol: Remove unnecessary copying of declarations from link.c

PATCH In review James Carter 2 participants 3 messages Mar 11, 2021 – Mar 15, 2021 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libsepol: Remove unnecessary copying of declarations from link.c

At one point link_modules() might have needed this initial copying, but now it serves no purpose, so remove it.

---
 libsepol/src/link.c | 30 ------------------------------
 1 file changed, 30 deletions(-)
libsepol/src/link.c +0 -30
index 83bbc8a5..bdc1fcbf 100644
@@ -2573,36 +2573,6 @@ int link_modules(sepol_handle_t * handle,
 		goto cleanup;
 	}
 
-	/* copy all types, declared and required */
-	for (i = 0; i < len; i++) {
-		state.cur = modules[i];
-		state.cur_mod_name = modules[i]->policy->name;
-		ret =
-		    hashtab_map(modules[i]->policy->p_types.table,
-				type_copy_callback, &state);
-		if (ret) {
-			retval = ret;
-			goto cleanup;
-		}
-	}
-
-	/* then copy everything else, including aliases, and fixup attributes */
-	for (i = 0; i < len; i++) {
-		state.cur = modules[i];
-		state.cur_mod_name = modules[i]->policy->name;
-		ret =
-		    copy_identifiers(&state, modules[i]->policy->symtab, NULL);
-		if (ret) {
-			retval = ret;
-			goto cleanup;
-		}
-	}
-
-	if (policydb_index_others(state.handle, state.base, 0)) {
-		ERR(state.handle, "Error while indexing others");
-		goto cleanup;
-	}
-
 	/* copy and remap the module's data over to base */
 	for (i = 0; i < len; i++) {
 		state.cur = modules[i];
Signature · 1 line
2.26.2
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · James Carter

At one point link_modules() might have needed this initial copying, but now it serves no purpose, so remove it.

Quoted 48 lines
---
 libsepol/src/link.c | 30 ------------------------------
 1 file changed, 30 deletions(-)
libsepol/src/link.c +0 -31
index 83bbc8a5..bdc1fcbf 100644
@@ -2573,36 +2573,6 @@ int link_modules(sepol_handle_t * handle,
                goto cleanup;
        }
 
-       /* copy all types, declared and required */
-       for (i = 0; i < len; i++) {
-               state.cur = modules[i];
-               state.cur_mod_name = modules[i]->policy->name;
-               ret =
-                   hashtab_map(modules[i]->policy->p_types.table,
-                               type_copy_callback, &state);
-               if (ret) {
-                       retval = ret;
-                       goto cleanup;
-               }
-       }
-
-       /* then copy everything else, including aliases, and fixup attributes */
-       for (i = 0; i < len; i++) {
-               state.cur = modules[i];
-               state.cur_mod_name = modules[i]->policy->name;
-               ret =
-                   copy_identifiers(&state, modules[i]->policy->symtab, NULL);
-               if (ret) {
-                       retval = ret;
-                       goto cleanup;
-               }
-       }
-
-       if (policydb_index_others(state.handle, state.base, 0)) {
-               ERR(state.handle, "Error while indexing others");
-               goto cleanup;
-       }
-
        /* copy and remap the module's data over to base */
        for (i = 0; i < len; i++) {
                state.cur = modules[i];
--

2.26.2

#2 lore raw
Quoted 9 lines · Nicolas Iooss
Quoted 5 lines · James Carter

At one point link_modules() might have needed this initial copying, but now it serves no purpose, so remove it.

Merged.

Thanks!
Nicolas

Quoted 48 lines
Quoted 48 lines
---
 libsepol/src/link.c | 30 ------------------------------
 1 file changed, 30 deletions(-)
libsepol/src/link.c +0 -31
index 83bbc8a5..bdc1fcbf 100644
@@ -2573,36 +2573,6 @@ int link_modules(sepol_handle_t * handle,
                goto cleanup;
        }
 
-       /* copy all types, declared and required */
-       for (i = 0; i < len; i++) {
-               state.cur = modules[i];
-               state.cur_mod_name = modules[i]->policy->name;
-               ret =
-                   hashtab_map(modules[i]->policy->p_types.table,
-                               type_copy_callback, &state);
-               if (ret) {
-                       retval = ret;
-                       goto cleanup;
-               }
-       }
-
-       /* then copy everything else, including aliases, and fixup attributes */
-       for (i = 0; i < len; i++) {
-               state.cur = modules[i];
-               state.cur_mod_name = modules[i]->policy->name;
-               ret =
-                   copy_identifiers(&state, modules[i]->policy->symtab, NULL);
-               if (ret) {
-                       retval = ret;
-                       goto cleanup;
-               }
-       }
-
-       if (policydb_index_others(state.handle, state.base, 0)) {
-               ERR(state.handle, "Error while indexing others");
-               goto cleanup;
-       }
-
        /* copy and remap the module's data over to base */
        for (i = 0; i < len; i++) {
                state.cur = modules[i];
--

2.26.2