[PATCH] print negative numbers correctly via vsprintf in arch/ppc64/boot/prom.c

Andreas Schwab schwab at suse.de
Mon May 9 19:42:39 EST 2005


Olaf Hering <olh at suse.de> writes:

> @@ -352,7 +369,7 @@ static int skip_atoi(const char **s)
>  #define SPECIAL	32		/* 0x */
>  #define LARGE	64		/* use 'ABCDEF' instead of 'abcdef' */
>  
> -static char * number(char * str, long num, int base, int size, int precision, int type)
> +static char * number(char * str, unsigned long long num, int base, int size, int precision, int type)
>  {
>  	char c,sign,tmp[66];
>  	const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
> @@ -367,9 +384,9 @@ static char * number(char * str, long nu
>  	c = (type & ZEROPAD) ? '0' : ' ';
>  	sign = 0;
>  	if (type & SIGN) {
> -		if (num < 0) {
> +		if ((signed long long)num < 0) {
>  			sign = '-';
> -			num = -num;
> +			num = - (unsigned long long)num;

I think the latter cast is useless.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab at suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



More information about the Linuxppc64-dev mailing list