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

Commit 7c511184 authored by Tao Bao's avatar Tao Bao Committed by Gerrit Code Review
Browse files

Merge "updater: Clean up char* with std::string."

parents e67104a6 e6aa3326
Loading
Loading
Loading
Loading
+1 −11
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#include "applypatch.h"
#include "mtdutils/mtdutils.h"
#include "edify/expr.h"
#include "print_sha1.h"

static int LoadPartitionContents(const char* filename, FileContents* file);
static ssize_t FileSink(const unsigned char* data, ssize_t len, void* token);
@@ -43,7 +44,6 @@ static int GenerateTarget(FileContents* source_file,
                          const uint8_t target_sha1[SHA_DIGEST_SIZE],
                          size_t target_size,
                          const Value* bonus_data);
static std::string short_sha1(const uint8_t sha1[SHA_DIGEST_SIZE]);

static bool mtd_partitions_scanned = false;

@@ -630,16 +630,6 @@ int CacheSizeCheck(size_t bytes) {
    }
}

static std::string short_sha1(const uint8_t sha1[SHA_DIGEST_SIZE]) {
    const char* hex = "0123456789abcdef";
    std::string result = "";
    for (size_t i = 0; i < 4; ++i) {
        result.push_back(hex[(sha1[i]>>4) & 0xf]);
        result.push_back(hex[sha1[i] & 0xf]);
    }
    return result;
}

// This function applies binary patches to files in a way that is safe
// (the original file is not touched until we have the desired
// replacement for it) and idempotent (it's okay to run this program
+0 −8
Original line number Diff line number Diff line
@@ -17,10 +17,6 @@
#ifndef _RECOVERY_BOOTLOADER_H
#define _RECOVERY_BOOTLOADER_H

#ifdef __cplusplus
extern "C" {
#endif

/* Bootloader Message
 *
 * This structure describes the content of a block in flash
@@ -64,8 +60,4 @@ struct bootloader_message {
int get_bootloader_message(struct bootloader_message *out);
int set_bootloader_message(const struct bootloader_message *in);

#ifdef __cplusplus
}
#endif

#endif
+0 −8
Original line number Diff line number Diff line
@@ -21,10 +21,6 @@
#include <stdio.h>
#include <stdarg.h>

#ifdef __cplusplus
extern "C" {
#endif

#define LOGE(...) ui_print("E:" __VA_ARGS__)
#define LOGW(...) fprintf(stdout, "W:" __VA_ARGS__)
#define LOGI(...) fprintf(stdout, "I:" __VA_ARGS__)
@@ -50,8 +46,4 @@ void ui_print(const char* format, ...);

bool is_ro_debuggable();

#ifdef __cplusplus
}
#endif

#endif  // RECOVERY_COMMON_H

print_sha1.h

0 → 100644
+43 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef RECOVERY_PRINT_SHA1_H
#define RECOVERY_PRINT_SHA1_H

#include <stdint.h>
#include <string>

#include "mincrypt/sha.h"

static std::string print_sha1(const uint8_t sha1[SHA_DIGEST_SIZE], size_t len) {
    const char* hex = "0123456789abcdef";
    std::string result = "";
    for (size_t i = 0; i < len; ++i) {
        result.push_back(hex[(sha1[i]>>4) & 0xf]);
        result.push_back(hex[sha1[i] & 0xf]);
    }
    return result;
}

static std::string print_sha1(const uint8_t sha1[SHA_DIGEST_SIZE]) {
    return print_sha1(sha1, SHA_DIGEST_SIZE);
}

static std::string short_sha1(const uint8_t sha1[SHA_DIGEST_SIZE]) {
    return print_sha1(sha1, 4);
}

#endif  // RECOVERY_PRINT_SHA1_H
+141 −261

File changed.

Preview size limit exceeded, changes collapsed.