restore: use our roundup2/rounddown2() macros when param.h is available.

While here cleanup a little a malloc call.
This commit is contained in:
Pedro F. Giffuni 2016-04-19 20:47:14 +00:00
parent cff92ffd4d
commit 05cfc40ab0
2 changed files with 4 additions and 4 deletions

View File

@ -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);

View File

@ -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");
}