diff options
author | Thiago Jung Bauermann <bauerman@linux.ibm.com> | 2019-06-11 02:28:10 -0400 |
---|---|---|
committer | Mimi Zohar <zohar@linux.ibm.com> | 2019-06-14 09:02:44 -0400 |
commit | e038f5f691e003af25cda0f1593d2cc0a4d1c866 (patch) | |
tree | fe7b9aef19152e189f80e905e75c8f6519c646ac | |
parent | b169424551930a9325f700f502802f4d515194e5 (diff) |
ima: Use designated initializers for struct ima_event_data
Designated initializers allow specifying only the members of the struct
that need initialization. Non-mentioned members are initialized to zero.
This makes the code a bit clearer (particularly in ima_add_boot_aggregate)
and also allows adding a new member to the struct without having to update
all struct initializations.
Signed-off-by: Thiago Jung Bauermann <bauerman@linux.ibm.com>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
-rw-r--r-- | security/integrity/ima/ima_api.c | 13 | ||||
-rw-r--r-- | security/integrity/ima/ima_init.c | 4 |
2 files changed, 11 insertions, 6 deletions
diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c index c7505fb122d4..4aec6b035fe9 100644 --- a/security/integrity/ima/ima_api.c +++ b/security/integrity/ima/ima_api.c | |||
@@ -133,8 +133,10 @@ void ima_add_violation(struct file *file, const unsigned char *filename, | |||
133 | { | 133 | { |
134 | struct ima_template_entry *entry; | 134 | struct ima_template_entry *entry; |
135 | struct inode *inode = file_inode(file); | 135 | struct inode *inode = file_inode(file); |
136 | struct ima_event_data event_data = {iint, file, filename, NULL, 0, | 136 | struct ima_event_data event_data = { .iint = iint, |
137 | cause}; | 137 | .file = file, |
138 | .filename = filename, | ||
139 | .violation = cause }; | ||
138 | int violation = 1; | 140 | int violation = 1; |
139 | int result; | 141 | int result; |
140 | 142 | ||
@@ -284,8 +286,11 @@ void ima_store_measurement(struct integrity_iint_cache *iint, | |||
284 | int result = -ENOMEM; | 286 | int result = -ENOMEM; |
285 | struct inode *inode = file_inode(file); | 287 | struct inode *inode = file_inode(file); |
286 | struct ima_template_entry *entry; | 288 | struct ima_template_entry *entry; |
287 | struct ima_event_data event_data = {iint, file, filename, xattr_value, | 289 | struct ima_event_data event_data = { .iint = iint, |
288 | xattr_len, NULL}; | 290 | .file = file, |
291 | .filename = filename, | ||
292 | .xattr_value = xattr_value, | ||
293 | .xattr_len = xattr_len }; | ||
289 | int violation = 0; | 294 | int violation = 0; |
290 | 295 | ||
291 | if (iint->measured_pcrs & (0x1 << pcr)) | 296 | if (iint->measured_pcrs & (0x1 << pcr)) |
diff --git a/security/integrity/ima/ima_init.c b/security/integrity/ima/ima_init.c index 6c9295449751..ef6c3a26296e 100644 --- a/security/integrity/ima/ima_init.c +++ b/security/integrity/ima/ima_init.c | |||
@@ -49,8 +49,8 @@ static int __init ima_add_boot_aggregate(void) | |||
49 | const char *audit_cause = "ENOMEM"; | 49 | const char *audit_cause = "ENOMEM"; |
50 | struct ima_template_entry *entry; | 50 | struct ima_template_entry *entry; |
51 | struct integrity_iint_cache tmp_iint, *iint = &tmp_iint; | 51 | struct integrity_iint_cache tmp_iint, *iint = &tmp_iint; |
52 | struct ima_event_data event_data = {iint, NULL, boot_aggregate_name, | 52 | struct ima_event_data event_data = { .iint = iint, |
53 | NULL, 0, NULL}; | 53 | .filename = boot_aggregate_name }; |
54 | int result = -ENOMEM; | 54 | int result = -ENOMEM; |
55 | int violation = 0; | 55 | int violation = 0; |
56 | struct { | 56 | struct { |