Skip to contentSkip to conversation

dma: Initialize uninitialized variable

PATCH In review Guenter Roeck 2 participants 2 messages May 26, 2011 – Jun 1, 2011 dmaengine

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dma: Initialize uninitialized variable

Uninitialized variable results in random debug output. Fix by initializing to 0.

This commit fixes the following warning:

drivers/dma/pch_dma.c: In function pdc_desc_get:
drivers/dma/pch_dma.c:406: warning: i may be used uninitialized in this function

---
 drivers/dma/pch_dma.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/dma/pch_dma.c +1 -1
index 8d8fef1..6eebc62 100644
@@ -403,7 +403,7 @@ static struct pch_dma_desc *pdc_desc_get(struct pch_dma_chan *pd_chan)
 {
 	struct pch_dma_desc *desc, *_d;
 	struct pch_dma_desc *ret = NULL;
-	int i;
+	int i = 0;
 
 	spin_lock(&pd_chan->lock);
 	list_for_each_entry_safe(desc, _d, &pd_chan->free_list, desc_node) {
Signature · 1 line
1.7.1
#1 lore raw
Quoted 5 lines · Guenter Roeck

Uninitialized variable results in random debug output. Fix by initializing to 0.

This commit fixes the following warning:

Quoted 8 lines

drivers/dma/pch_dma.c: In function pdc_desc_get:
drivers/dma/pch_dma.c:406: warning: i may be used uninitialized in this function

---
 drivers/dma/pch_dma.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Sorry I seem to have missed this earlier. This fix is already in place

commit 364de77831213be20f7f33c39ca1c194593b5c11

Author: Liu Yuan <[email protected]>
Date:   Sat Apr 2 14:20:47 2011 +0800

drivers, pch_dma: Fix uninitialized var before use

In the function pdc_desc_get(), var 'i' is not initialized before use. This patch fixes it.

~Vinod

Quoted 13 lines
drivers/dma/pch_dma.c +1 -1
index 8d8fef1..6eebc62 100644
@@ -403,7 +403,7 @@ static struct pch_dma_desc *pdc_desc_get(struct pch_dma_chan *pd_chan)
 {
 	struct pch_dma_desc *desc, *_d;
 	struct pch_dma_desc *ret = NULL;
-	int i;
+	int i = 0;
 
 	spin_lock(&pd_chan->lock);
 	list_for_each_entry_safe(desc, _d, &pd_chan->free_list, desc_node) {