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:	Tue, 27 Jan 2009 13:14:54 -0800
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Atsushi Nemoto <anemo@....ocn.ne.jp>
Cc:	linux-mips@...ux-mips.org, ralf@...ux-mips.org,
	linux-mtd@...ts.infradead.org, dwmw2@...radead.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/5] RBTX4939: Add MTD support

On Tue, 20 Jan 2009 23:12:16 +0900
Atsushi Nemoto <anemo@....ocn.ne.jp> wrote:

> +static void rbtx4939_flash_copy_from(struct map_info *map, void *to,
> +				     unsigned long from, ssize_t len)
> +{
> +	u8 bdipsw = readb(rbtx4939_bdipsw_addr) & 0x0f;
> +	unsigned char shift;
> +	ssize_t curlen;
> +
> +	from += (unsigned long)map->virt;
> +	if (bdipsw & 8) {
> +		/* BOOT Mode: USER ROM1 / USER ROM2 */
> +		shift = bdipsw & 3;
> +		while (len) {
> +			curlen = min((unsigned long)len,
> +				     0x400000 -	(from & (0x400000 - 1)));
> +			memcpy(to,
> +			       (void *)((from & ~0xc00000) |
> +					((((from >> 22) + shift) & 3) << 22)),
> +			       curlen);
> +			len -= curlen;
> +			from += curlen;
> +			to += curlen;
> +		}
> +		return;
> +	}
> +#ifdef __BIG_ENDIAN
> +	if (bdipsw == 0) {
> +		/* BOOT Mode: Monitor ROM */
> +		while (len) {
> +			curlen = min((unsigned long)len,
> +				     0x400000 - (from & (0x400000 - 1)));
> +			memcpy(to, (void *)(from ^ 0x400000), curlen);
> +			len -= curlen;
> +			from += curlen;
> +			to += curlen;
> +		}
> +		return;
> +	}
> +#endif
> +	memcpy(to, (void *)from, len);
> +}

min_t is the preferred way of preventing that warning.

Well.  Actually the preferred way is to get the types right - often the
code simply goofed, and people use casts/min_t to hide that.  But in
this case, yes, casting literal constants to ssize_t would be a bit
silly.

--- a/arch/mips/txx9/rbtx4939/setup.c~mtd-rbtx4939-add-mtd-support-fix
+++ a/arch/mips/txx9/rbtx4939/setup.c
@@ -335,7 +335,7 @@ static void rbtx4939_flash_copy_from(str
 		/* BOOT Mode: USER ROM1 / USER ROM2 */
 		shift = bdipsw & 3;
 		while (len) {
-			curlen = min((unsigned long)len,
+			curlen = min_t(unsigned long, len,
 				     0x400000 -	(from & (0x400000 - 1)));
 			memcpy(to,
 			       (void *)((from & ~0xc00000) |
@@ -351,7 +351,7 @@ static void rbtx4939_flash_copy_from(str
 	if (bdipsw == 0) {
 		/* BOOT Mode: Monitor ROM */
 		while (len) {
-			curlen = min((unsigned long)len,
+			curlen = min_t(unsigned long, len,
 				     0x400000 - (from & (0x400000 - 1)));
 			memcpy(to, (void *)(from ^ 0x400000), curlen);
 			len -= curlen;
_

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