system/corennnnn
リビジョン | b34cff344cfe26fbd6f6f0cf1b335b92b39b4228 (tree) |
---|---|
日時 | 2016-07-29 19:25:47 |
作者 | Biao Lu <biao.lu@inte...> |
コミッター | Chih-Wei Huang |
init: Fix load_firmware error
In function 'load_firmware', parameter 'buf' passed to 'write'
is wrong. To fix it, use android::base::WriteFully to replace.
Change-Id: I13f79bdc9be9e5eb669f6bd975535b1dce965ef0
Signed-off-by: Biao Lu <biao.lu@intel.com>
@@ -40,6 +40,7 @@ | ||
40 | 40 | #include <sys/time.h> |
41 | 41 | #include <sys/wait.h> |
42 | 42 | |
43 | +#include <base/file.h> | |
43 | 44 | #include <cutils/list.h> |
44 | 45 | #include <cutils/probe_module.h> |
45 | 46 | #include <cutils/uevent.h> |
@@ -952,21 +953,13 @@ static int load_firmware(int fw_fd, int loading_fd, int data_fd) | ||
952 | 953 | ret = -1; |
953 | 954 | break; |
954 | 955 | } |
955 | - | |
956 | - len_to_copy -= nr; | |
957 | - while (nr > 0) { | |
958 | - ssize_t nw = 0; | |
959 | - | |
960 | - nw = write(data_fd, buf + nw, nr); | |
961 | - if(nw <= 0) { | |
962 | - ret = -1; | |
963 | - goto out; | |
964 | - } | |
965 | - nr -= nw; | |
956 | + if (!android::base::WriteFully(data_fd, buf, nr)) { | |
957 | + ret = -1; | |
958 | + break; | |
966 | 959 | } |
960 | + len_to_copy -= nr; | |
967 | 961 | } |
968 | 962 | |
969 | -out: | |
970 | 963 | if(!ret) |
971 | 964 | write(loading_fd, "0", 1); /* successful end of transfer */ |
972 | 965 | else |