summaryrefslogtreecommitdiffstats
path: root/sbin/restore
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2016-04-19 20:47:14 +0000
committerpfg <pfg@FreeBSD.org>2016-04-19 20:47:14 +0000
commitb92544e73f822fb867851db8f4f2d542e287e0cc (patch)
treedb3244a093b181645f9d39516e59e9d2c293841a /sbin/restore
parentb4f1b9497df7399096b4129b583427d839421d9f (diff)
downloadFreeBSD-src-b92544e73f822fb867851db8f4f2d542e287e0cc.zip
FreeBSD-src-b92544e73f822fb867851db8f4f2d542e287e0cc.tar.gz
restore: use our roundup2/rounddown2() macros when param.h is available.
While here cleanup a little a malloc call.
Diffstat (limited to 'sbin/restore')
-rw-r--r--sbin/restore/dirs.c2
-rw-r--r--sbin/restore/symtab.c6
2 files changed, 4 insertions, 4 deletions
diff --git a/sbin/restore/dirs.c b/sbin/restore/dirs.c
index 8716de9..dcdc424 100644
--- a/sbin/restore/dirs.c
+++ b/sbin/restore/dirs.c
@@ -441,7 +441,7 @@ rst_seekdir(RST_DIR *dirp, long loc, long base)
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);
diff --git a/sbin/restore/symtab.c b/sbin/restore/symtab.c
index 9d0313d..7da7cc3 100644
--- a/sbin/restore/symtab.c
+++ b/sbin/restore/symtab.c
@@ -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");
}
OpenPOWER on IntegriCloud