Skip to contentSkip to conversation

lib/vsprintf.c:800 ptr_to_id() warn: ignoring unreachable code.

PATCH New Dan Carpenter 1 participant 1 message Feb 11, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 23/23 lib/vsprintf.c:800 ptr_to_id() warn: ignoring unreachable code.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/kbingham/rcar.git gmsl/dev
head:   93aef18a872beaf24093f699268e56a484e31f64
commit: 93aef18a872beaf24093f699268e56a484e31f64 [23/23] lib: vsprint debug-ptrval

If you fix the issue, kindly add following tag

New smatch warnings:
lib/vsprintf.c:800 ptr_to_id() warn: ignoring unreachable code.

Old smatch warnings:
lib/vsprintf.c:1405 ip6_compressed_string() warn: possible spectre second half. '*p' lib/vsprintf.c:1408 ip6_compressed_string() warn: possible spectre second half. '*p'

# https://git.kernel.org/pub/scm/linux/kernel/git/kbingham/rcar.git/commit/?id=93aef18a872beaf24093f699268e56a484e31f64
git remote add rcar https://git.kernel.org/pub/scm/linux/kernel/git/kbingham/rcar.git
git remote update rcar
git checkout 93aef18a872beaf24093f699268e56a484e31f64
vim +800 lib/vsprintf.c

e4dcad204d3a28 Joel Fernandes (Google  2019-11-30  789) 
9073dac14e397f Geert Uytterhoeven      2018-10-11  790  static char *ptr_to_id(char *buf, char *end, const void *ptr,
9073dac14e397f Geert Uytterhoeven      2018-10-11  791  		       struct printf_spec spec)
9073dac14e397f Geert Uytterhoeven      2018-10-11  792  {
9073dac14e397f Geert Uytterhoeven      2018-10-11  793  	const char *str = sizeof(ptr) == 8 ? "(____ptrval____)" : "(ptrval)";
9073dac14e397f Geert Uytterhoeven      2018-10-11  794  	unsigned long hashval;
e4dcad204d3a28 Joel Fernandes (Google  2019-11-30  795) 	int ret;
9073dac14e397f Geert Uytterhoeven      2018-10-11  796  
93aef18a872bea Laurent Pinchart        2020-02-10  797  	return pointer_string(buf, end, ptr, spec);
                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
93aef18a872bea Laurent Pinchart        2020-02-10  798  
9073dac14e397f Geert Uytterhoeven      2018-10-11  799  	/* When debugging early boot use non-cryptographically secure hash. */
9073dac14e397f Geert Uytterhoeven      2018-10-11 @800  	if (unlikely(debug_boot_weak_hash)) {
9073dac14e397f Geert Uytterhoeven      2018-10-11  801  		hashval = hash_long((unsigned long)ptr, 32);
9073dac14e397f Geert Uytterhoeven      2018-10-11  802  		return pointer_string(buf, end, (const void *)hashval, spec);
9073dac14e397f Geert Uytterhoeven      2018-10-11  803  	}
9073dac14e397f Geert Uytterhoeven      2018-10-11  804  
e4dcad204d3a28 Joel Fernandes (Google  2019-11-30  805) 	ret = __ptr_to_hashval(ptr, &hashval);
e4dcad204d3a28 Joel Fernandes (Google  2019-11-30  806) 	if (ret) {
9073dac14e397f Geert Uytterhoeven      2018-10-11  807  		spec.field_width = 2 * sizeof(ptr);
9073dac14e397f Geert Uytterhoeven      2018-10-11  808  		/* string length must be less than default_width */
c8c3b584343cb7 Petr Mladek             2019-04-17  809  		return error_string(buf, end, str, spec);
9073dac14e397f Geert Uytterhoeven      2018-10-11  810  	}
9073dac14e397f Geert Uytterhoeven      2018-10-11  811  
9073dac14e397f Geert Uytterhoeven      2018-10-11  812  	return pointer_string(buf, end, (const void *)hashval, spec);
9073dac14e397f Geert Uytterhoeven      2018-10-11  813  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org