reverted "removed pointless strlen from for loops"

This reverts commit 49b53ec5b1ffd1931e51c7d7c17a64a99e2bd54e.
This commit is contained in:
Václav Šmejkal 2024-02-20 14:45:35 +01:00
parent 3355d6ceea
commit 0525c43b6f
Signed by: ENGO150
GPG Key ID: 4A57E86482968843
4 changed files with 11 additions and 11 deletions

View File

@ -165,7 +165,7 @@ void *read_socket_raw_thread(void *socket)
void remove_json_syntax_characters(char *text)
{
for (int i = 0; text[i] != '\0'; i++) //TODO: DO SOMETHING MORE
for (size_t i = 0; i < strlen(text); i++) //TODO: DO SOMETHING MORE
{
if (text[i] == '\"')
{
@ -176,7 +176,7 @@ void remove_json_syntax_characters(char *text)
void lowercase(char *string)
{
for (int i = 0; string[i] != '\0'; i++)
for (unsigned long i = 0; i < strlen(string); i++)
{
string[i] = tolower(string[i]);
}
@ -201,7 +201,7 @@ why2_bool check_username(char *username)
if (username_equal(username, WHY2_CHAT_SERVER_USERNAME)) return 0; //DISABLE 'server' USERNAME
if (username_equal(username, WHY2_DEFAULT_USERNAME)) return 0; //DISABLE 'anon' USERNAME DUE TO ONE USERNAME PER SERVER
for (int i = 0; username[i] != '\0'; i++)
for (unsigned long i = 0; i < strlen(username); i++)
{
if (!((username[i] >= 48 && username[i] <= 57) ||
(username[i] >= 65 && username[i] <= 90) || //CHECK ONLY FOR a-Z & 0-9
@ -488,7 +488,7 @@ void *why2_communicate_thread(void *arg)
raw_output = why2_strdup("");
//REMOVE CONTROL CHARACTERS FROM raw
for (int i = 0; raw[i] != '\0'; i++)
for (size_t i = 0; i < strlen(raw); i++)
{
if (raw[i] == '\\') raw[i] = '/';
}

View File

@ -70,7 +70,7 @@ why2_output_flags why2_decrypt_text(char *text, char *keyNew)
char *used_text = why2_strdup(text); //COPY text TO used_text
//GET LENGTH OF returningText AND textKeyChain
for (int i = 0; used_text[i] != '\0'; i++)
for (int i = 0; i < (int) strlen(used_text); i++)
{
if (used_text[i] == why2_get_encryption_separator()) numberBuffer++;
}
@ -90,7 +90,7 @@ why2_output_flags why2_decrypt_text(char *text, char *keyNew)
numberBuffer = 0;
//GET LENGTH OF EACH CHARACTER
for (int j = 0; used_text[i] != '\0'; j++)
for (int j = 0; j < (int) strlen(used_text); j++)
{
if (used_text[j] == why2_get_encryption_separator()) break;
@ -106,7 +106,7 @@ why2_output_flags why2_decrypt_text(char *text, char *keyNew)
}
//LOAD textBuffer
for (int j = 0; used_text[i] != '\0'; j++)
for (int j = 0; j < (int) strlen(used_text); j++)
{
textBuffer[j] = used_text[j];

View File

@ -79,13 +79,13 @@ why2_output_flags why2_encrypt_text(char *text, char *keyNew)
why2_generate_text_key_chain(key, textKeyChain, strlen(text));
//ACTUALLY ENCRYPT TEXT
for (int i = 0; text[i] != '\0'; i++)
for (int i = 0; i < (int) strlen(text); i++)
{
textKeyChain[i] = why2_get_encryption_operation()(textKeyChain[i], (int) text[i]);
}
//COUNT REQUIRED SIZE FOR returningText
for (int i = 0; text[i] != '\0'; i++)
for (int i = 0; i < (int) strlen(text); i++)
{
numberBuffer += why2_count_int_length(textKeyChain[i]);
}
@ -94,7 +94,7 @@ why2_output_flags why2_encrypt_text(char *text, char *keyNew)
returningText = why2_calloc(numberBuffer + strlen(text), sizeof(char));
//LOAD returningText
for (int i = 0; text[i] != '\0'; i++)
for (int i = 0; i < (int) strlen(text); i++)
{
numberBuffer = sizeof(int) * why2_count_int_length(textKeyChain[i]);

View File

@ -119,7 +119,7 @@ void why2_write_log(int loggerFile, char *logMessage)
//COPY logMessage without '\n'
char *logMessageUsed = why2_strdup(logMessage);
for (int i = 0; logMessageUsed[i] != '\0'; i++)
for (int i = 0; i < (int) strlen(logMessageUsed); i++)
{
if (logMessageUsed[i] == '\n') logMessageUsed[i] = '\0';
}