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");
        }
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to