diff mbox

Found some errors and other oddities, largely by means of a static code analysis program

Message ID CAFo99gaHyhzmfn_N6Ynek0VxrNSp_2JNbU+U_ysZt=AOW5mwBw@mail.gmail.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Rickard Strandqvist May 3, 2014, 3:17 p.m. UTC
Hello again
Sorry!  I failed to include the patch :-)


The static code analysis program called cppcheck.
http://cppcheck.sourceforge.net/

I found code that I think are bugs, or at least inappropriate or
unnecessary code, in the files:
drivers/isdn/hisax/l3dss1.c
drivers/isdn/hisax/l3ni1.c
drivers/isdn/mISDN/dsp_cmx.c

I have created a patch, and inluderat the error file generated by cppcheck.

My goal was not to change any functionality, but it does not mean for
example the unused variables can't mean that there are other
problems/mistakes in the code. So a proper code review :)

Is there anything else I can help with regarding the patch or
cppcheck, do not hesitate to contact me.
If you like this type of code analysis, it is possible to get more
warnings, which are not as serious, but that may well indicate other
mistakes.


Best regards

Rickard Strandqvist
diff mbox

Patch

From 0ef1cda18e05aa6d0b0ea745ce194f33d8f03973 Mon Sep 17 00:00:00 2001
From: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Date: Wed, 30 Apr 2014 16:27:31 +0200
Subject: [PATCH] Found same errors using a static code analysis program
 called cppcheck.

---
 drivers/isdn/hisax/l3dss1.c  |    8 ++++++--
 drivers/isdn/hisax/l3ni1.c   |    8 ++++++--
 drivers/isdn/mISDN/dsp_cmx.c |    3 ---
 3 filer ändrade, 12 tillägg(+), 7 borttagningar(-)

diff --git a/drivers/isdn/hisax/l3dss1.c b/drivers/isdn/hisax/l3dss1.c
index cda7006..3ea6257 100644
--- a/drivers/isdn/hisax/l3dss1.c
+++ b/drivers/isdn/hisax/l3dss1.c
@@ -2208,8 +2208,12 @@  static int l3dss1_cmd_global(struct PStack *st, isdn_ctrl *ic)
 				{ free_invoke_id(st, id);
 					return (-2);
 				}
-			pc->prot.dss1.ll_id = ic->parm.dss1_io.ll_id; /* remember id */
-			pc->prot.dss1.proc = ic->parm.dss1_io.proc; /* and procedure */
+
+			if (pc)
+			{
+				pc->prot.dss1.ll_id = ic->parm.dss1_io.ll_id; /* remember id */
+				pc->prot.dss1.proc = ic->parm.dss1_io.proc; /* and procedure */
+			}
 
 			if (!(skb = l3_alloc_skb(l)))
 			{ free_invoke_id(st, id);
diff --git a/drivers/isdn/hisax/l3ni1.c b/drivers/isdn/hisax/l3ni1.c
index 0df6691..367b9d6 100644
--- a/drivers/isdn/hisax/l3ni1.c
+++ b/drivers/isdn/hisax/l3ni1.c
@@ -2064,8 +2064,12 @@  static int l3ni1_cmd_global(struct PStack *st, isdn_ctrl *ic)
 				{ free_invoke_id(st, id);
 					return (-2);
 				}
-			pc->prot.ni1.ll_id = ic->parm.ni1_io.ll_id; /* remember id */
-			pc->prot.ni1.proc = ic->parm.ni1_io.proc; /* and procedure */
+
+			if (pc)
+			{
+				pc->prot.ni1.ll_id = ic->parm.ni1_io.ll_id; /* remember id */
+				pc->prot.ni1.proc = ic->parm.ni1_io.proc; /* and procedure */
+			}
 
 			if (!(skb = l3_alloc_skb(l)))
 			{ free_invoke_id(st, id);
diff --git a/drivers/isdn/mISDN/dsp_cmx.c b/drivers/isdn/mISDN/dsp_cmx.c
index a4f05c5..9e9bdc0 100644
--- a/drivers/isdn/mISDN/dsp_cmx.c
+++ b/drivers/isdn/mISDN/dsp_cmx.c
@@ -1511,9 +1511,6 @@  dsp_cmx_send_member(struct dsp *dsp, int len, s32 *c, int members)
 			dsp->tx_R = t;
 			goto send_packet;
 		}
-#ifdef DSP_NEVER_DEFINED
-	}
-#endif
 	/* PROCESS DATA (three or more members) */
 	/* -> if echo is NOT enabled */
 	if (!dsp->echo.software) {
-- 
1.7.10.4