Why compilation say me "C4000 Condition always true" ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Why compilation say me "C4000 Condition always true" ?

951 Views
corso66
Contributor I

Hi,

Sometimes it's beyond my comprehension ...

Why this if, else if and else condition is always TRUE (on the first if()) as said my CW compilator :

U8 isInPeriod(U8 mm_start, U8 hh_start, U16 dly_run)
{
	S16 rtc_mm_time;
	U16 total_mm_start;
	U16 total_mm_stop = 0xFFFF;
	
	rtc_mm_time = u8RTC_minutes + (u8RTC_hours * 60);
	total_mm_start = mm_start + (hh_start * 60);
	total_mm_stop = total_mm_start + dly_run;

	if(0 <= total_mm_stop && total_mm_stop < 1440)
	{
		if(total_mm_start <= rtc_mm_time && rtc_mm_time < total_mm_stop)
		{
			return YES;
		}
		else
		{
			return NO;
		}
	}
	else if(1440 <= total_mm_stop && total_mm_stop < 2879)
	{
		rtc_mm_time = rtc_mm_time - total_mm_start;
		if(rtc_mm_time < 0)
		{
			rtc_mm_time = 1440 + rtc_mm_time;
		}
		total_mm_stop = total_mm_stop - total_mm_start;
		total_mm_start = 0;
		
		if(total_mm_start <= rtc_mm_time && rtc_mm_time < total_mm_stop)
		{
			return YES;
		}
		else
		{
			return NO;
		}
	}
	else
	{
		return NO;
	}
}

Because in plus, this function is doing the job properly ...

Thank you very much,

Sylvain

Tags (1)
0 Kudos
0 Replies