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>] [<thread-prev] [day] [month] [year] [list]
Date:	Fri, 22 Feb 2008 11:13:30 -0800
From:	Joe Perches <joe@...ches.com>
To:	Harvey Harrison <harvey.harrison@...il.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/2] char: hide sparse expensive pointer subtraction
	warning in specialix.c

On Fri, 2008-02-22 at 10:34 -0800, Harvey Harrison wrote:
> Andrew, take it or leave it, I just did this to make it easier to look at the other
> sparse issues....but without this sparse produces > 100 of these warnings for this
> file.
> 
>  drivers/char/specialix.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c
> index c0e08c7..5487f37 100644
> --- a/drivers/char/specialix.c
> +++ b/drivers/char/specialix.c
> @@ -228,21 +228,21 @@ static inline int sx_paranoia_check(struct specialix_port const * port,
>  /* Get board number from pointer */
>  static inline int board_No (struct specialix_board * bp)
>  {
> -	return bp - sx_board;
> +	return ((char *)bp - (char *)sx_board) * sizeof(*bp);
>  }

You've casted addresses to char then multiplied.
You need to divide.

Maybe it'd be better to change your sparse settings to
not print this warning rather than change normally
readable code to avoid the warning.

I like the control name "ptr-subtraction-blows".

$ make C=1 CHECKFLAGS="-Wno-ptr-subtraction-blows" drivers/char/specialix.o
  CHK     include/linux/version.h
  CHK     include/linux/utsrelease.h
  CALL    scripts/checksyscalls.sh
  CHECK   drivers/char/specialix.c
drivers/char/specialix.c:2112:3: warning: context imbalance in 'sx_throttle' - unexpected unlock
  CC      drivers/char/specialix.o
drivers/char/specialix.c:2488: warning: ‘specialx_pci_tbl’ defined but not used


--
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