PERFORCE change 123587 for review
Garrett Cooper
gcooper at FreeBSD.org
Mon Jul 16 12:27:09 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=123587
Change 123587 by gcooper at optimus-revised_pkgtools on 2007/07/16 12:26:44
- Check to make sure read(2) returns the stat'ed file length, instead of a non-(-1) value.
- Use write(2) instead of fwrite(2) based on results from my "fat" tool. Hopefully this results in a 30% to 3-fold speedup.
Affected files ...
.. //depot/projects/soc2007/revised_fbsd_pkgtools/usr/src/usr.sbin/pkg_install/lib/file.c#8 edit
Differences ...
==== //depot/projects/soc2007/revised_fbsd_pkgtools/usr/src/usr.sbin/pkg_install/lib/file.c#8 (text+ko) ====
@@ -223,7 +223,7 @@
contents = (char *)malloc(sb.st_size + 1);
- if (read(fileno(fd), contents, sb.st_size) == -1) {
+ if (read(fileno(fd), contents, sb.st_size) != sb.st_size) {
cleanup(0);
errx(2, "%s: short read on '%s' - did not get %lld bytes", __func__,
fname, (long long)sb.st_size);
@@ -280,10 +280,10 @@
errx(2, "%s: cannot fopen '%s' for writing", __func__, name);
}
len = strlen(str);
- if (fwrite(str, 1, len, fp) != len) {
+ if (write(fileno(fp), str, len) != len) {
cleanup(0);
- errx(2, "%s: short fwrite on '%s', tried to write %ld bytes",
- __func__, name, (long)len);
+ errx(2, "%s: short fwrite on '%s', tried to write %lld bytes",
+ __func__, name, (long long)len);
}
if (fclose(fp)) {
cleanup(0);
More information about the p4-projects
mailing list