Commit fc2efe47 authored by Rolf Eike Beer's avatar Rolf Eike Beer Committed by Deepak Saxena

[PATCH] Compaq PCI Hotplug: kill useless kmalloc casts

This patch removes the cast of kmalloc's results to the target pointer type.
Also it fixes kmalloc to use sizeof(*foo) instead of sizeof(type_of_foo) as
suggested by Matthew Wilcox. Also removes a few useless checks if a pointer
is NULL before calling kfree: kfree checks this itself.
parent bc81b21c
......@@ -454,7 +454,7 @@ static struct pci_resource *do_pre_bridge_resource_split(struct pci_resource **h
if (node->length & (alignment -1)) {
/* this one isn't an aligned length, so we'll make a new entry
* and split it up. */
split_node = kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
split_node = kmalloc(sizeof(*split_node), GFP_KERNEL);
if (!split_node)
return NULL;
......@@ -582,7 +582,7 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size
if ((node->length - (temp_dword - node->base)) < size)
continue;
split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
split_node = kmalloc(sizeof(*split_node), GFP_KERNEL);
if (!split_node)
return NULL;
......@@ -601,7 +601,7 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size
if (node->length > size) {
/* this one is longer than we need
* so we'll make a new entry and split it up */
split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
split_node = kmalloc(sizeof(*split_node), GFP_KERNEL);
if (!split_node)
return NULL;
......@@ -678,7 +678,7 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz
if ((max->length - (temp_dword - max->base)) < size)
continue;
split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
split_node = kmalloc(sizeof(*split_node), GFP_KERNEL);
if (!split_node)
return NULL;
......@@ -695,7 +695,7 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz
if ((max->base + max->length) & (size - 1)) {
/* this one isn't end aligned properly at the top
* so we'll make a new entry and split it up */
split_node = kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
split_node = kmalloc(sizeof(*split_node), GFP_KERNEL);
if (!split_node)
return NULL;
......@@ -776,7 +776,7 @@ static struct pci_resource *get_resource(struct pci_resource **head, u32 size)
if ((node->length - (temp_dword - node->base)) < size)
continue;
split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
split_node = kmalloc(sizeof(*split_node), GFP_KERNEL);
if (!split_node)
return NULL;
......@@ -795,7 +795,7 @@ static struct pci_resource *get_resource(struct pci_resource **head, u32 size)
dbg("%s: too big\n", __FUNCTION__);
/* this one is longer than we need
* so we'll make a new entry and split it up */
split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
split_node = kmalloc(sizeof(*split_node), GFP_KERNEL);
if (!split_node)
return NULL;
......@@ -985,7 +985,7 @@ struct pci_func *cpqhp_slot_create(u8 busnumber)
struct pci_func *new_slot;
struct pci_func *next;
new_slot = (struct pci_func *) kmalloc(sizeof(struct pci_func), GFP_KERNEL);
new_slot = kmalloc(sizeof(*new_slot), GFP_KERNEL);
if (new_slot == NULL) {
/* I'm not dead yet!
......@@ -1870,7 +1870,7 @@ static int update_slot_info(struct controller *ctrl, struct slot *slot)
struct hotplug_slot_info *info;
int result;
info = kmalloc (sizeof (struct hotplug_slot_info), GFP_KERNEL);
info = kmalloc(sizeof(*info), GFP_KERNEL);
if (!info)
return -ENOMEM;
......@@ -2361,7 +2361,7 @@ int cpqhp_hardware_test(struct controller *ctrl, int test_num)
* Returns 0 if success
*
*/
static u32 configure_new_device(struct controller *ctrl, struct pci_func *func,
static u32 configure_new_device(struct controller * ctrl, struct pci_func * func,
u8 behind_bridge, struct resource_lists * resources)
{
u8 temp_byte, function, max_functions, stop_it;
......@@ -2590,19 +2590,15 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
/* Make copies of the nodes we are going to pass down so that
* if there is a problem,we can just use these to free resources */
hold_bus_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
hold_IO_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
hold_mem_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
hold_p_mem_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
hold_bus_node = kmalloc(sizeof(*hold_bus_node), GFP_KERNEL);
hold_IO_node = kmalloc(sizeof(*hold_IO_node), GFP_KERNEL);
hold_mem_node = kmalloc(sizeof(*hold_mem_node), GFP_KERNEL);
hold_p_mem_node = kmalloc(sizeof(*hold_p_mem_node), GFP_KERNEL);
if (!hold_bus_node || !hold_IO_node || !hold_mem_node || !hold_p_mem_node) {
if (hold_bus_node)
kfree(hold_bus_node);
if (hold_IO_node)
kfree(hold_IO_node);
if (hold_mem_node)
kfree(hold_mem_node);
if (hold_p_mem_node)
kfree(hold_p_mem_node);
return 1;
......
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