mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-22 01:57:43 +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:
parent
f896a64152
commit
0742edf5ba
@ -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;
|
||||
}
|
||||
|
@ -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 */
|
||||
|
@ -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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user