diff mbox

[2/8] dspbridge: Drop useless memory allocation

Message ID 1251375541-1866-3-git-send-email-andy.shevchenko@gmail.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Andy Shevchenko Aug. 27, 2009, 12:18 p.m. UTC
From: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>

strcmp() should do the job without additional memory allocation and
strncpy()/strcmp() calls.

Additionally fix spelling.

Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
---
 drivers/dsp/bridge/rmgr/node.c |   15 ++++-----------
 1 files changed, 4 insertions(+), 11 deletions(-)

Comments

Guzman Lugo, Fernando Aug. 31, 2009, 8:49 p.m. UTC | #1
Hi,
	Good finding.

Acked-by: Fernando Guzman Lugo <x0095840@ti.com>


>-----Original Message-----
>From: linux-omap-owner@vger.kernel.org [mailto:linux-omap-
>owner@vger.kernel.org] On Behalf Of Andy Shevchenko
>Sent: Thursday, August 27, 2009 7:19 AM
>To: linux-omap@vger.kernel.org
>Cc: Andy Shevchenko
>Subject: [PATCH 2/8] dspbridge: Drop useless memory allocation
>
>From: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
>
>strcmp() should do the job without additional memory allocation and
>strncpy()/strcmp() calls.
>
>Additionally fix spelling.
>
>Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
>---
> drivers/dsp/bridge/rmgr/node.c |   15 ++++-----------
> 1 files changed, 4 insertions(+), 11 deletions(-)
>
>diff --git a/drivers/dsp/bridge/rmgr/node.c
>b/drivers/dsp/bridge/rmgr/node.c
>index d3f0e34..e213b22 100644
>--- a/drivers/dsp/bridge/rmgr/node.c
>+++ b/drivers/dsp/bridge/rmgr/node.c
>@@ -404,7 +404,6 @@ DSP_STATUS NODE_Allocate(struct PROC_OBJECT
>*hProcessor,
> 	DSP_STATUS status = DSP_SOK;
> 	struct CMM_OBJECT *hCmmMgr = NULL; /* Shared memory manager hndl */
> 	u32 procId;
>-	char *label;
> 	u32 pulValue;
> 	u32 dynextBase;
> 	u32 offSet = 0;
>@@ -691,18 +690,16 @@ func_cont2:
> 		}
> 	}
>
>-	/* Comapare value read from Node Properties and check if it is same
>as
>+	/* Compare value read from Node Properties and check if it is same as
> 	 * STACKSEGLABEL, if yes read the Address of STACKSEGLABEL, calculate
> 	 * GPP Address, Read the value in that address and override the
> 	 * uStackSeg value in task args */
> 	if (DSP_SUCCEEDED(status) &&
> 	   (char *)pNode->dcdProps.objData.nodeObj.ndbProps.uStackSegName !=
> 	   NULL) {
>-		label = MEM_Calloc(sizeof(STACKSEGLABEL)+1, MEM_PAGED);
>-               strncpy(label, STACKSEGLABEL, sizeof(STACKSEGLABEL)+1);
>-
>-               if (strcmp((char *)pNode->dcdProps.objData.nodeObj.
>-				     ndbProps.uStackSegName, label) == 0) {
>+		if (strcmp((char *)
>+		    pNode->dcdProps.objData.nodeObj.ndbProps.uStackSegName,
>+		    STACKSEGLABEL) == 0) {
> 			status = hNodeMgr->nldrFxns.pfnGetFxnAddr(pNode->
> 				 hNldrNode, "DYNEXT_BEG", &dynextBase);
> 			if (DSP_FAILED(status)) {
>@@ -744,10 +741,6 @@ func_cont2:
> 				ulStackSegVal;
>
> 		}
>-
>-		if (label)
>-			MEM_Free(label);
>-
> 	}
>
>
>--
>1.5.6.5
>
>--
>To unsubscribe from this list: send the line "unsubscribe linux-omap" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/dsp/bridge/rmgr/node.c b/drivers/dsp/bridge/rmgr/node.c
index d3f0e34..e213b22 100644
--- a/drivers/dsp/bridge/rmgr/node.c
+++ b/drivers/dsp/bridge/rmgr/node.c
@@ -404,7 +404,6 @@  DSP_STATUS NODE_Allocate(struct PROC_OBJECT *hProcessor,
 	DSP_STATUS status = DSP_SOK;
 	struct CMM_OBJECT *hCmmMgr = NULL; /* Shared memory manager hndl */
 	u32 procId;
-	char *label;
 	u32 pulValue;
 	u32 dynextBase;
 	u32 offSet = 0;
@@ -691,18 +690,16 @@  func_cont2:
 		}
 	}
 
-	/* Comapare value read from Node Properties and check if it is same as
+	/* Compare value read from Node Properties and check if it is same as
 	 * STACKSEGLABEL, if yes read the Address of STACKSEGLABEL, calculate
 	 * GPP Address, Read the value in that address and override the
 	 * uStackSeg value in task args */
 	if (DSP_SUCCEEDED(status) &&
 	   (char *)pNode->dcdProps.objData.nodeObj.ndbProps.uStackSegName !=
 	   NULL) {
-		label = MEM_Calloc(sizeof(STACKSEGLABEL)+1, MEM_PAGED);
-               strncpy(label, STACKSEGLABEL, sizeof(STACKSEGLABEL)+1);
-
-               if (strcmp((char *)pNode->dcdProps.objData.nodeObj.
-				     ndbProps.uStackSegName, label) == 0) {
+		if (strcmp((char *)
+		    pNode->dcdProps.objData.nodeObj.ndbProps.uStackSegName,
+		    STACKSEGLABEL) == 0) {
 			status = hNodeMgr->nldrFxns.pfnGetFxnAddr(pNode->
 				 hNldrNode, "DYNEXT_BEG", &dynextBase);
 			if (DSP_FAILED(status)) {
@@ -744,10 +741,6 @@  func_cont2:
 				ulStackSegVal;
 
 		}
-
-		if (label)
-			MEM_Free(label);
-
 	}