Skip to content

Commit

Permalink
kip, npdm: Prevent const qualifier discarding warnings from occurring
Browse files Browse the repository at this point in the history
Given this is an allocated buffer that the caller needs to deal with,
the return type being const causes warnings when passing to free.
  • Loading branch information
lioncash committed Aug 12, 2018
1 parent 1371815 commit 54abbac
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions kip.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ void ini1_save(ini1_ctx_t *ctx) {
}
}

const char *kip1_get_json(kip1_ctx_t *ctx) {
char *kip1_get_json(kip1_ctx_t *ctx) {
cJSON *kip_json = cJSON_CreateObject();
const char *output_str = NULL;
char *output_str = NULL;
char work_buffer[0x300] = {0};

/* Add KIP1 header fields. */
Expand Down Expand Up @@ -272,7 +272,7 @@ void kip1_save(kip1_ctx_t *ctx) {
fprintf(stderr, "Failed to open %s!\n", json_path->char_path);
return;
}
const char *json = kip1_get_json(ctx);
char *json = kip1_get_json(ctx);
if (json == NULL) {
fprintf(stderr, "Failed to allocate KIP1 JSON\n");
exit(EXIT_FAILURE);
Expand Down
2 changes: 1 addition & 1 deletion kip.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void ini1_process(ini1_ctx_t *ctx);
void ini1_print(ini1_ctx_t *ctx);
void ini1_save(ini1_ctx_t *ctx);

const char *kip1_get_json(kip1_ctx_t *ctx);
char *kip1_get_json(kip1_ctx_t *ctx);
void kip1_process(kip1_ctx_t *ctx);
void kip1_print(kip1_ctx_t *ctx, int suppress);
void kip1_save(kip1_ctx_t *ctx);
Expand Down
6 changes: 3 additions & 3 deletions npdm.c
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ void npdm_save(npdm_t *npdm, hactool_ctx_t *tool_ctx) {
return;
}

const char *json = npdm_get_json(npdm);
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);
Expand Down Expand Up @@ -832,11 +832,11 @@ cJSON *kac_get_json(uint32_t *descriptors, uint32_t num_descriptors) {
return kac_json;
}

const char *npdm_get_json(npdm_t *npdm) {
char *npdm_get_json(npdm_t *npdm) {
npdm_acid_t *acid = npdm_get_acid(npdm);
npdm_aci0_t *aci0 = npdm_get_aci0(npdm);
cJSON *npdm_json = cJSON_CreateObject();
const char *output_str = NULL;
char *output_str = NULL;
char work_buffer[0x300] = {0};

/* Add NPDM header fields. */
Expand Down
2 changes: 1 addition & 1 deletion npdm.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void npdm_save(npdm_t *npdm, hactool_ctx_t *tool_ctx);

char *npdm_get_proc_category(int process_category);
void kac_print(uint32_t *descriptors, uint32_t num_descriptors);
const char *npdm_get_json(npdm_t *npdm);
char *npdm_get_json(npdm_t *npdm);

void cJSON_AddU8ToObject(cJSON *obj, char *name, uint8_t val);
void cJSON_AddU16ToObject(cJSON *obj, char *name, uint16_t val);
Expand Down

0 comments on commit 54abbac

Please sign in to comment.