Fix warnings on clang (literally 95% implicit conversion to char* from const char*)#
This commit is contained in:
+13
-13
@@ -8,11 +8,11 @@
|
||||
static inline bool hammy_embeds_genericerror(struct discord *client, struct discord_embed *out) {
|
||||
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){
|
||||
.title = "An Error Occurred",
|
||||
.description = "An error occurred while processing your request.",
|
||||
.title = (char*)"An Error Occurred",
|
||||
.description = (char*)"An error occurred while processing your request.",
|
||||
.color = 0xFF0000,
|
||||
.timestamp = discord_timestamp(client),
|
||||
.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,
|
||||
struct discord_embed *out,
|
||||
struct discord_embed_fields *fieldsOut,
|
||||
char *title,
|
||||
char *description,
|
||||
const char *title,
|
||||
const char *description,
|
||||
struct discord_embed_field *fields,
|
||||
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 && !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) {
|
||||
*fieldsOut = (struct discord_embed_fields){
|
||||
@@ -45,8 +45,8 @@ static inline bool hammy_embeds_customerror(struct discord *client,
|
||||
}
|
||||
|
||||
out[0] = (struct discord_embed){
|
||||
.title = title,
|
||||
.description = description,
|
||||
.title = (char*)title,
|
||||
.description = (char*)description,
|
||||
.color = 0xFF0000,
|
||||
.timestamp = discord_timestamp(client),
|
||||
.footer = &footer,
|
||||
@@ -61,8 +61,8 @@ static inline bool hammy_embeds_customerror(struct discord *client,
|
||||
static inline bool hammy_embeds_customembed(struct discord *client,
|
||||
struct discord_embed *out,
|
||||
struct discord_embed_fields *fieldsOut,
|
||||
char *title,
|
||||
char *description,
|
||||
const char *title,
|
||||
const char *description,
|
||||
struct discord_embed_field *fields,
|
||||
int fieldCount,
|
||||
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 && !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) {
|
||||
*fieldsOut = (struct discord_embed_fields){
|
||||
@@ -81,8 +81,8 @@ static inline bool hammy_embeds_customembed(struct discord *client,
|
||||
}
|
||||
|
||||
out[0] = (struct discord_embed){
|
||||
.title = title,
|
||||
.description = description,
|
||||
.title = (char*)title,
|
||||
.description = (char*)description,
|
||||
.color = color,
|
||||
.timestamp = discord_timestamp(client),
|
||||
.footer = &footer,
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ void hammy_cmd_abbr(const hammy_job_t* job, struct discord* client, hammy_refdb_
|
||||
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"));
|
||||
|
||||
|
||||
@@ -30,7 +30,10 @@ static void sb_addf(hammy_sb_t* sb, const char* fmt, ...) {
|
||||
|
||||
va_list ap;
|
||||
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);
|
||||
#pragma clang diagnostic pop
|
||||
va_end(ap);
|
||||
|
||||
if (n < 0) {
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
hammy_to_uppercase(text);
|
||||
hammy_to_uppercase((char*)text);
|
||||
|
||||
// Reply with the phonetic words and how each of them is spoken.
|
||||
char body[sizeof(phonetic) + sizeof(pronunciation) + 48];
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ void hammy_cmd_q(const hammy_job_t* job, struct discord* client, hammy_refdb_t*
|
||||
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"));
|
||||
|
||||
|
||||
+1
-1
@@ -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, ¶ms, NULL);
|
||||
} else {
|
||||
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, ¶ms, NULL);
|
||||
|
||||
+12
-12
@@ -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.
|
||||
static struct discord_application_command_option morse_opts[] = {
|
||||
{ .type = DISCORD_APPLICATION_OPTION_STRING, .name = "text",
|
||||
.description = "Text to convert to Morse code", .required = true },
|
||||
{ .type = DISCORD_APPLICATION_OPTION_STRING, .name = (char*)"text",
|
||||
.description = (char*)"Text to convert to Morse code", .required = true },
|
||||
};
|
||||
|
||||
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[] = {
|
||||
{ .type = DISCORD_APPLICATION_OPTION_STRING, .name = "frequency",
|
||||
.description = "Frequency in MHz", .required = true },
|
||||
{ .type = DISCORD_APPLICATION_OPTION_STRING, .name = "country",
|
||||
.description = "Country code to look up (e.g. US) - Defaults to US if none specified.", .required = false },
|
||||
{ .type = DISCORD_APPLICATION_OPTION_STRING, .name = (char*)"frequency",
|
||||
.description = (char*)"Frequency in MHz", .required = true },
|
||||
{ .type = DISCORD_APPLICATION_OPTION_STRING, .name = (char*)"country",
|
||||
.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 = {
|
||||
@@ -32,8 +32,8 @@ static struct discord_application_command_options freq_opts_struct = {
|
||||
};
|
||||
|
||||
static struct discord_application_command_option q_opts[] = {
|
||||
{ .type = DISCORD_APPLICATION_OPTION_STRING, .name = "q-code",
|
||||
.description = "Q-Code to convert to Question/Answer", .required = true },
|
||||
{ .type = DISCORD_APPLICATION_OPTION_STRING, .name = (char*)"q-code",
|
||||
.description = (char*)"Q-Code to convert to Question/Answer", .required = true },
|
||||
};
|
||||
|
||||
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[] = {
|
||||
{ .type = DISCORD_APPLICATION_OPTION_STRING, .name = "abbreviation",
|
||||
.description = "Abbreviation to convert to Meaning", .required = true },
|
||||
{ .type = DISCORD_APPLICATION_OPTION_STRING, .name = (char*)"abbreviation",
|
||||
.description = (char*)"Abbreviation to convert to Meaning", .required = true },
|
||||
};
|
||||
|
||||
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[] = {
|
||||
{ .type = DISCORD_APPLICATION_OPTION_STRING, .name = "text",
|
||||
.description = "Text to convert to Phonetics", .required = true },
|
||||
{ .type = DISCORD_APPLICATION_OPTION_STRING, .name = (char*)"text",
|
||||
.description = (char*)"Text to convert to Phonetics", .required = true },
|
||||
};
|
||||
|
||||
static struct discord_application_command_options phonetic_opts_struct = {
|
||||
|
||||
Vendored
+2
-1122
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user