kip, npdm: Prevent const qualifier discarding warnings from occurring

Given this is an allocated buffer that the caller needs to deal with,
the return type being const causes warnings when passing to free.
This commit is contained in:
Lioncash 2018-08-11 22:21:26 -04:00
parent 1371815e2a
commit 54abbac0b3
4 changed files with 8 additions and 8 deletions

6
kip.c
View File

@ -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. */
@ -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);

2
kip.h
View File

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

6
npdm.c
View File

@ -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);
@ -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. */

2
npdm.h
View File

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