efivarfs: Replace magic number with sizeof(attributes)
authorMatt Fleming <matt.fleming@intel.com>
Mon, 22 Oct 2012 14:23:29 +0000 (15:23 +0100)
committerMatt Fleming <matt.fleming@intel.com>
Tue, 30 Oct 2012 10:39:26 +0000 (10:39 +0000)
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>
drivers/firmware/efivars.c

index 277e42616f0d84258c4edeea6b18f9a4a9aa912d..2c044343c99b35d4bad93fd6236f98960e14650b 100644 (file)
@@ -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;
@@ -810,7 +810,7 @@ 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) {
@@ -818,9 +818,9 @@ static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf,
                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);
 
This page took 0.027046 seconds and 5 git commands to generate.