mirror of
https://github.com/SciresM/hactool
synced 2024-11-14 00:17:14 +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
7
npdm.c
7
npdm.c
|
@ -662,12 +662,16 @@ 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) {
|
||||
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");
|
||||
|
@ -675,7 +679,6 @@ void npdm_save(npdm_t *npdm, hactool_ctx_t *tool_ctx) {
|
|||
}
|
||||
fclose(f_json);
|
||||
}
|
||||
}
|
||||
|
||||
void cJSON_AddU8ToObject(cJSON *obj, char *name, uint8_t val) {
|
||||
char buf[0x20] = {0};
|
||||
|
|
Loading…
Reference in a new issue