Help me fast.
#1

* Script code:

if(strlen(inputtext))
{
new tmppass[64];
mysql_real_escape_string(inputtext, tmppass);
//************************************************** ****************
OnPlayerLogin(playerid, tmppass);
}

* Warning:

warning 225: unreachable code

* Warning line/code:

if(strlen(inputtext))
Reply
#2

Thanks.
Reply
#3

Код:
if(strlen(inputtext) > 0)
Try this. I guess you are trying to check if the inputtext has any characters whatsoever. So by adding greater than 0, it will check if inputtext has any text at all.
Reply
#4

"Unreachable". Means it can't be reached and will never be executed. Also means you need to look at the code above it, not below it.
Reply
#5

Quote:
Originally Posted by Affan
Посмотреть сообщение
Код:
if(strlen(inputtext) > 0)
Try this. I guess you are trying to check if the inputtext has any characters whatsoever. So by adding greater than 0, it will check if inputtext has any text at all.
It is the same in this case (of course yours isn't wrong, but you don't have to do it, nor is it the solution here). Because any number greater than 0 is considered true, that will make it valid - so any length but 0 will execute the code within the if statement.

This cannot technically be the cause for Warning 225. strlen() returns a value that isn't known at compile time - thus regardless which checks are done the code in brackets can potentially always be executed in a specific case - so it is in theory always reachable. Also the Compiler doesn't know that strlen can only return positive values or zero, so even if you do if(strlen(string) < 0) that warning will not be thrown.
Reply
#6

Quote:
Originally Posted by NaS
Посмотреть сообщение
It is the same in this case (of course yours isn't wrong, but you don't have to do it, nor is it the solution here). Because any number greater than 0 is considered true, that will make it valid - so any length but 0 will execute the code within the if statement.

This cannot technically be the cause for Warning 225. strlen() returns a value that isn't known at compile time - thus regardless which checks are done the code in brackets can potentially always be executed in a specific case - so it is in theory always reachable. Also the Compiler doesn't know that strlen can only return positive values or zero, so even if you do if(strlen(string) < 0) that warning will not be thrown.
Oh thanks, you learn a new thing everyday!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)