npdm: Invert top-level conditional within ndpm_save()

Allows for denesting of the code.
This commit is contained in:
Lioncash 2018-08-11 21:43:43 -04:00
parent ff6c8eba11
commit ab6fe349da

7
npdm.c
View file

@ -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};