2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-22 10:07:12 +00:00

parser: Add features comparison function

This is a simple aa_features equality test. Placing it behind a function
call allows us to do something more complex than a simple string
comparison later.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
Tyler Hicks 2015-03-25 17:09:26 -05:00
parent f896a64152
commit 0742edf5ba
3 changed files with 15 additions and 4 deletions

View File

@ -286,3 +286,16 @@ const char *aa_features_get_string(aa_features *features)
{
return features->string;
}
/**
* aa_features_is_equal - equality test for two features
* @features1: the first features (can be NULL)
* @features2: the second features (can be NULL)
*
* Returns: true if they're equal, false if they're not or either are NULL
*/
bool aa_features_is_equal(aa_features *features1, aa_features *features2)
{
return features1 && features2 &&
strcmp(features1->string, features2->string) == 0;
}

View File

@ -28,5 +28,6 @@ int aa_features_new_from_kernel(aa_features **features);
aa_features *aa_features_ref(aa_features *features);
void aa_features_unref(aa_features *features);
const char *aa_features_get_string(aa_features *features);
bool aa_features_is_equal(aa_features *features1, aa_features *features2);
#endif /* __AA_FEATURES_H */

View File

@ -252,10 +252,7 @@ int setup_cache(aa_features *kernel_features, const char *cacheloc)
kernel_features_string = aa_features_get_string(kernel_features);
if (!aa_features_new(&cache_features, cache_features_path)) {
const char *cache_features_string;
cache_features_string = aa_features_get_string(cache_features);
if (strcmp(kernel_features_string, cache_features_string) != 0) {
if (!aa_features_is_equal(kernel_features, cache_features)) {
if (write_cache && cond_clear_cache) {
if (create_cache(cacheloc, cache_features_path,
kernel_features_string))