Remove unused function memsize. [rsc] --rw-rw-r-- M 383570 glenda sys 10098 Sep 9 11:03 sys/src/cmd/disk/prep/prep.c /n/sourcesdump/2005/0909/plan9/sys/src/cmd/disk/prep/prep.c:25,31 - /n/sourcesdump/2005/0910/plan9/sys/src/cmd/disk/prep/prep.c:25,30 static int donvram; static void autoxpart(Edit*); - static vlong memsize(void); static Part *mkpart(char*, vlong, vlong, int); static void rdpart(Edit*); static void wrpart(Edit*); /n/sourcesdump/2005/0909/plan9/sys/src/cmd/disk/prep/prep.c:268,305 - /n/sourcesdump/2005/0910/plan9/sys/src/cmd/disk/prep/prep.c:267,272 if(isfrog[*(uchar*)elem]) return "bad character in name"; return nil; - } - - /* - * return memory size in bytes - */ - static vlong - memsize(void) - { - int fd, n, by2pg; - char *p; - char buf[128]; - vlong mem; - - p = getenv("cputype"); - if(p && (strcmp(p, "68020") == 0 || strcmp(p, "alpha") == 0)) - by2pg = 8*1024; - else - by2pg = 4*1024; - - mem = 64*1024*1024; - fd = open("/dev/swap", OREAD); - if(fd < 0) - return mem; - n = read(fd, buf, sizeof(buf)-1); - close(fd); - if(n <= 0) - return mem; - buf[n] = 0; - p = strchr(buf, '/'); - if(p) - mem = strtoul(p+1, 0, 0) * (vlong)by2pg; - return mem; } static Part* [sys] --rwxrwxr-x M 383570 glenda sys 95831 Sep 9 23:08 386/bin/disk/prep /sys/src/cmd/disk/prep/calc.y:yylex1 /sys/src/cmd/disk/prep/prep.c:autoxpart /sys/src/cmd/disk/prep/prep.c:checkfat /sys/src/cmd/disk/prep/prep.c:memsize /sys/src/cmd/disk/prep/prep.c:rdpart /sys/src/cmd/disk/prep/prep.c:restore /sys/src/cmd/disk/prep/prep.c:wrpart /sys/src/libc/9sys/getenv.c:getenv /sys/src/libc/fmt/fmt.c:_fmtinstall /sys/src/libc/fmt/sprint.c:sprint /sys/src/libc/port/pool.c:blocksetdsize /sys/src/libc/port/pool.c:trim /sys/src/libc/port/rune.c:chartorune /sys/src/libc/port/strtoul.c:strtoul /sys/src/libdisk/disk.c:opendisk Close fdf before removing it, to work around Steve Simon's cifs. Making spacing more consistent too. [rsc] --rw-rw-r-- M 383570 glenda sys 4241 Sep 9 11:01 sys/src/cmd/mv.c /n/sourcesdump/2005/0909/plan9/sys/src/cmd/mv.c:37,43 - /n/sourcesdump/2005/0910/plan9/sys/src/cmd/mv.c:37,43 } failed = 0; for(i=1; i < argc-1; i++) - if (mv(argv[i], todir, toelem) < 0) + if(mv(argv[i], todir, toelem) < 0) failed++; if(failed) exits("failure"); /n/sourcesdump/2005/0909/plan9/sys/src/cmd/mv.c:117,135 - /n/sourcesdump/2005/0910/plan9/sys/src/cmd/mv.c:117,134 close(fdf); return -1; } - if ((stat = copy1(fdf, fdt, fromname, toname)) != -1) { + stat = copy1(fdf, fdt, fromname, toname); + close(fdf); + if(stat >= 0){ nulldir(&null); null.mtime = dirb->mtime; null.mode = dirb->mode; dirfwstat(fdt, &null); /* ignore errors; e.g. user none always fails */ - if (remove(fromname) < 0) { + if(remove(fromname) < 0){ fprint(2, "mv: can't remove %s: %r\n", fromname); - close(fdf); - close(fdt); - return -1; + stat = -1; } } - close(fdf); close(fdt); return stat; } /n/sourcesdump/2005/0909/plan9/sys/src/cmd/mv.c:140,158 - /n/sourcesdump/2005/0910/plan9/sys/src/cmd/mv.c:139,157 char buf[8192]; long n, n1; - for(;;) { + for(;;){ n = read(fdf, buf, sizeof buf); - if(n >= 0) { + if(n >= 0){ if(n == 0) break; n1 = write(fdt, buf, n); - if(n1 != n) { + if(n1 != n){ fprint(2, "mv: error writing %s: %r\n", to); return -1; } } } - if(n < 0) { + if(n < 0){ fprint(2, "mv: error reading %s: %r\n", from); return -1; } [sys] --rwxrwxr-x M 383570 glenda sys 65489 Sep 9 23:08 386/bin/mv /sys/src/cmd/mv.c:mv Zero allocated data structures. [rsc] --rw-rw-r-- M 383570 glenda sys 6665 Sep 9 11:04 sys/src/libdisk/disk.c /n/sourcesdump/2005/0909/plan9/sys/src/libdisk/disk.c:272,278 - /n/sourcesdump/2005/0910/plan9/sys/src/libdisk/disk.c:272,278 char *p, *q; Disk *d; - d = malloc(sizeof(*d)); + d = mallocz(sizeof(*d), 1); if(d == nil) return nil; /n/sourcesdump/2005/0909/plan9/sys/src/libdisk/disk.c:347,350 - /n/sourcesdump/2005/0910/plan9/sys/src/libdisk/disk.c:347,349 d->type = Tfile; return openfile(d); } - [rsc] --rw-rw-r-- M 383570 glenda sys 6023 Sep 9 11:04 sys/src/libdisk/scsi.c /n/sourcesdump/2005/0909/plan9/sys/src/libdisk/scsi.c:308,320 - /n/sourcesdump/2005/0910/plan9/sys/src/libdisk/scsi.c:308,319 if((p = strdup(buf+8)) == nil) goto Error; - s = malloc(sizeof(*s)); + s = mallocz(sizeof(*s), 1); if(s == nil) { Error1: free(p); goto Error; } - memset(s, 0, sizeof(*s)); s->rawfd = rawfd; s->inquire = p; [sys] --rwxrwxr-x M 383570 glenda sys 161177 Sep 9 23:08 386/bin/cdfs /sys/src/libdisk/scsi.c:openscsi [sys] --rwxrwxr-x M 383570 glenda sys 103794 Sep 9 23:08 386/bin/disk/fdisk [sys] --rwxrwxr-x M 383570 glenda sys 89534 Sep 9 23:08 386/bin/disk/format [sys] --rwxrwxr-x M 383570 glenda sys 73689 Sep 9 23:08 386/bin/disk/mbr /sys/src/libdisk/disk.c:opendisk [sys] --rw-rw-r-- M 383570 glenda sys 42236 Sep 9 23:08 386/lib/libdisk.a