Commit e038f5f6 authored by Thiago Jung Bauermann's avatar Thiago Jung Bauermann Committed by Mimi Zohar

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: default avatarThiago Jung Bauermann <bauerman@linux.ibm.com>
Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
parent b1694245
...@@ -133,8 +133,10 @@ void ima_add_violation(struct file *file, const unsigned char *filename, ...@@ -133,8 +133,10 @@ void ima_add_violation(struct file *file, const unsigned char *filename,
{ {
struct ima_template_entry *entry; struct ima_template_entry *entry;
struct inode *inode = file_inode(file); struct inode *inode = file_inode(file);
struct ima_event_data event_data = {iint, file, filename, NULL, 0, struct ima_event_data event_data = { .iint = iint,
cause}; .file = file,
.filename = filename,
.violation = cause };
int violation = 1; int violation = 1;
int result; int result;
...@@ -284,8 +286,11 @@ void ima_store_measurement(struct integrity_iint_cache *iint, ...@@ -284,8 +286,11 @@ void ima_store_measurement(struct integrity_iint_cache *iint,
int result = -ENOMEM; int result = -ENOMEM;
struct inode *inode = file_inode(file); struct inode *inode = file_inode(file);
struct ima_template_entry *entry; struct ima_template_entry *entry;
struct ima_event_data event_data = {iint, file, filename, xattr_value, struct ima_event_data event_data = { .iint = iint,
xattr_len, NULL}; .file = file,
.filename = filename,
.xattr_value = xattr_value,
.xattr_len = xattr_len };
int violation = 0; int violation = 0;
if (iint->measured_pcrs & (0x1 << pcr)) if (iint->measured_pcrs & (0x1 << pcr))
......
...@@ -49,8 +49,8 @@ static int __init ima_add_boot_aggregate(void) ...@@ -49,8 +49,8 @@ static int __init ima_add_boot_aggregate(void)
const char *audit_cause = "ENOMEM"; const char *audit_cause = "ENOMEM";
struct ima_template_entry *entry; struct ima_template_entry *entry;
struct integrity_iint_cache tmp_iint, *iint = &tmp_iint; struct integrity_iint_cache tmp_iint, *iint = &tmp_iint;
struct ima_event_data event_data = {iint, NULL, boot_aggregate_name, struct ima_event_data event_data = { .iint = iint,
NULL, 0, NULL}; .filename = boot_aggregate_name };
int result = -ENOMEM; int result = -ENOMEM;
int violation = 0; int violation = 0;
struct { struct {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment