Skip to content

Commit

Permalink
magiskboot: clean-up
Browse files Browse the repository at this point in the history
Signed-off-by: svoboda18 <[email protected]>
  • Loading branch information
svoboda18 committed Aug 27, 2022
1 parent e1898bf commit 2d1fdc3
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 21 deletions.
3 changes: 0 additions & 3 deletions bootimg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ using namespace std;
uint32_t dyn_img_hdr::j32 = 0;
uint64_t dyn_img_hdr::j64 = 0;

#ifdef SVB_MINGW
#define creat(path, mode) xopen(path, O_TRUNC | O_RDWR | O_CREAT, mode)
#endif
#define PADDING 15

static void decompress(format_t type, int fd, const void *in, size_t size) {
Expand Down
8 changes: 4 additions & 4 deletions compress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ void decompress(char *infile, const char *outfile) {
bool in_std = infile == "-"sv;
bool rm_in = false;

FILE *in_fp = in_std ? stdin : xfopen(infile, "re" BINARY);
FILE *in_fp = in_std ? stdin : xfopen(infile, "re");
stream_ptr strm;

char buf[4096];
Expand Down Expand Up @@ -619,7 +619,7 @@ void decompress(char *infile, const char *outfile) {
}
}

FILE *out_fp = outfile == "-"sv ? stdout : xfopen(outfile, "we" BINARY);
FILE *out_fp = outfile == "-"sv ? stdout : xfopen(outfile, "we");
strm = get_decoder(type, make_unique<fp_stream>(out_fp));
if (ext) *ext = '.';
}
Expand All @@ -642,7 +642,7 @@ void compress(const char *method, const char *infile, const char *outfile) {
bool in_std = infile == "-"sv;
bool rm_in = false;

FILE *in_fp = in_std ? stdin : xfopen(infile, "re" BINARY);
FILE *in_fp = in_std ? stdin : xfopen(infile, "re");
FILE *out_fp;

if (outfile == nullptr) {
Expand All @@ -658,7 +658,7 @@ void compress(const char *method, const char *infile, const char *outfile) {
rm_in = true;
}
} else {
out_fp = outfile == "-"sv ? stdout : xfopen(outfile, "we" BINARY);
out_fp = outfile == "-"sv ? stdout : xfopen(outfile, "we");
}

auto strm = get_encoder(fmt, make_unique<fp_stream>(out_fp));
Expand Down
6 changes: 5 additions & 1 deletion cpio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ static cpio::entry_map recursive_dir_iterator(const char* root, const char* conf

void cpio::dump(const char *file) {
fprintf(stderr, "Dump cpio: [%s]\n", file);
dump(xfopen(file, "we" BINARY));
dump(xfopen(file, "we"));
}

void cpio::rm(entry_map::iterator it) {
Expand Down Expand Up @@ -176,7 +176,11 @@ void cpio::extract_entry(const entry_map::value_type &e, const char *file) {
void cpio::extract() {
unlink("cpio");
rmdir("ramdisk");
#ifdef SVB_MINGW
::mkdir("ramdisk");
#else
::mkdir("ramdisk", 0744);
#endif
for (auto &e : entries)
extract_entry(e, ("ramdisk/" + e.first).data());
}
Expand Down
8 changes: 1 addition & 7 deletions magiskbase/include/base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@
#include "../missing.hpp"
#endif

#ifdef SVB_MINGW
#define BINARY "b"
#else
#define BINARY
#endif

#include "../xwrap.hpp"
#include "../files.hpp"
#include "../misc.hpp"
Expand All @@ -24,6 +18,6 @@

#define LOG(fmt, args...) fprintf(stderr, fmt, ##args)
#define PLOGE(fmt, args...) LOG(fmt " failed with %d: %s\n", ##args, errno, std::strerror(errno))
#define LOGE(fmt, args...) LOG("Error: " fmt, ##args)
#define LOGE(fmt, args...) { LOG("Error: " fmt, ##args); exit(1); }
#define LOGW(fmt, args...) LOG("Warning: " fmt, ##args)
#define LOGD(fmt, args...) LOG("Debug: " fmt, ##args)
6 changes: 0 additions & 6 deletions magiskbase/xwrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ FILE *xfdopen(int fd, const char *mode) {
}

int xopen(const char *pathname, int flags) {
#ifdef SVB_MINGW
flags |= O_BINARY;
#endif
int fd = open(pathname, flags);
if (fd < 0) {
PLOGE("open: %s", pathname);
Expand All @@ -47,9 +44,6 @@ int xopen(const char *pathname, int flags) {
}

int xopen(const char *pathname, int flags, mode_t mode) {
#ifdef SVB_MINGW
flags |= O_BINARY;
#endif
int fd = open(pathname, flags, mode);
if (fd < 0) {
PLOGE("open: %s", pathname);
Expand Down

0 comments on commit 2d1fdc3

Please sign in to comment.