Return value of function might be undefined

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
bernardj
Posts: 14
Joined: Fri Jul 10, 2015 7:52 pm

Return value of function might be undefined

Post by bernardj » Mon Apr 22, 2019 8:29 pm

Good day esteemed forum members

I have tried everything I can think of to get rid of the compiler warning from this function:

Code: Select all

Function waitForMatchingCharCount(matchChar As Byte, matchCount As Byte = 1) As Byte
  Dim c as byte
  Dim charCount As Byte
  
  charCount = 0
  PIE3.7    = 0                  
  PIR3.7    = 0
  TMR3CLK   = %00000100
  PIR4.2    = 0                  
  TMR3H     = 0
  TMR3L     = 0
  T3CON     = %00110011
  
  While PIR4.2 = 0 And charCount < matchCount
    If PIR3.7 = 1 Then
      c = RC2REG
      If c = matchChar Then
        charCount = charCount + 1 
      EndIf
    EndIf  
  Wend   
  
  UART.Write("/wfmChar res: ",DecToStr(charCount),#13,#10)
  PIE3.7 = 1
  T3CON  = %00000000
  result = charCount
End Function
Warning[] F:\Projects\Alarm\18F47K40 Home Alarm.bas 955 : Return value of function 'waitForMatchingCharCount' might be undefined

I also tried

Code: Select all

waitForMatchingCharCount = charCount
in stead of

Code: Select all

result = charCount
Any suggestions, please?
I may add that the code functions as intended - its just that warning ... :?: :oops:

Is this the latest compiler version?
Swordfish BASIC Compiler 2.2.2.5 (BETA B6) (ICC 1.1.6.4)

Regards

Bernard

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Re: Return value of function might be undefined

Post by David Barker » Tue Apr 23, 2019 9:18 am

can you post a full working program that shows the warning (device, includes etc)

bernardj
Posts: 14
Joined: Fri Jul 10, 2015 7:52 pm

Re: Return value of function might be undefined

Post by bernardj » Wed Apr 24, 2019 4:47 pm

Hi

Thanks for the reply.

Source code files attached as requested

Regards

Bernard

Jerry Messina
Swordfish Developer
Posts: 1469
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: Return value of function might be undefined

Post by Jerry Messina » Mon May 27, 2019 9:40 pm

Bernard,

There were no attachments to your post. Want to try again?

Post Reply