[svn-commits] sruffell: linux/trunk r6246 - /linux/trunk/drivers/dahdi/wctc4xxp/base.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Mar 24 14:08:20 CDT 2009


Author: sruffell
Date: Tue Mar 24 14:08:17 2009
New Revision: 6246

URL: http://svn.digium.com/svn-view/dahdi?view=rev&rev=6246
Log:
Eliminate unnecessary checks for NULL before freeing memory.

Modified:
    linux/trunk/drivers/dahdi/wctc4xxp/base.c

Modified: linux/trunk/drivers/dahdi/wctc4xxp/base.c
URL: http://svn.digium.com/svn-view/dahdi/linux/trunk/drivers/dahdi/wctc4xxp/base.c?view=diff&rev=6246&r1=6245&r2=6246
==============================================================================
--- linux/trunk/drivers/dahdi/wctc4xxp/base.c (original)
+++ linux/trunk/drivers/dahdi/wctc4xxp/base.c Tue Mar 24 14:08:17 2009
@@ -200,6 +200,7 @@
 
 /* Transcoder buffer (tcb) */
 struct tcb {
+	void *data;
 	struct list_head node;
 	unsigned long timeout;
 	unsigned long retries;
@@ -217,7 +218,6 @@
 	struct tcb *response;
 	struct completion complete;
 	struct timer_list timer;
-	void *data;
 	/* The number of bytes available in data. */
 	int data_len;
 	spinlock_t lock;
@@ -1578,6 +1578,9 @@
 {
 	int i;
 	struct wctc4xxp_descriptor *d;
+
+	if (!dr || !dr->desc)
+		return;
 
 	for (i = 0; i < DRING_SIZE; ++i) {
 		d = wctc4xxp_descriptor(dr, i);
@@ -3590,20 +3593,12 @@
 	wctc4xxp_net_unregister(wc);
 	kfree(wc->encoders);
 	kfree(wc->decoders);
-	if (wc->uencode)
-		dahdi_transcoder_free(wc->uencode);
-	if (wc->udecode)
-		dahdi_transcoder_free(wc->udecode);
-	if (wc->txd) {
-		if (wc->txd->desc)
-			wctc4xxp_cleanup_descriptor_ring(wc->txd);
-		kfree(wc->txd);
-	}
-	if (wc->rxd) {
-		if (wc->rxd && wc->rxd->desc)
-			wctc4xxp_cleanup_descriptor_ring(wc->rxd);
-		kfree(wc->rxd);
-	}
+	dahdi_transcoder_free(wc->uencode);
+	dahdi_transcoder_free(wc->udecode);
+	wctc4xxp_cleanup_descriptor_ring(wc->txd);
+	kfree(wc->txd);
+	wctc4xxp_cleanup_descriptor_ring(wc->rxd);
+	kfree(wc->rxd);
 	release_region(wc->iobase, 0xff);
 	spin_lock(&wctc4xxp_list_lock);
 	list_del(&wc->node);
@@ -3630,10 +3625,8 @@
 {
 	struct wcdte *wc = pci_get_drvdata(pdev);
 
-	if (!wc) {
-		/* \todo print warning message here. */
+	if (!wc)
 		return;
-	}
 
 	spin_lock(&wctc4xxp_list_lock);
 	list_del(&wc->node);
@@ -3666,16 +3659,10 @@
 
 	/* Free Resources */
 	release_region(wc->iobase, 0xff);
-	if (wc->txd) {
-		if (wc->txd->desc)
-			wctc4xxp_cleanup_descriptor_ring(wc->txd);
-		kfree(wc->txd);
-	}
-	if (wc->rxd) {
-		if (wc->rxd && wc->rxd->desc)
-			wctc4xxp_cleanup_descriptor_ring(wc->rxd);
-		kfree(wc->rxd);
-	}
+	wctc4xxp_cleanup_descriptor_ring(wc->txd);
+	kfree(wc->txd);
+	wctc4xxp_cleanup_descriptor_ring(wc->rxd);
+	kfree(wc->rxd);
 
 	wctc4xxp_cleanup_command_list(wc);
 	wctc4xxp_cleanup_channels(wc);




More information about the svn-commits mailing list