mirror of https://gitee.com/openkylin/linux.git
efivarfs: Replace magic number with sizeof(attributes)
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>
This commit is contained in:
parent
7253eaba7b
commit
d292384152
|
@ -801,7 +801,7 @@ static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf,
|
||||||
if (status != EFI_BUFFER_TOO_SMALL)
|
if (status != EFI_BUFFER_TOO_SMALL)
|
||||||
return efi_status_to_err(status);
|
return efi_status_to_err(status);
|
||||||
|
|
||||||
data = kmalloc(datasize + 4, GFP_KERNEL);
|
data = kmalloc(datasize + sizeof(attributes), GFP_KERNEL);
|
||||||
|
|
||||||
if (!data)
|
if (!data)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -810,7 +810,7 @@ static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf,
|
||||||
status = efivars->ops->get_variable(var->var.VariableName,
|
status = efivars->ops->get_variable(var->var.VariableName,
|
||||||
&var->var.VendorGuid,
|
&var->var.VendorGuid,
|
||||||
&attributes, &datasize,
|
&attributes, &datasize,
|
||||||
(data + 4));
|
(data + sizeof(attributes)));
|
||||||
spin_unlock(&efivars->lock);
|
spin_unlock(&efivars->lock);
|
||||||
|
|
||||||
if (status != EFI_SUCCESS) {
|
if (status != EFI_SUCCESS) {
|
||||||
|
@ -818,9 +818,9 @@ static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf,
|
||||||
goto out_free;
|
goto out_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(data, &attributes, 4);
|
memcpy(data, &attributes, sizeof(attributes));
|
||||||
size = simple_read_from_buffer(userbuf, count, ppos,
|
size = simple_read_from_buffer(userbuf, count, ppos,
|
||||||
data, datasize + 4);
|
data, datasize + sizeof(attributes));
|
||||||
out_free:
|
out_free:
|
||||||
kfree(data);
|
kfree(data);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue