[svn-commits] kpfleming: branch linux/kpfleming/echocan_work r6385 - /linux/team/kpfleming/...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Apr 16 14:00:10 CDT 2009


Author: kpfleming
Date: Thu Apr 16 14:00:06 2009
New Revision: 6385

URL: http://svn.digium.com/svn-view/dahdi?view=rev&rev=6385
Log:
fix this debugging code to properly deep copy the dahdi_echocan_state structure (if one exists, and using a direct structure assignment just for shaun), and while in there:

remove some broken code that couldn't possibly compile if it was enabled
change the format strings for outputting pointers to actually output the entire pointer on 64-bit platforms instead of casting them to 'long'
remove an extraneous 'struct dahdi_chan *' variable on the stack


Modified:
    linux/team/kpfleming/echocan_work/drivers/dahdi/dahdi-base.c

Modified: linux/team/kpfleming/echocan_work/drivers/dahdi/dahdi-base.c
URL: http://svn.digium.com/svn-view/dahdi/linux/team/kpfleming/echocan_work/drivers/dahdi/dahdi-base.c?view=diff&rev=6385&r1=6384&r2=6385
==============================================================================
--- linux/team/kpfleming/echocan_work/drivers/dahdi/dahdi-base.c (original)
+++ linux/team/kpfleming/echocan_work/drivers/dahdi/dahdi-base.c Thu Apr 16 14:00:06 2009
@@ -3424,7 +3424,6 @@
 	struct dahdi_chan *chan;
 	unsigned long flags;
 	unsigned char *txgain, *rxgain;
-	struct dahdi_chan *mychan;
 	int i,j;
 	int return_master = 0;
 	size_t size_to_copy;
@@ -3665,7 +3664,14 @@
 		break;
 	case DAHDI_CHANDIAG_V1: /* Intentional drop through. */
 	case DAHDI_CHANDIAG:
-		get_user(j, (int *)data); /* get channel number from user */
+	{
+		/* there really is no need to initialize this structure because when it is used it has
+		 * already been completely overwritten, but apparently the compiler cannot figure that
+		 * out and warns about uninitialized usage... so initialize it.
+		 */
+		struct dahdi_echocan_state ec_state = { .ops = NULL, };
+
+		get_user(j, (int *) data); /* get channel number from user */
 		/* make sure its a valid channel number */
 		if ((j < 1) || (j >= maxchans))
 			return -EINVAL;
@@ -3673,56 +3679,51 @@
 		if (!chans[j])
 			return -EINVAL;
 
-		if (!(mychan = kmalloc(sizeof(*mychan), GFP_KERNEL)))
+		if (!(chan = kmalloc(sizeof(*chan), GFP_KERNEL)))
 			return -ENOMEM;
 
 		/* lock channel */
 		spin_lock_irqsave(&chans[j]->lock, flags);
 		/* make static copy of channel */
-		memcpy(mychan, chans[j], sizeof(*mychan));
+		*chan = *chans[j];
+		if (chan->ec_state) {
+			ec_state = *chan->ec_state;
+		}
 		/* release it. */
 		spin_unlock_irqrestore(&chans[j]->lock, flags);
 
 		module_printk(KERN_INFO, "Dump of DAHDI Channel %d (%s,%d,%d):\n\n",j,
-			mychan->name,mychan->channo,mychan->chanpos);
-		module_printk(KERN_INFO, "flags: %x hex, writechunk: %08lx, readchunk: %08lx\n",
-			(unsigned int) mychan->flags, (long) mychan->writechunk, (long) mychan->readchunk);
-		module_printk(KERN_INFO, "rxgain: %08lx, txgain: %08lx, gainalloc: %d\n",
-			(long) mychan->rxgain, (long)mychan->txgain, mychan->gainalloc);
-		module_printk(KERN_INFO, "span: %08lx, sig: %x hex, sigcap: %x hex\n",
-			(long)mychan->span, mychan->sig, mychan->sigcap);
+			      chan->name, chan->channo, chan->chanpos);
+		module_printk(KERN_INFO, "flags: %x hex, writechunk: %p, readchunk: %p\n",
+			      (unsigned int) chan->flags, chan->writechunk, chan->readchunk);
+		module_printk(KERN_INFO, "rxgain: %p, txgain: %p, gainalloc: %d\n",
+			      chan->rxgain, chan->txgain, chan->gainalloc);
+		module_printk(KERN_INFO, "span: %p, sig: %x hex, sigcap: %x hex\n",
+			      chan->span, chan->sig, chan->sigcap);
 		module_printk(KERN_INFO, "inreadbuf: %d, outreadbuf: %d, inwritebuf: %d, outwritebuf: %d\n",
-			mychan->inreadbuf, mychan->outreadbuf, mychan->inwritebuf, mychan->outwritebuf);
+			      chan->inreadbuf, chan->outreadbuf, chan->inwritebuf, chan->outwritebuf);
 		module_printk(KERN_INFO, "blocksize: %d, numbufs: %d, txbufpolicy: %d, txbufpolicy: %d\n",
-			mychan->blocksize, mychan->numbufs, mychan->txbufpolicy, mychan->rxbufpolicy);
+			      chan->blocksize, chan->numbufs, chan->txbufpolicy, chan->rxbufpolicy);
 		module_printk(KERN_INFO, "txdisable: %d, rxdisable: %d, iomask: %d\n",
-			mychan->txdisable, mychan->rxdisable, mychan->iomask);
-		module_printk(KERN_INFO, "curzone: %08lx, tonezone: %d, curtone: %08lx, tonep: %d\n",
-			(long) mychan->curzone, mychan->tonezone, (long) mychan->curtone, mychan->tonep);
+			      chan->txdisable, chan->rxdisable, chan->iomask);
+		module_printk(KERN_INFO, "curzone: %p, tonezone: %d, curtone: %p, tonep: %d\n",
+			      chan->curzone, chan->tonezone, chan->curtone, chan->tonep);
 		module_printk(KERN_INFO, "digitmode: %d, txdialbuf: %s, dialing: %d, aftdialtimer: %d, cadpos. %d\n",
-			mychan->digitmode, mychan->txdialbuf, mychan->dialing,
-				mychan->afterdialingtimer, mychan->cadencepos);
+			      chan->digitmode, chan->txdialbuf, chan->dialing,
+			      chan->afterdialingtimer, chan->cadencepos);
 		module_printk(KERN_INFO, "confna: %d, confn: %d, confmode: %d, confmute: %d\n",
-			mychan->confna, mychan->_confn, mychan->confmode, mychan->confmute);
-		module_printk(KERN_INFO, "ec: %08lx, deflaw: %d, xlaw: %08lx\n",
-			(long) mychan->ec_state, mychan->deflaw, (long) mychan->xlaw);
-		if (mychan->ec_state) {
+			      chan->confna, chan->_confn, chan->confmode, chan->confmute);
+		module_printk(KERN_INFO, "ec: %p, deflaw: %d, xlaw: %p\n",
+			      chan->ec_state, chan->deflaw, chan->xlaw);
+		if (chan->ec_state) {
 			module_printk(KERN_INFO, "echostate: %02x, echotimer: %d, echolastupdate: %d\n",
-				      (int) mychan->ec_state->status.mode, mychan->ec_state->status.pretrain_timer, mychan->ec_state->status.last_train_tap);
+				      ec_state.status.mode, ec_state.status.pretrain_timer, ec_state.status.last_train_tap);
 		}
 		module_printk(KERN_INFO, "itimer: %d, otimer: %d, ringdebtimer: %d\n\n",
-			mychan->itimer, mychan->otimer, mychan->ringdebtimer);
-#if 0
-		if (mychan->ec_state) {
-			int x;
-			/* Dump the echo canceller parameters */
-			for (x=0;x<mychan->ec_state->taps;x++) {
-				module_printk(KERN_INFO, "tap %d: %d\n", x, mychan->ec_state->fir_taps[x]);
-			}
-		}
-#endif
-		kfree(mychan);
-		break;
+			      chan->itimer, chan->otimer, chan->ringdebtimer);
+		kfree(chan);
+		break;
+	}
 	default:
 		return -ENOTTY;
 	}




More information about the svn-commits mailing list