mirror of
https://github.com/SciresM/hactool
synced 2024-11-12 23:47:09 +00:00
npdm: Invert top-level conditional within ndpm_save()
Allows for denesting of the code.
This commit is contained in:
parent
ff6c8eba11
commit
ab6fe349da
1 changed files with 15 additions and 12 deletions
27
npdm.c
27
npdm.c
|
@ -662,19 +662,22 @@ void npdm_print(npdm_t *npdm, hactool_ctx_t *tool_ctx) {
|
|||
|
||||
void npdm_save(npdm_t *npdm, hactool_ctx_t *tool_ctx) {
|
||||
filepath_t *json_path = &tool_ctx->settings.npdm_json_path;
|
||||
if (json_path->valid == VALIDITY_VALID) {
|
||||
FILE *f_json = os_fopen(json_path->os_path, OS_MODE_WRITE);
|
||||
if (f_json == NULL) {
|
||||
fprintf(stderr, "Failed to open %s!\n", json_path->char_path);
|
||||
return;
|
||||
}
|
||||
const char *json = npdm_get_json(npdm);
|
||||
if (fwrite(json, 1, strlen(json), f_json) != strlen(json)) {
|
||||
fprintf(stderr, "Failed to write JSON file!\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
fclose(f_json);
|
||||
if (json_path->valid != VALIDITY_VALID) {
|
||||
return;
|
||||
}
|
||||
|
||||
FILE *f_json = os_fopen(json_path->os_path, OS_MODE_WRITE);
|
||||
if (f_json == NULL) {
|
||||
fprintf(stderr, "Failed to open %s!\n", json_path->char_path);
|
||||
return;
|
||||
}
|
||||
|
||||
const char *json = npdm_get_json(npdm);
|
||||
if (fwrite(json, 1, strlen(json), f_json) != strlen(json)) {
|
||||
fprintf(stderr, "Failed to write JSON file!\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
fclose(f_json);
|
||||
}
|
||||
|
||||
void cJSON_AddU8ToObject(cJSON *obj, char *name, uint8_t val) {
|
||||
|
|
Loading…
Reference in a new issue