Skip to content

Commit

Permalink
efivarfs: Replace magic number with sizeof(attributes)
Browse files Browse the repository at this point in the history
Seeing "+ 4" littered throughout the functions gets a bit
confusing. Use "sizeof(attributes)" which clearly explains what
quantity we're adding.

Acked-by: Jeremy Kerr <jeremy.kerr@canonical.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
  • Loading branch information
Matt Fleming committed Oct 30, 2012
1 parent 7253eab commit d292384
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/firmware/efivars.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf,
if (status != EFI_BUFFER_TOO_SMALL)
return efi_status_to_err(status);

data = kmalloc(datasize + 4, GFP_KERNEL);
data = kmalloc(datasize + sizeof(attributes), GFP_KERNEL);

if (!data)
return -ENOMEM;
Expand All @@ -810,17 +810,17 @@ static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf,
status = efivars->ops->get_variable(var->var.VariableName,
&var->var.VendorGuid,
&attributes, &datasize,
(data + 4));
(data + sizeof(attributes)));
spin_unlock(&efivars->lock);

if (status != EFI_SUCCESS) {
size = efi_status_to_err(status);
goto out_free;
}

memcpy(data, &attributes, 4);
memcpy(data, &attributes, sizeof(attributes));
size = simple_read_from_buffer(userbuf, count, ppos,
data, datasize + 4);
data, datasize + sizeof(attributes));
out_free:
kfree(data);

Expand Down

0 comments on commit d292384

Please sign in to comment.