Lines Matching full:vec

187 static bool vec_is_stale(struct aa_profile **vec, int n)  in vec_is_stale()  argument
191 AA_BUG(!vec); in vec_is_stale()
194 if (profile_is_stale(vec[i])) in vec_is_stale()
213 u |= new->vec[i]->label.flags & (FLAG_DEBUG1 | FLAG_DEBUG2 | in accum_label_info()
215 if (!(u & new->vec[i]->label.flags & FLAG_UNCONFINED)) in accum_label_info()
217 new->mediates |= new->vec[i]->label.mediates; in accum_label_info()
228 * assumes vec is sorted
229 * Assumes @vec has null terminator at vec[n], and will null terminate
230 * vec[n - dups]
232 static inline int unique(struct aa_profile **vec, int n) in unique() argument
237 AA_BUG(!vec); in unique()
241 int res = profile_cmp(vec[pos], vec[i]); in unique()
243 AA_BUG(res > 0, "vec not sorted"); in unique()
246 aa_put_profile(vec[i]); in unique()
252 vec[pos] = vec[i]; in unique()
263 * @vec: list of profiles to sort and merge
264 * @flags: null terminator flags of @vec
268 * If @flags & VEC_FLAG_TERMINATE @vec has null terminator at vec[n], and will
269 * null terminate vec[n - dups]
271 int aa_vec_unique(struct aa_profile **vec, int n, int flags) in aa_vec_unique() argument
276 AA_BUG(!vec); in aa_vec_unique()
280 sort(vec, n, sizeof(struct aa_profile *), sort_cmp, NULL); in aa_vec_unique()
281 dups = unique(vec, n); in aa_vec_unique()
287 struct aa_profile *tmp = vec[i]; in aa_vec_unique()
291 int res = profile_cmp(vec[pos], tmp); in aa_vec_unique()
305 vec[j] = vec[j - 1]; in aa_vec_unique()
306 vec[pos] = tmp; in aa_vec_unique()
315 vec[n - dups] = NULL; in aa_vec_unique()
333 label->vec[i.i] = (struct aa_profile *) in aa_label_destroy()
388 on_list_rcu(&label->vec[0]->base.profiles)); in aa_label_kref()
390 on_list_rcu(&label->vec[0]->base.list)); in aa_label_kref()
414 label->vec[size] = NULL; /* null terminate */ in aa_label_init()
436 /* + 1 for null terminator entry on vec */ in aa_label_alloc()
437 new = kzalloc(struct_size(new, vec, size + 1), gfp); in aa_label_alloc()
479 return vec_cmp(a->vec, a->size, b->vec, b->size); in label_cmp()
489 if (!profile_unconfined(label->vec[i])) in aa_label_next_confined()
518 int res = profile_cmp(sub->vec[I->j], set->vec[I->i]); in __aa_label_next_not_in_set()
526 return sub->vec[(I->j)++]; in __aa_label_next_not_in_set()
530 return sub->vec[(I->j)++]; in __aa_label_next_not_in_set()
719 * __vec_find - find label that matches @vec in label set
720 * @vec: vec of profiles to find matching label for (NOT NULL)
721 * @n: length of @vec
723 * Requires: @vec_labelset(vec) lock held
728 * else NULL if @vec equiv is not in tree
730 static struct aa_label *__vec_find(struct aa_profile **vec, int n) in __vec_find() argument
734 AA_BUG(!vec); in __vec_find()
735 AA_BUG(!*vec); in __vec_find()
738 node = vec_labelset(vec, n)->root.rb_node; in __vec_find()
741 int result = vec_cmp(this->vec, this->size, vec, n); in __vec_find()
769 return __vec_find(label->vec, label->size); in __label_find()
838 * @vec: array of profiles to find equiv label for (NOT NULL)
839 * @n: length of @vec
841 * Returns: refcounted label if @vec equiv is in tree
842 * else NULL if @vec equiv is not in tree
844 static struct aa_label *vec_find(struct aa_profile **vec, int n) in vec_find() argument
850 AA_BUG(!vec); in vec_find()
851 AA_BUG(!*vec); in vec_find()
854 ls = vec_labelset(vec, n); in vec_find()
856 label = __vec_find(vec, n); in vec_find()
863 static struct aa_label *vec_create_and_insert_label(struct aa_profile **vec, in vec_create_and_insert_label() argument
872 AA_BUG(!vec); in vec_create_and_insert_label()
875 return aa_get_label(&vec[0]->label); in vec_create_and_insert_label()
877 ls = labels_set(&vec[len - 1]->label); in vec_create_and_insert_label()
887 new->vec[i] = aa_get_profile(vec[i]); in vec_create_and_insert_label()
897 struct aa_label *aa_vec_find_or_create_label(struct aa_profile **vec, int len, in aa_vec_find_or_create_label() argument
900 struct aa_label *label = vec_find(vec, len); in aa_vec_find_or_create_label()
905 return vec_create_and_insert_label(vec, len, gfp); in aa_vec_find_or_create_label()
967 int res = profile_cmp(a->vec[I->i], b->vec[I->j]); in aa_label_next_in_merge()
970 return b->vec[(I->j)++]; in aa_label_next_in_merge()
975 return a->vec[(I->i)++]; in aa_label_next_in_merge()
979 return b->vec[(I->j)++]; in aa_label_next_in_merge()
1010 int res = profile_cmp(p, z->vec[k]); in label_merge_cmp()
1062 new->vec[k] = aa_get_newest_profile(next); in label_merge_insert()
1063 AA_BUG(!new->vec[k]->label.proxy); in label_merge_insert()
1064 AA_BUG(!new->vec[k]->label.proxy->label); in label_merge_insert()
1065 if (next->label.proxy != new->vec[k]->label.proxy) in label_merge_insert()
1070 new->vec[k++] = aa_get_profile(next); in label_merge_insert()
1074 new->vec[k] = NULL; in label_merge_insert()
1077 new->size -= aa_vec_unique(&new->vec[0], new->size, in label_merge_insert()
1081 label = aa_get_label(&new->vec[0]->label); in label_merge_insert()
1863 DEFINE_VEC(profile, vec); in aa_label_strn_parse()
1886 error = vec_setup(profile, vec, len, gfp); in aa_label_strn_parse()
1891 vec[i] = aa_get_profile(base->vec[i]); in aa_label_strn_parse()
1895 vec[i] = fqlookupn_profile(base, currbase, str, split - str); in aa_label_strn_parse()
1896 if (!vec[i]) in aa_label_strn_parse()
1902 if (vec[i]->ns != labels_ns(currbase)) in aa_label_strn_parse()
1903 currbase = &vec[i]->label; in aa_label_strn_parse()
1909 vec[i] = fqlookupn_profile(base, currbase, str, end - str); in aa_label_strn_parse()
1910 if (!vec[i]) in aa_label_strn_parse()
1914 /* no need to free vec as len < LOCAL_VEC_ENTRIES */ in aa_label_strn_parse()
1915 return &vec[0]->label; in aa_label_strn_parse()
1917 len -= aa_vec_unique(vec, len, VEC_FLAG_TERMINATE); in aa_label_strn_parse()
1920 label = aa_get_label(&vec[0]->label); in aa_label_strn_parse()
1925 label = aa_vec_find_or_create_label(vec, len, gfp); in aa_label_strn_parse()
1927 label = vec_find(vec, len); in aa_label_strn_parse()
1933 vec_cleanup(profile, vec, len); in aa_label_strn_parse()
1999 vec_is_stale(label->vec, label->size)) && in labelset_next_stale()
2045 AA_BUG(!label->vec[i]); in __label_update()
2046 new->vec[i] = aa_get_newest_profile(label->vec[i]); in __label_update()
2047 AA_BUG(!new->vec[i]); in __label_update()
2048 AA_BUG(!new->vec[i]->label.proxy); in __label_update()
2049 AA_BUG(!new->vec[i]->label.proxy->label); in __label_update()
2050 if (new->vec[i]->label.proxy != label->vec[i]->label.proxy) in __label_update()
2056 new->size -= aa_vec_unique(&new->vec[0], new->size, in __label_update()
2060 tmp = aa_get_label(&new->vec[0]->label); in __label_update()