소스 검색

Use fd_read() instead of fd_buf_copy()

The latter is doing unneeded work. Switch to use a simpler but equally
functional variant.
Guillem Jover 15 년 전
부모
커밋
12f71d6df3
3개의 변경된 파일9개의 추가작업 그리고 7개의 파일을 삭제
  1. 3 2
      lib/dpkg/parse.c
  2. 3 2
      src/filesdb.c
  3. 3 3
      src/statdb.c

+ 3 - 2
lib/dpkg/parse.c

@@ -41,7 +41,7 @@
 #include <dpkg/dpkg.h>
 #include <dpkg/dpkg-db.h>
 #include <dpkg/parsedump.h>
-#include <dpkg/buffer.h>
+#include <dpkg/fdio.h>
 
 /**
  * Fields information.
@@ -131,7 +131,8 @@ int parsedb(const char *filename, enum parsedbflags flags,
 #else
     dataptr = m_malloc(st.st_size);
 
-    fd_buf_copy(fd, dataptr, st.st_size, _("copy info file `%.255s'"), filename);
+    if (fd_read(fd, dataptr, st.st_size) < 0)
+      ohshite(_("reading package info file '%.255s'"), filename);
 #endif
     data= dataptr;
     endptr = dataptr + st.st_size;

+ 3 - 2
src/filesdb.c

@@ -44,7 +44,7 @@
 #include <dpkg/dpkg-db.h>
 #include <dpkg/path.h>
 #include <dpkg/dir.h>
-#include <dpkg/buffer.h>
+#include <dpkg/fdio.h>
 #include <dpkg/pkg-array.h>
 #include <dpkg/progress.h>
 
@@ -287,7 +287,8 @@ ensure_packagefiles_available(struct pkginfo *pkg)
      loaded_list = nfmalloc(stat_buf.st_size);
      loaded_list_end = loaded_list + stat_buf.st_size;
 
-    fd_buf_copy(fd, loaded_list, stat_buf.st_size, _("files list for package `%.250s'"), pkg->name);
+    if (fd_read(fd, loaded_list, stat_buf.st_size) < 0)
+      ohshite(_("reading files list for package '%.250s'"), pkg->name);
 
     lendp= &pkg->clientdata->files;
     thisline = loaded_list;

+ 3 - 3
src/statdb.c

@@ -37,7 +37,7 @@
 #include <dpkg/i18n.h>
 #include <dpkg/dpkg.h>
 #include <dpkg/dpkg-db.h>
-#include <dpkg/buffer.h>
+#include <dpkg/fdio.h>
 
 #include "filesdb.h"
 #include "main.h"
@@ -160,8 +160,8 @@ ensure_statoverrides(void)
 	loaded_list = nfmalloc(stab2.st_size);
 	loaded_list_end = loaded_list + stab2.st_size;
 
-	fd_buf_copy(fileno(file), loaded_list, stab2.st_size,
-	            _("statoverride file `%.250s'"), vb.buf);
+	if (fd_read(fileno(file), loaded_list, stab2.st_size) < 0)
+		ohshite(_("reading statoverride file '%.250s'"), vb.buf);
 
 	thisline = loaded_list;
 	while (thisline < loaded_list_end) {