possible loss of data due to type conversion

 

My EA always compiled without any warnings, but recently decided to compile again and have been getting these warnings.


For the life of me, I cannot work out why as I'm storing the return value of the File* functions in the correct variable type and only

using those variables as int values in the rest of my code

void StoreOrderOpenPrice(string argFile, int argTicket, string argPair, int argType, double argPrice)
{
   int handle = FileOpen(argFile, FILE_READ|FILE_WRITE|FILE_CSV, ',');

   if(FileSize(handle) > 0)
      FileSeek(handle, 0, SEEK_END);

   if(handle < 0)
      Print(GetErrorDescription(GetLastError()));

   int recorded = FileWrite(handle, argTicket, argPair, argType, argPrice);

   if(recorded < 0)
      Print(GetErrorDescription(GetLastError()));

   FileClose(handle);
}
 

FileWrite returns a uint, not an int.

Also note that it returns zero in the case of an error, so your error reporting will not work correctly 

 
Double click on the warnings and the cursor will show you exactly where they are in the code.
 

Thx GumRaj all fixed,   replaced  "  < 0  "  with   " == 0" for the error checking.


cheers

Reason: