ChangeSet 1.1587.12.28, 2004/04/29 16:14:14-07:00, eike-hotplug@sf-tec.de [PATCH] PCI Express Hotplug: remove useless kmalloc casts The result of kmalloc does not need to be casted, it is a void * which can be assigned to any pointer variable. Also avoid code duplication in one if statement. drivers/pci/hotplug/pciehp_ctrl.c | 30 ++++++++++++++++++------------ 1 files changed, 18 insertions(+), 12 deletions(-) diff -Nru a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c --- a/drivers/pci/hotplug/pciehp_ctrl.c Mon May 17 17:03:25 2004 +++ b/drivers/pci/hotplug/pciehp_ctrl.c Mon May 17 17:03:25 2004 @@ -391,7 +391,7 @@ /* this one isn't an aligned length, 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(struct pci_resource), GFP_KERNEL); if (!split_node) return NULL; @@ -415,15 +415,14 @@ /* Now unlink it */ if (*head == node) { *head = node->next; - node->next = NULL; } else { prevnode = *head; while (prevnode->next != node) prevnode = prevnode->next; prevnode->next = node->next; - node->next = NULL; } + node->next = NULL; return node; } @@ -524,7 +523,8 @@ 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(struct pci_resource), + GFP_KERNEL); if (!split_node) return NULL; @@ -543,7 +543,8 @@ 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(struct pci_resource), + GFP_KERNEL); if (!split_node) return NULL; @@ -624,7 +625,8 @@ 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(struct pci_resource), + GFP_KERNEL); if (!split_node) return NULL; @@ -642,7 +644,8 @@ 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 = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); + split_node = kmalloc(sizeof(struct pci_resource), + GFP_KERNEL); if (!split_node) return NULL; @@ -663,7 +666,8 @@ for ( i = 0; max_size[i] > size; i++) { if (max->length > max_size[i]) { - split_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); + split_node = kmalloc(sizeof(struct pci_resource), + GFP_KERNEL); if (!split_node) break; /* return NULL; */ split_node->base = max->base + max_size[i]; @@ -738,7 +742,8 @@ 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(struct pci_resource), + GFP_KERNEL); if (!split_node) return NULL; @@ -758,7 +763,8 @@ 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(struct pci_resource), + GFP_KERNEL); if (!split_node) return NULL; @@ -876,7 +882,7 @@ struct pci_func *new_slot; struct pci_func *next; dbg("%s: busnumber %x\n", __FUNCTION__, busnumber); - new_slot = (struct pci_func *) kmalloc(sizeof(struct pci_func), GFP_KERNEL); + new_slot = kmalloc(sizeof(struct pci_func), GFP_KERNEL); if (new_slot == NULL) return new_slot; @@ -1452,7 +1458,7 @@ /* char buffer[SLOT_NAME_SIZE]; */ int result; - info = kmalloc (sizeof (struct hotplug_slot_info), GFP_KERNEL); + info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL); if (!info) return -ENOMEM;