Skip to content
Commit 3dc14cb4 authored by Tao Bao's avatar Tao Bao
Browse files

Add ota_close(unique_fd&) and ota_fclose(std::unique_ptr<FILE>&).

We were using the below sequence prior to the CL in [1].

unique_fd fd(ota_open(...));
ota_close(fd);
fd.reset(ota_open(...));

fd.reset() may unintentionally close the newly opened FD if it
has the same value as the early ota_open. The CL in [1] changed to
"ota_close(fd.release())" to avoid the issue. This CL adds a new
overloaded function ota_close(unique_fd&) to handle the release
automatically.

Similarly add ota_fclose(std::unique_ptr<FILE>&).

[1] commit 48cf7704.

Bug: 33034669
Test: recovery_component_test passes.
Change-Id: Ief91edc590e95a7426e33364b28754173efb1056
parent 8dd44e90
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment