From: Julian Andres Klode Date: Mon, 28 Dec 2015 10:41:04 +0000 (+0100) Subject: apt-helper: Use CopyFile() for concatenating the files X-Git-Tag: 1.1.10~11 X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/ff2717e8c6a7633bbd38be95b2d30615802b6679 apt-helper: Use CopyFile() for concatenating the files There's no point in keeping using yet another read-then-write loop. Gbp-Dch: ignore --- diff --git a/cmdline/apt-helper.cc b/cmdline/apt-helper.cc index a519f3042..5e0b00c46 100644 --- a/cmdline/apt-helper.cc +++ b/cmdline/apt-helper.cc @@ -111,8 +111,6 @@ static bool DoCatFile(CommandLine &CmdL) /*{{{*/ { FileFd fd; FileFd out; - char buf[4096]; - unsigned long long read; if (out.OpenDescriptor(STDOUT_FILENO, FileFd::WriteOnly) == false) return false; @@ -127,14 +125,8 @@ static bool DoCatFile(CommandLine &CmdL) /*{{{*/ if (fd.Open(name, FileFd::ReadOnly, FileFd::Extension) == false) return false; - for (;;) { - if (fd.Read(buf, sizeof(buf), &read) == false) - return false; - if (read == 0) - break; - if (out.Write(buf, read) == false) - return false; - } + if (CopyFile(fd, out) == false) + return false; } return true; }