On Mon, Jun 27, 2011 at 03:44:43PM -0400, Ted Unangst wrote:
> useless and or wrong
Gee, you couldn't eliminate that magic 256? :-). ok krw@
.... Ken
>
> Index: dirs.c
> ===================================================================
> RCS file: /home/tedu/cvs/src/sbin/restore/dirs.c,v
> retrieving revision 1.32
> diff -u -r1.32 dirs.c
> --- dirs.c 27 Oct 2009 23:59:34 -0000 1.32
> +++ dirs.c 27 Jun 2011 19:38:06 -0000
> @@ -407,7 +407,7 @@
> (void)fwrite(dirbuf, 1, DIRBLKSIZ, df);
> dirloc = 0;
> }
> - memcpy(dirbuf + dirloc, dp, (long)dp->d_reclen);
> + memcpy(dirbuf + dirloc, dp, dp->d_reclen);
> prev = dirloc;
> dirloc += dp->d_reclen;
> }
> @@ -428,7 +428,7 @@
> dcvt(struct odirect *odp, struct direct *ndp)
> {
>
> - memset(ndp, 0, (size_t)(sizeof *ndp));
> + memset(ndp, 0, sizeof *ndp);
> if (Bcvt)
> ndp->d_ino = swap16(odp->d_ino);
> else
> Index: interactive.c
> ===================================================================
> RCS file: /home/tedu/cvs/src/sbin/restore/interactive.c,v
> retrieving revision 1.26
> diff -u -r1.26 interactive.c
> --- interactive.c 27 Oct 2009 23:59:34 -0000 1.26
> +++ interactive.c 27 Jun 2011 19:40:31 -0000
> @@ -527,7 +527,7 @@
> while ((dp = rst_readdir(dirp)))
> entries++;
> rst_closedir(dirp);
> - list = (struct afile *)calloc(entries, sizeof(struct afile));
> + list = calloc(entries, sizeof(struct afile));
> if (list == NULL) {
> fprintf(stderr, "ls: out of memory\n");
> return;
> Index: symtab.c
> ===================================================================
> RCS file: /home/tedu/cvs/src/sbin/restore/symtab.c,v
> retrieving revision 1.18
> diff -u -r1.18 symtab.c
> --- symtab.c 27 Oct 2009 23:59:34 -0000 1.18
> +++ symtab.c 27 Jun 2011 19:41:32 -0000
> @@ -190,7 +190,7 @@
>
> for (cp = &namebuf[MAXPATHLEN - 2]; cp > &namebuf[ep->e_namlen]; ) {
> cp -= ep->e_namlen;
> - memcpy(cp, ep->e_name, (long)ep->e_namlen);
> + memcpy(cp, ep->e_name, ep->e_namlen);
> if (ep == lookupino(ROOTINO))
> return (cp);
> *(--cp) = '/';
> @@ -217,9 +217,9 @@
> if (freelist != NULL) {
> np = freelist;
> freelist = np->e_next;
> - memset(np, 0, (long)sizeof(struct entry));
> + memset(np, 0, sizeof(struct entry));
> } else {
> - np = (struct entry *)calloc(1, sizeof(struct entry));
> + np = calloc(1, sizeof(struct entry));
> if (np == NULL)
> panic("no memory to extend symbol table\n");
> }
> @@ -388,7 +388,7 @@
> 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");
> }
> @@ -464,7 +464,7 @@
> stroff = 0;
> for (i = ROOTINO; i <= maxino; i++) {
> for (ep = lookupino(i); ep != NULL; ep = ep->e_links) {
> - memcpy(tep, ep, (long)sizeof(struct entry));
> + memcpy(tep, ep, sizeof(struct entry));
> tep->e_name = (char *)stroff;
> stroff += allocsize(ep->e_namlen);
> tep->e_parent = (struct entry *)ep->e_parent->e_index;
> @@ -527,9 +527,8 @@
> Vprintf(stdout, "Initialize symbol table.\n");
> if (filename == NULL) {
> entrytblsize = maxino / HASHFACTOR;
> - entry = (struct entry **)
> - calloc((unsigned)entrytblsize, sizeof(struct entry *));
> - if (entry == (struct entry **)NULL)
> + entry = calloc(entrytblsize, sizeof(struct entry *));
> + if (entry == NULL)
> panic("no memory for entry table\n");
> ep = addentry(".", ROOTINO, NODE);
> ep->e_flags |= NEW;
> @@ -544,11 +543,11 @@
> panic("cannot stat symbol table file %s\n", filename);
> }
> tblsize = stbuf.st_size - sizeof(struct symtableheader);
> - base = calloc((unsigned)tblsize, sizeof(char));
> + base = calloc(tblsize, sizeof(char));
> if (base == NULL)
> panic("cannot allocate space for symbol table\n");
> - if (read(fd, base, (int)tblsize) < 0 ||
> - read(fd, (char *)&hdr, sizeof(struct symtableheader)) < 0) {
> + if (read(fd, base, tblsize) < 0 ||
> + read(fd, &hdr, sizeof(struct symtableheader)) < 0) {
> warn("read");
> panic("cannot read symbol table file %s\n", filename);
> }
> Index: tape.c
> ===================================================================
> RCS file: /home/tedu/cvs/src/sbin/restore/tape.c,v
> retrieving revision 1.38
> diff -u -r1.38 tape.c
> --- tape.c 27 Oct 2009 23:59:34 -0000 1.38
> +++ tape.c 27 Jun 2011 19:41:57 -0000
> @@ -253,7 +253,7 @@
> errx(1, "Cannot find file removal list");
> maxino = (spcl.c_count * TP_BSIZE * NBBY) + 1;
> Dprintf(stdout, "maxino = %d\n", maxino);
> - map = calloc((unsigned)1, (unsigned)howmany(maxino, NBBY));
> + map = calloc(1, howmany(maxino, NBBY));
> if (map == NULL)
> panic("no memory for active inode map\n");
> usedinomap = map;
> @@ -261,7 +261,7 @@
> getfile(xtrmap, xtrmapskip);
> if (spcl.c_type != TS_BITS)
> errx(1, "Cannot find file dump list");
> - map = calloc((size_t)1, (size_t)howmany(maxino, NBBY));
> + map = calloc(1, howmany(maxino, NBBY));
> if (map == NULL)
> panic("no memory for file dump list\n");
> dumpmap = map;
> @@ -819,7 +819,7 @@
> int cnt, seek_failed;
>
> if (blkcnt < numtrec) {
> - memcpy(buf, &tapebuf[(blkcnt++ * TP_BSIZE)], (long)TP_BSIZE);
> + memcpy(buf, &tapebuf[(blkcnt++ * TP_BSIZE)], TP_BSIZE);
> blksread++;
> tpblksread++;
> return;
> @@ -919,10 +919,10 @@
> panic("partial block read: %d should be %d\n",
> rd, ntrec * TP_BSIZE);
> terminateinput();
> - memcpy(&tapebuf[rd], &endoftapemark, (long)TP_BSIZE);
> + memcpy(&tapebuf[rd], &endoftapemark, TP_BSIZE);
> }
> blkcnt = 0;
> - memcpy(buf, &tapebuf[(blkcnt++ * TP_BSIZE)], (long)TP_BSIZE);
> + memcpy(buf, &tapebuf[(blkcnt++ * TP_BSIZE)], TP_BSIZE);
> blksread++;
> tpblksread++;
> }
> @@ -1011,7 +1011,7 @@
> swap_old_header(&u_ospcl.s_ospcl);
> }
>
> - memset(buf, 0, (long)TP_BSIZE);
> + memset(buf, 0, TP_BSIZE);
> buf->c_type = u_ospcl.s_ospcl.c_type;
> buf->c_date = u_ospcl.s_ospcl.c_date;
> buf->c_ddate = u_ospcl.s_ospcl.c_ddate;
> @@ -1027,7 +1027,7 @@
> buf->c_atime = u_ospcl.s_ospcl.c_odinode.odi_atime;
> buf->c_mtime = u_ospcl.s_ospcl.c_odinode.odi_mtime;
> buf->c_count = u_ospcl.s_ospcl.c_count;
> - memcpy(buf->c_addr, u_ospcl.s_ospcl.c_addr, (long)256);
> + memcpy(buf->c_addr, u_ospcl.s_ospcl.c_addr, 256);
> buf->c_magic = FS_UFS2_MAGIC;
> good:
> switch (buf->c_type) {