Fix unsigned char / char mismatch warnings in encrypt plugin

There's no need to dynamically allocate encode_string, so just make it static.

It does need to be unsigned char though, for the loop that intialises it.  So cast it
when calling my_encrypt() / my_decrypt().
This commit is contained in:
Kevin Easton
2017-11-25 01:37:11 +11:00
parent e63033e1d5
commit 860e7e28fb

View File

@@ -17,7 +17,7 @@
#define cparse convert_output_format #define cparse convert_output_format
char encode_version[] = "Encode 0.001"; char encode_version[] = "Encode 0.001";
unsigned char *encode_string = NULL; unsigned char encode_string[256];
BUILT_IN_FUNCTION(func_encode) BUILT_IN_FUNCTION(func_encode)
{ {
@@ -25,7 +25,7 @@ char *new;
if (!input) if (!input)
return m_strdup(empty_string); return m_strdup(empty_string);
new = m_strdup(input); new = m_strdup(input);
my_encrypt(new, strlen(new), encode_string); my_encrypt(new, strlen(new), (char *)encode_string);
return new; return new;
} }
@@ -35,7 +35,7 @@ char *new;
if (!input) if (!input)
return m_strdup(empty_string); return m_strdup(empty_string);
new = m_strdup(input); new = m_strdup(input);
my_decrypt(new, strlen(new), encode_string); my_decrypt(new, strlen(new), (char *)encode_string);
return new; return new;
} }
@@ -47,14 +47,15 @@ char *Encode_Version(IrcCommandDll **intp)
int Encrypt_Init(IrcCommandDll **intp, Function_ptr *global_table) int Encrypt_Init(IrcCommandDll **intp, Function_ptr *global_table)
{ {
int i, j; int i;
char buffer[BIG_BUFFER_SIZE+1]; char buffer[BIG_BUFFER_SIZE+1];
initialize_module("encrypt"); initialize_module("encrypt");
add_module_proc(ALIAS_PROC, "encrypt", "MENCODE", NULL, 0, 0, func_encode, NULL); add_module_proc(ALIAS_PROC, "encrypt", "MENCODE", NULL, 0, 0, func_encode, NULL);
add_module_proc(ALIAS_PROC, "encrypt", "MDECODE", NULL, 0, 0, func_decode, NULL); add_module_proc(ALIAS_PROC, "encrypt", "MDECODE", NULL, 0, 0, func_decode, NULL);
encode_string = (char *)new_malloc(512);
for (i = 1, j = 255; i <= 255; i++, j--) for (i = 1; i <= 255; i++)
{ {
switch (i) switch (i)
{ {
@@ -64,7 +65,7 @@ char buffer[BIG_BUFFER_SIZE+1];
encode_string[i - 1] = i; encode_string[i - 1] = i;
break; break;
default: default:
encode_string[i-1] = j; encode_string[i - 1] = 256 - i;
break; break;
} }
} }