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

Commit 132b1ecd authored by Elliott Hughes's avatar Elliott Hughes
Browse files

Switch mkbootfs to C++.

Minimum changes just to get it to compile as C++, no real cleanup.

Change-Id: I8ff3fa35a07cdc9a6a246e79e33581e5d6598833
parent d7b46e39
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -6,7 +6,7 @@ package {


cc_binary_host {
cc_binary_host {
    name: "mkbootfs",
    name: "mkbootfs",
    srcs: ["mkbootfs.c"],
    srcs: ["mkbootfs.cpp"],
    cflags: ["-Werror"],
    cflags: ["-Werror"],
    static_libs: [
    static_libs: [
        "libbase",
        "libbase",
+8 −10
Original line number Original line Diff line number Diff line
@@ -75,7 +75,7 @@ static void fix_stat(const char *path, struct stat *s)
    }
    }
}
}


static void _eject(struct stat *s, char *out, int olen, char *data, unsigned datasize)
static void _eject(struct stat *s, const char *out, int olen, char *data, unsigned datasize)
{
{
    // Nothing is special about this value, just picked something in the
    // Nothing is special about this value, just picked something in the
    // approximate range that was being used already, and avoiding small
    // approximate range that was being used already, and avoiding small
@@ -151,9 +151,10 @@ static void _archive_dir(char *in, char *out, int ilen, int olen)
    DIR* d = opendir(in);
    DIR* d = opendir(in);
    if (d == NULL) err(1, "cannot open directory '%s'", in);
    if (d == NULL) err(1, "cannot open directory '%s'", in);


    // TODO: switch to std::vector
    int size = 32;
    int size = 32;
    int entries = 0;
    int entries = 0;
    char** names = malloc(size * sizeof(char*));
    char** names = (char**) malloc(size * sizeof(char*));
    if (names == NULL) {
    if (names == NULL) {
      errx(1, "failed to allocate dir names array (size %d)", size);
      errx(1, "failed to allocate dir names array (size %d)", size);
    }
    }
@@ -167,7 +168,7 @@ static void _archive_dir(char *in, char *out, int ilen, int olen)


        if (entries >= size) {
        if (entries >= size) {
          size *= 2;
          size *= 2;
          names = realloc(names, size * sizeof(char*));
          names = (char**) realloc(names, size * sizeof(char*));
          if (names == NULL) {
          if (names == NULL) {
            errx(1, "failed to reallocate dir names array (size %d)", size);
            errx(1, "failed to reallocate dir names array (size %d)", size);
          }
          }
@@ -447,13 +448,10 @@ int main(int argc, char *argv[])


    while (num_dirs-- > 0){
    while (num_dirs-- > 0){
        char *x = strchr(*argv, '=');
        char *x = strchr(*argv, '=');
        if(x != 0) {
        if (x != nullptr) {
            *x++ = 0;
            *x++ = '\0';
        } else {
            x = "";
        }
        }

        archive(*argv, x ?: "");
        archive(*argv, x);


        argv++;
        argv++;
    }
    }