lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1431442214-15087-1-git-send-email-hofrat@osadl.org>
Date:	Tue, 12 May 2015 16:50:14 +0200
From:	Nicholas Mc Guire <hofrat@...dl.org>
To:	Jason Wessel <jason.wessel@...driver.com>
Cc:	Daniel Thompson <daniel.thompson@...aro.org>,
	kgdb-bugreport@...ts.sourceforge.net, linux-kernel@...r.kernel.org,
	Nicholas Mc Guire <hofrat@...dl.org>
Subject: [PATCH V2] kdb: match return value to function signature

kdb_task_state_string() introduced in the initial commit 5d5314d6795f
("kdb: core for kgdb back end (1 of 2)") returns unsigned long (a bit
array of states) but intermediately it is being assigned to a long which
make static code checkers unhappy and also does not help readability
(technically there is no reason to use a signed type here).

Type-checking coccinelle spatches are being used to locate type mismatches
between function signatures and return values in this case it produced:
./kernel/debug/kdb/kdb_support.c:611 WARNING: return of wrong type
                                 unsigned long != long

Patch was compile tested with x86_64_defconfig + CONFIG_KGDB=y,
CONFIG_KGDB_KDB=y

Patch is against 4.1-rc3 (localversion-next is -next-20150512)

Signed-off-by: Nicholas Mc Guire <hofrat@...dl.org>
---

V2: As suggested by Daniel Thompson <daniel.thompson@...aro.org> rather
    than reformatting the entire comment just drop the type information

All (5) call-sites of kdb_task_state_string() were checked and all are
expecting an unsigned long as the function signature provides - so this
change should have no effect as automatic type conversion did not make
the signed type visible externally and internally the signed nature was
not in use.

Doc fixup: just remove the type information here.

 kernel/debug/kdb/kdb_support.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/debug/kdb/kdb_support.c b/kernel/debug/kdb/kdb_support.c
index d35cc2d..80a2a098 100644
--- a/kernel/debug/kdb/kdb_support.c
+++ b/kernel/debug/kdb/kdb_support.c
@@ -544,7 +544,7 @@ int kdb_putword(unsigned long addr, unsigned long word, size_t size)
  * Returns:
  *	Mask for process state.
  * Notes:
- *	The mask folds data from several sources into a single long value, so
+ *	The mask folds data from several sources into a single value, so
  *	be careful not to overlap the bits.  TASK_* bits are in the LSB,
  *	special cases like UNRUNNABLE are in the MSB.  As of 2.6.10-rc1 there
  *	is no overlap between TASK_* and EXIT_* but that may not always be
@@ -560,7 +560,7 @@ int kdb_putword(unsigned long addr, unsigned long word, size_t size)
 
 unsigned long kdb_task_state_string(const char *s)
 {
-	long res = 0;
+	unsigned long res = 0;
 	if (!s) {
 		s = kdbgetenv("PS");
 		if (!s)
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ