Skip to content

Commit

Permalink
Constify read-only variables
Browse files Browse the repository at this point in the history
  • Loading branch information
cgzones committed Jan 8, 2024
1 parent 1e7fe2d commit dfa796e
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/check_hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ void display_check_issue_counts(const struct checks *ck)
qsort((void *) node_arr, num_nodes, sizeof(struct check_node *), comp_check_nodes);

unsigned int issue_count = 0;
char *old_issue_name = NULL;
const char *old_issue_name = NULL;
for (unsigned int i=0; i < num_nodes; i++) {
if (old_issue_name && 0 != strcmp(old_issue_name, node_arr[i]->check_id)) {
// New issue. Print the old info
Expand Down
2 changes: 1 addition & 1 deletion src/parse_fc.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ struct sel_context *parse_context(char *context_str)
struct sel_context *context = xmalloc(sizeof(struct sel_context));
memset(context, 0, sizeof(struct sel_context));
// User
char *pos = strtok(context_str, ":");
const char *pos = strtok(context_str, ":");

if (pos == NULL) {
goto cleanup;
Expand Down
6 changes: 3 additions & 3 deletions src/parse_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ enum selint_error insert_declaration(struct policy_node **cur,
// If the name starts with $ we're probably doing something like associating
// a role with types in interfaces

char *mn = get_current_module_name();
const char *mn = get_current_module_name();

if (!mn) {
return SELINT_NO_MOD_NAME;
Expand Down Expand Up @@ -155,7 +155,7 @@ enum selint_error insert_aliases(struct policy_node **cur,
insert_decl_into_template_map(temp_name, flavor,
alias->string);
} else {
char *mn = get_current_module_name();
const char *mn = get_current_module_name();
if (!mn) {
free_string_list(aliases);
return SELINT_NO_MOD_NAME;
Expand Down Expand Up @@ -382,7 +382,7 @@ enum selint_error insert_role_transition(struct policy_node **cur,
struct string_list *sources,
struct string_list *targets,
struct string_list *object_classes,
char *default_role,
const char *default_role,
unsigned int lineno)
{
struct role_transition_data *rt_data =
Expand Down
2 changes: 1 addition & 1 deletion src/parse_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ enum selint_error insert_role_transition(struct policy_node **cur,
struct string_list *sources,
struct string_list *targets,
struct string_list *object_classes,
char *default_role,
const char *default_role,
unsigned int lineno);

enum selint_error insert_interface_call(struct policy_node **cur, const char *if_name,
Expand Down
8 changes: 4 additions & 4 deletions src/startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ enum selint_error load_access_vectors_kernel(const char *av_path)

FTS *ftsp = fts_open(paths, FTS_PHYSICAL, NULL);

FTSENT *file = fts_read(ftsp);
const FTSENT *file = fts_read(ftsp);

while (file) {

Expand Down Expand Up @@ -219,14 +219,14 @@ enum selint_error load_modules_source(const char *modules_conf_path)
fclose(fd);
return SELINT_PARSE_ERROR;
}
char *mod_name = strip_space(pos);
const char *mod_name = strip_space(pos);
pos = strtok(NULL, "=");
if (!pos) {
free(line);
fclose(fd);
return SELINT_PARSE_ERROR;
}
char *status = strip_space(pos);
const char *status = strip_space(pos);
insert_into_mods_map(mod_name, status);
if (strtok(NULL, "=")) {
free(line);
Expand Down Expand Up @@ -296,7 +296,7 @@ enum selint_error load_devel_headers(struct policy_file_list *context_files)

FTS *ftsp = fts_open(paths, FTS_PHYSICAL | FTS_NOSTAT, NULL);

FTSENT *file = fts_read(ftsp);
const FTSENT *file = fts_read(ftsp);
while (file) {
const char *suffix = (file->fts_pathlen > 3) ? (file->fts_path + file->fts_pathlen - 3) : NULL;
if (suffix && !strcmp(suffix, ".if")) {
Expand Down
2 changes: 1 addition & 1 deletion src/te_checks.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ struct check_result *check_no_self(__attribute__((unused)) const struct check_da
if (node->flavor != NODE_AV_RULE && node->flavor != NODE_XAV_RULE) {
return alloc_internal_error("Bad node type given to check C-007");
}
struct av_rule_data *av_data = node->data.av_data;
const struct av_rule_data *av_data = node->data.av_data;

if (av_data->sources->next ||
av_data->targets->next ||
Expand Down
18 changes: 9 additions & 9 deletions src/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int is_template_call(const struct policy_node *node)
return 0;
}

char *call_name = node->data.ic_data->name;
const char *call_name = node->data.ic_data->name;

if (look_up_in_template_map(call_name)) {
return 1;
Expand Down Expand Up @@ -149,14 +149,14 @@ struct name_list *get_names_in_node(const struct policy_node *node)

struct name_list *ret = NULL;
struct name_list *cur = NULL;
struct av_rule_data *av_data;
struct type_transition_data *tt_data;
struct role_transition_data *rt_data;
struct declaration_data *d_data;
struct if_call_data *ifc_data;
struct role_allow_data *ra_data;
struct role_types_data *rtyp_data;
struct attribute_data *at_data;
const struct av_rule_data *av_data;
const struct type_transition_data *tt_data;
const struct role_transition_data *rt_data;
const struct declaration_data *d_data;
const struct if_call_data *ifc_data;
const struct role_allow_data *ra_data;
const struct role_types_data *rtyp_data;
const struct attribute_data *at_data;

switch (node->flavor) {
case NODE_AV_RULE:
Expand Down

0 comments on commit dfa796e

Please sign in to comment.