[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-omap
Subject:    [PATCH 2/5] dspbridge: static code analysis issues - useless null pointer checks
From:       Hiroshi DOYU <Hiroshi.DOYU () nokia ! com>
Date:       2009-07-31 10:39:25
Message-ID: 1249036768-754-2-git-send-email-Hiroshi.DOYU () nokia ! com
[Download RAW message or body]

From: Phil Carmody <ext-phil.2.carmody@nokia.com>

Given that dl_state.myio can only be 0 or init, the additional check
for init to be non-null is unnecessary once we know dl_state.myio is
non-NULL. (This assumes NULL is all-bits-zero, but as this is
platform/implementation-specific code, that's a fair assumption to
make.)

Signed-off-by: Phil Carmody <ext-phil.2.carmody@nokia.com>
Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
---
 drivers/dsp/bridge/dynload/cload.c |   27 ++++++++++++---------------
 1 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/dsp/bridge/dynload/cload.c b/drivers/dsp/bridge/dynload/cload.c
index 271ab81..ef5d7d9 100644
--- a/drivers/dsp/bridge/dynload/cload.c
+++ b/drivers/dsp/bridge/dynload/cload.c
@@ -177,18 +177,14 @@ int Dynamic_Load_Module(struct Dynamic_Loader_Stream *module,
 
 		init_module_handle(&dl_state);
 
+		/* dl_state.myio is init or 0 at this point. */
 		if (dl_state.myio) {
 			if ((!dl_state.dload_errcount) &&
-			   (dl_state.dfile_hdr.df_entry_secn != DN_UNDEF)) {
-				if (init != NULL) {
-					if (!init->execute(init,
-					   dl_state.dfile_hdr.df_entrypt))
-						dload_error(&dl_state,
-						    "Init->Execute Failed");
-				} else {
-					dload_error(&dl_state, "init is NULL");
-				}
-			}
+			    (dl_state.dfile_hdr.df_entry_secn != DN_UNDEF) &&
+			    (!init->execute(init,
+					    dl_state.dfile_hdr.df_entrypt)))
+				dload_error(&dl_state,
+					    "Init->Execute Failed");
 			init->release(init);
 		}
 
@@ -287,12 +283,13 @@ Dynamic_Open_Module(struct Dynamic_Loader_Stream *module,
 
 		init_module_handle(&dl_state);
 
+		/* dl_state.myio is either 0 or init at this point. */
 		if (dl_state.myio) {
-			if ((!dl_state.dload_errcount)
-			    && (dl_state.dfile_hdr.df_entry_secn != DN_UNDEF))
-				if (!init->execute(init,
-				   dl_state.dfile_hdr.df_entrypt))
-					dload_error(&dl_state,
+			if ((!dl_state.dload_errcount) &&
+			    (dl_state.dfile_hdr.df_entry_secn != DN_UNDEF) &&
+			    (!init->execute(init,
+					    dl_state.dfile_hdr.df_entrypt)))
+				dload_error(&dl_state,
 					    "Init->Execute Failed");
 			init->release(init);
 		}
-- 
1.6.0.4

--
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
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic