OSDN Git Service

DO NOT MERGE: fec: remove unneeded target executable
authorSami Tolvanen <samitolvanen@google.com>
Thu, 1 Sep 2016 20:43:51 +0000 (13:43 -0700)
committerZheng Zhang <zhzh@google.com>
Sun, 20 Nov 2016 06:21:21 +0000 (06:21 +0000)
Bug: 32789520

Change-Id: Ic925814191b8ac952b584a994cf455f871a8ee0c

(cherrypicked from commit 4c716c92a691e6b39e8e65a397f9b6e91f9e07ee)

verity/fec/Android.mk
verity/fec/image.cpp

index c13f577..5fff9c3 100644 (file)
@@ -19,23 +19,4 @@ LOCAL_STATIC_LIBRARIES := \
 LOCAL_SHARED_LIBRARIES := libbase
 LOCAL_CFLAGS += -Wall -Werror -O3
 LOCAL_C_INCLUDES += external/fec
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_CLANG := true
-LOCAL_SANITIZE := integer
-LOCAL_MODULE := fec
-LOCAL_FORCE_STATIC_EXECUTABLE := true
-LOCAL_SRC_FILES := main.cpp image.cpp
-LOCAL_MODULE_TAGS := optional
-LOCAL_STATIC_LIBRARIES := \
-    libcrypto_static \
-    libfec \
-    libfec_rs \
-    libbase \
-    libext4_utils_static \
-    libsquashfs_utils \
-    libcutils
-LOCAL_CFLAGS += -Wall -Werror -O3 -DIMAGE_NO_SPARSE=1
-LOCAL_C_INCLUDES += external/fec
-include $(BUILD_EXECUTABLE)
+include $(BUILD_HOST_EXECUTABLE)
\ No newline at end of file
index 780d981..7c1eab7 100644 (file)
@@ -33,9 +33,7 @@ extern "C" {
 #include <string.h>
 #include <sys/ioctl.h>
 #include <sys/mman.h>
-#ifndef IMAGE_NO_SPARSE
 #include <sparse/sparse.h>
-#endif
 #include "image.h"
 
 #if defined(__linux__)
@@ -66,31 +64,6 @@ void image_free(image *ctx)
     image_init(ctx);
 }
 
-#ifdef IMAGE_NO_SPARSE
-static uint64_t get_size(int fd)
-{
-    struct stat st;
-
-    if (fstat(fd, &st) == -1) {
-        FATAL("failed to fstat: %s\n", strerror(errno));
-    }
-
-    uint64_t size = 0;
-
-    if (S_ISBLK(st.st_mode)) {
-        if (ioctl(fd, BLKGETSIZE64, &size) == -1) {
-            FATAL("failed to ioctl(BLKGETSIZE64): %s\n", strerror(errno));
-        }
-    } else if (S_ISREG(st.st_mode)) {
-        size = st.st_size;
-    } else {
-        FATAL("unknown file mode: %d\n", (int)st.st_mode);
-    }
-
-    return size;
-}
-#endif
-
 static void calculate_rounds(uint64_t size, image *ctx)
 {
     if (!size) {
@@ -105,7 +78,6 @@ static void calculate_rounds(uint64_t size, image *ctx)
     ctx->rounds = fec_div_round_up(ctx->blocks, ctx->rs_n);
 }
 
-#ifndef IMAGE_NO_SPARSE
 static int process_chunk(void *priv, const void *data, int len)
 {
     image *ctx = (image *)priv;
@@ -118,25 +90,14 @@ static int process_chunk(void *priv, const void *data, int len)
     ctx->pos += len;
     return 0;
 }
-#endif
 
 static void file_image_load(const std::vector<int>& fds, image *ctx)
 {
     uint64_t size = 0;
-#ifndef IMAGE_NO_SPARSE
     std::vector<struct sparse_file *> files;
-#endif
 
     for (auto fd : fds) {
         uint64_t len = 0;
-
-#ifdef IMAGE_NO_SPARSE
-        if (ctx->sparse) {
-            FATAL("sparse files not supported\n");
-        }
-
-        len = get_size(fd);
-#else
         struct sparse_file *file;
 
         if (ctx->sparse) {
@@ -151,7 +112,6 @@ static void file_image_load(const std::vector<int>& fds, image *ctx)
 
         len = sparse_file_len(file, false, false);
         files.push_back(file);
-#endif /* IMAGE_NO_SPARSE */
 
         size += len;
     }
@@ -172,18 +132,6 @@ static void file_image_load(const std::vector<int>& fds, image *ctx)
     ctx->output = ctx->input;
     ctx->pos = 0;
 
-#ifdef IMAGE_NO_SPARSE
-    for (auto fd : fds) {
-        uint64_t len = get_size(fd);
-
-        if (!android::base::ReadFully(fd, &ctx->input[ctx->pos], len)) {
-            FATAL("failed to read: %s\n", strerror(errno));
-        }
-
-        ctx->pos += len;
-        close(fd);
-    }
-#else
     for (auto file : files) {
         sparse_file_callback(file, false, false, process_chunk, ctx);
         sparse_file_destroy(file);
@@ -192,7 +140,6 @@ static void file_image_load(const std::vector<int>& fds, image *ctx)
     for (auto fd : fds) {
         close(fd);
     }
-#endif
 }
 
 bool image_load(const std::vector<std::string>& filenames, image *ctx)