Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 16 Nov 2002 13:18:42 +1100
From:      Tim Robbins <tjr@FreeBSD.ORG>
To:        Julian Elischer <julian@elischer.org>
Cc:        FreeBSD current users <current@FreeBSD.ORG>
Subject:   Re: Sign fixes for disklabel(8)
Message-ID:  <20021116131842.A92191@dilbert.robbins.dropbear.id.au>
In-Reply-To: <Pine.BSF.4.21.0211151555190.46162-200000@InterJet.elischer.org>; from julian@elischer.org on Fri, Nov 15, 2002 at 03:59:25PM -0800
References:  <Pine.BSF.4.21.0211151555190.46162-200000@InterJet.elischer.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Nov 15, 2002 at 03:59:25PM -0800, Julian Elischer wrote:

> Here are the diffs to allow disklabel to correctly create partitions >
> 1TB (up to 2TB is useful with UFS2) pending a different partitionning
> scheme. It also allows you to correctly make smaller partitions beyond
> 1TB which is nice if you don't want to waste 800GB on an array :-)
> 
> 
> permission to commit please?
> (pending comments by others)
> 
> (also the sysinstall changes posted before)
> (also the bluetooth code)
[...]
> -	int v, lineno = 0, errors = 0;
> +	unsigned int v;
> +	int lineno = 0, errors = 0;
>  	int i;
[...]
> -			v = atoi(tp);
> +			v = strtoul(tp, NULL, 0);
>  			if ((unsigned)v >= DKMAXTYPES)
>  				fprintf(stderr, "line %d:%s %d\n", lineno,
>  				    "Warning, unknown disk type", v);

This cast is redundant since v is already unsigned. The fprintf() format
string needs to use %u instead of %d. Use 10 as the base argument to
stroul(), not 0 otherwise numbers with leading zeros will be interpreted
as octal.

[...]
> -			v = atoi(tp);
> +			v = strtoul(tp, NULL, 0);
>  			if (v <= 0 || (v % DEV_BSIZE) != 0) {
>  				fprintf(stderr,
>  				    "line %d: %s: bad sector size\n",

Should be == 0, not <= 0 since v is unsigned.

[...]
> -			v = atoi(tp);
> +			v = strtoul(tp, NULL, 0);
>  			if (v < 0) {
>  				fprintf(stderr, "line %d: %s: bad %s\n",
>  				    lineno, tp, cp);

v < 0 is impossible.


Tim

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021116131842.A92191>