Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 776c67b4 authored by Bowgo Tsai's avatar Bowgo Tsai Committed by android-build-merger
Browse files

Merge "fs_mgr: trim the terminating '\0' when reading from device tree" am: b76158d5

am: 3205cd6c

Change-Id: I81cb7e1f3bf6043bfc2f8383ba1bc6929d9785c8
parents 914e3417 3205cd6c
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@
 * limitations under the License.
 */

#include <string>

#include <android-base/file.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
@@ -51,11 +53,13 @@ bool fs_mgr_get_boot_config(const std::string& key, std::string* out_val) {
    // lastly, check the device tree
    if (is_dt_compatible()) {
        std::string file_name = kAndroidDtDir + "/" + key;
        // DT entries terminate with '\0' but so do the properties
        if (android::base::ReadFileToString(file_name, out_val)) {
            if (!out_val->empty()) {
                out_val->pop_back();  // Trims the trailing '\0' out.
                return true;
            }
        }
    }

    return false;
}