Fix warnings on clang (literally 95% implicit conversion to char* from const char*)#

This commit is contained in:
2026-09-02 09:07:16 +02:00
parent 3d6b08d9d5
commit fcf510afa4
9 changed files with 35 additions and 1152 deletions
+13 -13
View File
@@ -8,11 +8,11 @@
static inline bool hammy_embeds_genericerror(struct discord *client, struct discord_embed *out) { static inline bool hammy_embeds_genericerror(struct discord *client, struct discord_embed *out) {
if (!out || !client) { return false; } if (!out || !client) { return false; }
static struct discord_embed_footer footer = { .text = "Hammy Bot" }; static struct discord_embed_footer footer = { .text = (char*)"Hammy Bot" };
out[0] = (struct discord_embed){ out[0] = (struct discord_embed){
.title = "An Error Occurred", .title = (char*)"An Error Occurred",
.description = "An error occurred while processing your request.", .description = (char*)"An error occurred while processing your request.",
.color = 0xFF0000, .color = 0xFF0000,
.timestamp = discord_timestamp(client), .timestamp = discord_timestamp(client),
.footer = &footer, .footer = &footer,
@@ -26,8 +26,8 @@ static inline bool hammy_embeds_genericerror(struct discord *client, struct disc
static inline bool hammy_embeds_customerror(struct discord *client, static inline bool hammy_embeds_customerror(struct discord *client,
struct discord_embed *out, struct discord_embed *out,
struct discord_embed_fields *fieldsOut, struct discord_embed_fields *fieldsOut,
char *title, const char *title,
char *description, const char *description,
struct discord_embed_field *fields, struct discord_embed_field *fields,
int fieldCount) int fieldCount)
{ {
@@ -35,7 +35,7 @@ static inline bool hammy_embeds_customerror(struct discord *client,
if (fieldCount < 0 || (fieldCount > 0 && !fields)) { return false; } if (fieldCount < 0 || (fieldCount > 0 && !fields)) { return false; }
if (fieldCount > 0 && !fieldsOut) { return false; } if (fieldCount > 0 && !fieldsOut) { return false; }
static struct discord_embed_footer footer = { .text = "Hammy Bot" }; static struct discord_embed_footer footer = { .text = (char*)"Hammy Bot" };
if (fieldCount > 0) { if (fieldCount > 0) {
*fieldsOut = (struct discord_embed_fields){ *fieldsOut = (struct discord_embed_fields){
@@ -45,8 +45,8 @@ static inline bool hammy_embeds_customerror(struct discord *client,
} }
out[0] = (struct discord_embed){ out[0] = (struct discord_embed){
.title = title, .title = (char*)title,
.description = description, .description = (char*)description,
.color = 0xFF0000, .color = 0xFF0000,
.timestamp = discord_timestamp(client), .timestamp = discord_timestamp(client),
.footer = &footer, .footer = &footer,
@@ -61,8 +61,8 @@ static inline bool hammy_embeds_customerror(struct discord *client,
static inline bool hammy_embeds_customembed(struct discord *client, static inline bool hammy_embeds_customembed(struct discord *client,
struct discord_embed *out, struct discord_embed *out,
struct discord_embed_fields *fieldsOut, struct discord_embed_fields *fieldsOut,
char *title, const char *title,
char *description, const char *description,
struct discord_embed_field *fields, struct discord_embed_field *fields,
int fieldCount, int fieldCount,
int color) int color)
@@ -71,7 +71,7 @@ static inline bool hammy_embeds_customembed(struct discord *client,
if (fieldCount < 0 || (fieldCount > 0 && !fields)) { return false; } if (fieldCount < 0 || (fieldCount > 0 && !fields)) { return false; }
if (fieldCount > 0 && !fieldsOut) { return false; } if (fieldCount > 0 && !fieldsOut) { return false; }
static struct discord_embed_footer footer = { .text = "Hammy Bot" }; static struct discord_embed_footer footer = { .text = (char*)"Hammy Bot" };
if (fieldCount > 0) { if (fieldCount > 0) {
*fieldsOut = (struct discord_embed_fields){ *fieldsOut = (struct discord_embed_fields){
@@ -81,8 +81,8 @@ static inline bool hammy_embeds_customembed(struct discord *client,
} }
out[0] = (struct discord_embed){ out[0] = (struct discord_embed){
.title = title, .title = (char*)title,
.description = description, .description = (char*)description,
.color = color, .color = color,
.timestamp = discord_timestamp(client), .timestamp = discord_timestamp(client),
.footer = &footer, .footer = &footer,
+1 -1
View File
@@ -32,7 +32,7 @@ void hammy_cmd_abbr(const hammy_job_t* job, struct discord* client, hammy_refdb_
return; return;
} }
hammy_to_uppercase(abbr); hammy_to_uppercase((char*)abbr);
snprintf(body, sizeof(body), "Abbreviation: `%s`\nMeaning: `%s`\nUsage Context: `%s`", abbr, (str ? str : "Not Specified"), (context ? context : "Not Specified")); snprintf(body, sizeof(body), "Abbreviation: `%s`\nMeaning: `%s`\nUsage Context: `%s`", abbr, (str ? str : "Not Specified"), (context ? context : "Not Specified"));
+3
View File
@@ -30,7 +30,10 @@ static void sb_addf(hammy_sb_t* sb, const char* fmt, ...) {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wformat-nonliteral"
int n = vsnprintf(sb->buf + sb->len, sb->cap - sb->len, fmt, ap); int n = vsnprintf(sb->buf + sb->len, sb->cap - sb->len, fmt, ap);
#pragma clang diagnostic pop
va_end(ap); va_end(ap);
if (n < 0) { if (n < 0) {
+1 -1
View File
@@ -130,7 +130,7 @@ void hammy_cmd_phonetic(const hammy_job_t* job, struct discord* client, hammy_re
memcpy(pronunciation + pronunciationLen, HAMMY_PHONETIC_TRUNCATED, sizeof(HAMMY_PHONETIC_TRUNCATED)); memcpy(pronunciation + pronunciationLen, HAMMY_PHONETIC_TRUNCATED, sizeof(HAMMY_PHONETIC_TRUNCATED));
} }
hammy_to_uppercase(text); hammy_to_uppercase((char*)text);
// Reply with the phonetic words and how each of them is spoken. // Reply with the phonetic words and how each of them is spoken.
char body[sizeof(phonetic) + sizeof(pronunciation) + 48]; char body[sizeof(phonetic) + sizeof(pronunciation) + 48];
+1 -1
View File
@@ -32,7 +32,7 @@ void hammy_cmd_q(const hammy_job_t* job, struct discord* client, hammy_refdb_t*
return; return;
} }
hammy_to_uppercase(qcode); hammy_to_uppercase((char*)qcode);
snprintf(body, sizeof(body), "Q-Code: `%s`\nQuestion: `%s`\nAnswer: `%s`", qcode, (questionStr ? questionStr : "Not Specified"), (answerStr ? answerStr : "Not Specified")); snprintf(body, sizeof(body), "Q-Code: `%s`\nQuestion: `%s`\nAnswer: `%s`", qcode, (questionStr ? questionStr : "Not Specified"), (answerStr ? answerStr : "Not Specified"));
+1 -1
View File
@@ -52,7 +52,7 @@ static void hammy_bot_on_interaction(struct discord* client, const struct discor
code = discord_create_interaction_response(client, event->id, event->token, &params, NULL); code = discord_create_interaction_response(client, event->id, event->token, &params, NULL);
} else { } else {
params.data = &(struct discord_interaction_callback_data){ params.data = &(struct discord_interaction_callback_data){
.content = "I don't know that command!" .content = (char*)"I don't know that command!"
}; };
code = discord_create_interaction_response(client, event->id, event->token, &params, NULL); code = discord_create_interaction_response(client, event->id, event->token, &params, NULL);
+12 -12
View File
@@ -10,8 +10,8 @@
// TODO: Temporary - move to a proper options system; e.g. a vector of heap-allocated options or something. For now, just point at static storage. // TODO: Temporary - move to a proper options system; e.g. a vector of heap-allocated options or something. For now, just point at static storage.
static struct discord_application_command_option morse_opts[] = { static struct discord_application_command_option morse_opts[] = {
{ .type = DISCORD_APPLICATION_OPTION_STRING, .name = "text", { .type = DISCORD_APPLICATION_OPTION_STRING, .name = (char*)"text",
.description = "Text to convert to Morse code", .required = true }, .description = (char*)"Text to convert to Morse code", .required = true },
}; };
static struct discord_application_command_options morse_opts_struct = { static struct discord_application_command_options morse_opts_struct = {
@@ -20,10 +20,10 @@ static struct discord_application_command_options morse_opts_struct = {
}; };
static struct discord_application_command_option freq_opts[] = { static struct discord_application_command_option freq_opts[] = {
{ .type = DISCORD_APPLICATION_OPTION_STRING, .name = "frequency", { .type = DISCORD_APPLICATION_OPTION_STRING, .name = (char*)"frequency",
.description = "Frequency in MHz", .required = true }, .description = (char*)"Frequency in MHz", .required = true },
{ .type = DISCORD_APPLICATION_OPTION_STRING, .name = "country", { .type = DISCORD_APPLICATION_OPTION_STRING, .name = (char*)"country",
.description = "Country code to look up (e.g. US) - Defaults to US if none specified.", .required = false }, .description = (char*)"Country code to look up (e.g. US) - Defaults to US if none specified.", .required = false },
}; };
static struct discord_application_command_options freq_opts_struct = { static struct discord_application_command_options freq_opts_struct = {
@@ -32,8 +32,8 @@ static struct discord_application_command_options freq_opts_struct = {
}; };
static struct discord_application_command_option q_opts[] = { static struct discord_application_command_option q_opts[] = {
{ .type = DISCORD_APPLICATION_OPTION_STRING, .name = "q-code", { .type = DISCORD_APPLICATION_OPTION_STRING, .name = (char*)"q-code",
.description = "Q-Code to convert to Question/Answer", .required = true }, .description = (char*)"Q-Code to convert to Question/Answer", .required = true },
}; };
static struct discord_application_command_options q_opts_struct = { static struct discord_application_command_options q_opts_struct = {
@@ -42,8 +42,8 @@ static struct discord_application_command_options q_opts_struct = {
}; };
static struct discord_application_command_option abbr_opts[] = { static struct discord_application_command_option abbr_opts[] = {
{ .type = DISCORD_APPLICATION_OPTION_STRING, .name = "abbreviation", { .type = DISCORD_APPLICATION_OPTION_STRING, .name = (char*)"abbreviation",
.description = "Abbreviation to convert to Meaning", .required = true }, .description = (char*)"Abbreviation to convert to Meaning", .required = true },
}; };
static struct discord_application_command_options abbr_opts_struct = { static struct discord_application_command_options abbr_opts_struct = {
@@ -52,8 +52,8 @@ static struct discord_application_command_options abbr_opts_struct = {
}; };
static struct discord_application_command_option phonetic_opts[] = { static struct discord_application_command_option phonetic_opts[] = {
{ .type = DISCORD_APPLICATION_OPTION_STRING, .name = "text", { .type = DISCORD_APPLICATION_OPTION_STRING, .name = (char*)"text",
.description = "Text to convert to Phonetics", .required = true }, .description = (char*)"Text to convert to Phonetics", .required = true },
}; };
static struct discord_application_command_options phonetic_opts_struct = { static struct discord_application_command_options phonetic_opts_struct = {
+1 -1
View File
@@ -192,4 +192,4 @@ void hammy_pool_stats(hammy_pool_t* pool, size_t* outQueued, size_t* outBusy) {
if (outBusy) { *outBusy = pool->busy; } if (outBusy) { *outBusy = pool->busy; }
if (outQueued) { *outQueued = pool->count; } if (outQueued) { *outQueued = pool->count; }
pthread_mutex_unlock(&pool->lock); pthread_mutex_unlock(&pool->lock);
} }
+2 -1122
View File
File diff suppressed because it is too large Load Diff