Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Jun 2010 09:43:08 +0000 (UTC)
From:      "Andrey V. Elsukov" <ae@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r209246 - user/ae/usr.sbin/sade
Message-ID:  <201006170943.o5H9h8Rg083952@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ae
Date: Thu Jun 17 09:43:07 2010
New Revision: 209246
URL: http://svn.freebsd.org/changeset/base/209246

Log:
  Clean types. Replace "unsigned long long" to "off_t".
  Add a temporary make knob LIBDIALOG_PATH.

Modified:
  user/ae/usr.sbin/sade/Makefile
  user/ae/usr.sbin/sade/libsade.h
  user/ae/usr.sbin/sade/parts.c
  user/ae/usr.sbin/sade/util.c

Modified: user/ae/usr.sbin/sade/Makefile
==============================================================================
--- user/ae/usr.sbin/sade/Makefile	Thu Jun 17 09:36:23 2010	(r209245)
+++ user/ae/usr.sbin/sade/Makefile	Thu Jun 17 09:43:07 2010	(r209246)
@@ -13,7 +13,8 @@ WARNS?=	1
 DPADD=	${LIBUTIL} ${LIBGEOM} ${LIBDIALOG} ${LIBNCURSES} ${LIBUFS}
 LDADD=	-lutil -lgeom -ldialog -lncurses -lufs
 
+LIBDIALOG_PATH?=	../../../../head/gnu/lib/libdialog
 #DEBUG_FLAGS= -g
-CFLAGS+= -I${.CURDIR} -I${.CURDIR}/libdialog
+CFLAGS+= -I${.CURDIR} -I${.CURDIR}/${LIBDIALOG_PATH}
 
 .include <bsd.prog.mk>

Modified: user/ae/usr.sbin/sade/libsade.h
==============================================================================
--- user/ae/usr.sbin/sade/libsade.h	Thu Jun 17 09:36:23 2010	(r209245)
+++ user/ae/usr.sbin/sade/libsade.h	Thu Jun 17 09:43:07 2010	(r209246)
@@ -155,6 +155,6 @@ struct gclass	*find_class(struct gmesh *
 struct ggeom	*find_geom(struct gclass *classp, const char *name);
 const char	*find_geomcfg(struct ggeom *gp, const char *cfg);
 const char	*find_provcfg(struct gprovider *pp, const char *cfg);
-struct gprovider *find_provider(struct ggeom *gp, unsigned long long minsector);
+struct gprovider *find_provider(struct ggeom *gp, off_t minsector);
 
 #endif /* _SADE_H_ */

Modified: user/ae/usr.sbin/sade/parts.c
==============================================================================
--- user/ae/usr.sbin/sade/parts.c	Thu Jun 17 09:36:23 2010	(r209245)
+++ user/ae/usr.sbin/sade/parts.c	Thu Jun 17 09:43:07 2010	(r209246)
@@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
 #include <stdio.h>
 #include <stdlib.h>
 #include <limits.h>
+#include <inttypes.h>
 #include <string.h>
 #include <sysexits.h>
 #include <errno.h>
@@ -109,7 +110,7 @@ de_partlist_get(struct de_device *pdev)
 	struct gclass *cp;
 	struct ggeom *gp;
 	struct gprovider *pp;
-	unsigned long long first, last, start, end;
+	off_t first, last, start, end;
 	const char *s;
 	int error;
 
@@ -133,23 +134,25 @@ de_partlist_get(struct de_device *pdev)
 	pdev->de_scheme = strdup(s);
 
         s = find_geomcfg(gp, "first");
-        first = atoll(s);
+        first = (off_t)strtoimax(s, NULL, 0);
         s = find_geomcfg(gp, "last");
-        last = atoll(s);
+        last = (off_t)strtoimax(s, NULL, 0);
 	while ((pp = find_provider(gp, first)) != NULL) {
 		s = find_provcfg(pp, "start");
 		if (s == NULL) {
 			s = find_provcfg(pp, "offset");
-			start = atoll(s) / pdev->de_sectorsize;
+			start =
+			    (off_t)strtoimax(s, NULL, 0) / pdev->de_sectorsize;
 		} else
-			start = atoll(s);
+			start = (off_t)strtoimax(s, NULL, 0);
 
 		s = find_provcfg(pp, "end");
 		if (s == NULL) {
 			s = find_provcfg(pp, "length");
-			end = start + atoll(s) / pdev->de_sectorsize - 1;
+			end = start - 1 +
+			    (off_t)strtoimax(s, NULL, 0) / pdev->de_sectorsize;
 		} else
-			end = atoll(s);
+			end = (off_t)strtoimax(s, NULL, 0);
 
 		if (first < start) {
 			error = de_partlist_add_unused(pdev, first, start - 1);
@@ -410,9 +413,10 @@ de_part_add_calculate_size(const char *d
 	struct gclass *cp;
 	struct ggeom *gp;
 	struct gprovider *pp;
-	unsigned long long first, last;
-	unsigned long long size, start;
-	unsigned long long lba, len, grade;
+	off_t first, last;
+	off_t size, start;
+	off_t lba, len;
+	uintmax_t grade;
 	const char *s;
 	int error;
 
@@ -437,22 +441,24 @@ de_part_add_calculate_size(const char *d
 		    devname);
 		goto fail;
 	}
-	first = strtoull(find_geomcfg(gp, "first"), NULL, 10);
-	last = strtoull(find_geomcfg(gp, "last"), NULL, 10);
+	first = (off_t)strtoimax(find_geomcfg(gp, "first"), NULL, 10);
+	last = (off_t)strtoimax(find_geomcfg(gp, "last"), NULL, 10);
 	grade = ~0ULL;
 	while ((pp = find_provider(gp, first)) != NULL) {
 		s = find_provcfg(pp, "start");
 		if (s == NULL) {
 			s = find_provcfg(pp, "offset");
-			lba = strtoull(s, NULL, 10) / pp->lg_sectorsize;
+			lba =
+			    (off_t)strtoimax(s, NULL, 10) / pp->lg_sectorsize;
 		} else
-			lba = strtoull(s, NULL, 10);
+			lba = (off_t)strtoimax(s, NULL, 10);
 
 		if (first < lba) {
 			/* Free space [first, lba> */
 			len = lba - first;
 			if (*sizep) {
-				if (len >= size && len - size < grade) {
+				if (len >= size &&
+				    (uintmax_t)(len - size) < grade) {
 					start = first;
 					grade = len - size;
 				}
@@ -473,15 +479,17 @@ de_part_add_calculate_size(const char *d
 		s = find_provcfg(pp, "end");
 		if (s == NULL) {
 			s = find_provcfg(pp, "length");
-			first = lba + strtoull(s, NULL, 10) / pp->lg_sectorsize;
+			first = lba +
+			    (off_t)strtoimax(s, NULL, 10) / pp->lg_sectorsize;
 		} else
-			first = strtoull(s, NULL, 10) + 1;
+			first = (off_t)strtoimax(s, NULL, 10) + 1;
 	}
 	if (first <= last) {
 		/* Free space [first-last] */
 		len = last - first + 1;
 		if (*sizep) {
-			if (len >= size && len - size < grade) {
+			if (len >= size &&
+			    (uintmax_t)(len - size) < grade) {
 				start = first;
 				grade = len - size;
 			}
@@ -542,10 +550,10 @@ de_part_add(struct de_device *pdev, cons
 			return (ENOMEM);
 	}
 	error = ENOMEM;
-	asprintf(&sstart, "%lu", start);
+	asprintf(&sstart, "%jd", (intmax_t)start);
 	if (sstart == NULL)
 		goto fail;
-	asprintf(&ssize, "%lu", size);
+	asprintf(&ssize, "%jd", (intmax_t)size);
 	if (ssize == NULL)
 		goto fail;
 	req = gctl_get_handle();
@@ -693,6 +701,7 @@ fail:
 	return (error);
 }
 
+/* XXX: Add VTOC8 support */
 int
 de_part_bootcode(struct de_part *ppart, const char *path)
 {

Modified: user/ae/usr.sbin/sade/util.c
==============================================================================
--- user/ae/usr.sbin/sade/util.c	Thu Jun 17 09:36:23 2010	(r209245)
+++ user/ae/usr.sbin/sade/util.c	Thu Jun 17 09:43:07 2010	(r209246)
@@ -32,6 +32,8 @@ __FBSDID("$FreeBSD$");
 
 #include <sys/types.h>
 #include <stdlib.h>
+#include <limits.h>
+#include <inttypes.h>
 #include <string.h>
 #include <libgeom.h>
 #include <libsade.h>
@@ -87,11 +89,11 @@ find_provcfg(struct gprovider *pp, const
 }
 
 struct gprovider *
-find_provider(struct ggeom *gp, unsigned long long minsector)
+find_provider(struct ggeom *gp, off_t minsector)
 {
 	struct gprovider *pp, *bestpp;
 	const char *s;
-	unsigned long long sector, bestsector;
+	off_t sector, bestsector;
 
 	bestpp = NULL;
 	bestsector = 0;
@@ -99,9 +101,10 @@ find_provider(struct ggeom *gp, unsigned
 		s = find_provcfg(pp, "start");
 		if (s == NULL) {
 			s = find_provcfg(pp, "offset");
-			sector = atoll(s) / pp->lg_sectorsize;
+			sector =
+			    (off_t)strtoimax(s, NULL, 0) / pp->lg_sectorsize;
 		} else
-			sector = atoll(s);
+			sector = (off_t)strtoimax(s, NULL, 0);
 
 		if (sector < minsector)
 			continue;



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