public:
NewlineLogger(std::ostream& sink) : sink_(sink) {}
~NewlineLogger() {
- sink_ << stream.str() << std::endl;
+ try {
+ sink_ << stream.str() << std::endl;
+ } catch(...) {
+ }
}
std::ostringstream stream;
bool list_tables = false;
bool free_space = false;
- for (int i = 2; i < argc; ++i) {
- if (std::string_view(argv[i]).compare("--list-tables") == 0) {
- list_tables = true;
- } else if (std::string_view(argv[i]).compare("--free-space") == 0) {
- free_space = true;
- } else {
- usage(argv[0]);
- return 1;
+ try {
+ for (int i = 2; i < argc; ++i) {
+ if (std::string_view(argv[i]).compare("--list-tables") == 0) {
+ list_tables = true;
+ } else if (std::string_view(argv[i]).compare("--free-space") == 0) {
+ free_space = true;
+ } else {
+ usage(argv[0]);
+ return 1;
+ }
}
- }
- auto metadata = ReadMetadata(argv[1], 0);
+ auto metadata = ReadMetadata(argv[1], 0);
- if (!metadata) {
- cerr << "Failed to parse metadata from \"" << argv[1] << "\"" << endl;
- return 1;
- }
+ if (!metadata) {
+ cerr << "Failed to parse metadata from \"" << argv[1] << "\"" << endl;
+ return 1;
+ }
- std::optional<std::string> out;
+ std::optional<std::string> out;
- if (free_space) {
- out = go_free(*metadata, list_tables, argv[1], cerr);
- } else {
- out = go(*metadata, list_tables, argv[1], cerr);
- }
+ if (free_space) {
+ out = go_free(*metadata, list_tables, argv[1], cerr);
+ } else {
+ out = go(*metadata, list_tables, argv[1], cerr);
+ }
- if (out)
- cout << *out << "\n";
- else
+ if (out)
+ cout << *out << "\n";
+ else
+ return 1;
+ } catch(...) {
+ cerr << "Error occured" << endl;
return 1;
+ }
return 0;
}
vector<update_cfg_record> update_cfg_records;
- if (update_cfg_path != "" && !readFromUpdateCfgFile(update_cfg_path, update_cfg_records, cerr)) {
- cerr << "Could not read from " << update_cfg_path << endl;
- return 1;
- }
+ try {
+ if (update_cfg_path != "" && !readFromUpdateCfgFile(update_cfg_path, update_cfg_records, cerr)) {
+ cerr << "Could not read from " << update_cfg_path << endl;
+ return 1;
+ }
- auto metadata = android::fs_mgr::ReadMetadata(super_path, 0);
+ auto metadata = android::fs_mgr::ReadMetadata(super_path, 0);
- if (!metadata) {
- cerr << "Could not read super partition metadata for " << super_path << "\n";
- return 1;
- }
+ if (!metadata) {
+ cerr << "Could not read super partition metadata for " << super_path << "\n";
+ return 1;
+ }
- auto metadata_new = go(*metadata, slot, update_cfg_records, cerr);
+ auto metadata_new = go(*metadata, slot, update_cfg_records, cerr);
- if (metadata_new == nullptr) {
- return 1;
- }
+ if (metadata_new == nullptr) {
+ return 1;
+ }
- if (!UpdatePartitionTable(super_path, *metadata_new, 0)) {
- cerr << "Failed to write metadata.";
+ if (!UpdatePartitionTable(super_path, *metadata_new, 0)) {
+ cerr << "Failed to write metadata.";
+ return 1;
+ }
+ } catch(...) {
+ cerr << "Error occured" << endl;
return 1;
}
}
if ((res = remmap(&data.src, 0)) != PF_OK)
return res;
- if ((res = remmap(&data.dest, 0)) != PF_OK)
+ if ((res = remmap(&data.dest, 0)) != PF_OK) {
+ free_data(&data, funcs);
return res;
+ }
uint64_t progress_report_block_count = 0;
if (block_count != NULL) {