Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Apr 2016 20:47:14 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r298296 - head/sbin/restore
Message-ID:  <201604192047.u3JKlEL1043093@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pfg
Date: Tue Apr 19 20:47:14 2016
New Revision: 298296
URL: https://svnweb.freebsd.org/changeset/base/298296

Log:
  restore: use our roundup2/rounddown2() macros when param.h is available.
  
  While here cleanup a little a malloc call.

Modified:
  head/sbin/restore/dirs.c
  head/sbin/restore/symtab.c

Modified: head/sbin/restore/dirs.c
==============================================================================
--- head/sbin/restore/dirs.c	Tue Apr 19 20:43:05 2016	(r298295)
+++ head/sbin/restore/dirs.c	Tue Apr 19 20:47:14 2016	(r298296)
@@ -441,7 +441,7 @@ rst_seekdir(RST_DIR *dirp, long loc, lon
 	loc -= base;
 	if (loc < 0)
 		fprintf(stderr, "bad seek pointer to rst_seekdir %ld\n", loc);
-	(void) lseek(dirp->dd_fd, base + (loc & ~(DIRBLKSIZ - 1)), SEEK_SET);
+	(void) lseek(dirp->dd_fd, base + rounddown2(loc, DIRBLKSIZ), SEEK_SET);
 	dirp->dd_loc = loc & (DIRBLKSIZ - 1);
 	if (dirp->dd_loc != 0)
 		dirp->dd_size = read(dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ);

Modified: head/sbin/restore/symtab.c
==============================================================================
--- head/sbin/restore/symtab.c	Tue Apr 19 20:43:05 2016	(r298295)
+++ head/sbin/restore/symtab.c	Tue Apr 19 20:47:14 2016	(r298296)
@@ -372,7 +372,7 @@ struct strhdr {
 };
 
 #define STRTBLINCR	(sizeof(struct strhdr))
-#define allocsize(size)	(((size) + 1 + STRTBLINCR - 1) & ~(STRTBLINCR - 1))
+#define	allocsize(size)	roundup2((size) + 1, STRTBLINCR)
 
 static struct strhdr strtblhdr[allocsize(NAME_MAX) / STRTBLINCR];
 
@@ -384,7 +384,7 @@ char *
 savename(char *name)
 {
 	struct strhdr *np;
-	long len;
+	size_t len;
 	char *cp;
 
 	if (name == NULL)
@@ -395,7 +395,7 @@ savename(char *name)
 		strtblhdr[len / STRTBLINCR].next = np->next;
 		cp = (char *)np;
 	} else {
-		cp = malloc((unsigned)allocsize(len));
+		cp = malloc(allocsize(len));
 		if (cp == NULL)
 			panic("no space for string table\n");
 	}



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