Comments (14)
I decided to go ahead and just {$IFDEF}
the three values in Delphi 7 and earlier. They will get taken out anyway in Indy 11.
from indy.
How does it look now?
from indy.
Remain 1 warning:
[Warning] IdStackWindows.pas(1832): Return value of function 'TIdSocketListWindows.GetItem' might be undefined
from indy.
@GreySerg2 Which version of Delphi are you using?
@rlebeau The changes to TIdIOHandler.WriteFile and TCustomSSPIConnectionContext.UpdateAndGenerateReply actually cause (correct) warnings for me on Delphi 10.4:
[dcc32 Hint] IdIOHandler.pas(2576): H2077 Value assigned to 'TIdIOHandler.WriteFile' never used
[dcc32 Hint] IdAuthenticationSSPI.pas(1058): H2077 Value assigned to 'TCustomSSPIConnectionContext.UpdateAndGenerateReply' never used
from indy.
I wrote in Header - "Delphi 7".
from indy.
Sorry, didn't see that. Delphi 7 wasn't so good with some of these hints and could give invalid ones, for example when the code uses Result but also raises exceptions.
from indy.
If code will raise exception the return value of function will be undefined. The compiler of Delphi 7 write exactly about this. It's very easy to fix, I set result value at the beginning of function.
from indy.
Since there's no return value when an exception is raised by a function Delphi 7 is wrong, this was fixed in a later Delphi version. This is why newer versions will actually give a warning is the result value is set at the beginning anyway, as the code now does. There should be an IFDEF around the assignment.
from indy.
If I call a function with try..except and then will be work with result value of function - it will be undefined.
from indy.
Yes but this is not the case in TIdSocketListWindows.GetItem which you posted about above, nor in TIdIOHandler.WriteFile nor in TCustomSSPIConnectionContext.UpdateAndGenerateReply. They don't handle the exception so the function will raise it.
from indy.
If I call a function with try..except and then will be work with result value of function - it will be undefined.
If the caller decides to swallow an exception and use an undefined return value, that is the fault of the caller, not the callee. Even if the callee were to set its Result
before raise
'ing the exception, there is no guarantee that the value will reach the caller. If the caller wants to save the return value to a variable and use it even if an exception is raised, the except
handler will have to assign a different value to the variable before letting the code move forward, eg:
try
value := DoSomethingAndGetAValue();
except
value := SomeOtherValue; // <-- here
end;
// use value as needed...
from indy.
There should be an IFDEF around the assignment.
I would really like to avoid having to do that. There are plenty of other functions throughout Indy that assign an initial Result
value and then later raise
an exception, and nobody complains about them warning about unused values.
Do we even know in which version of Delphi this issue was "fixed"?
I'm tempted to just revert my earlier change and let old compilers issue their warnings as before. Especially since support for old compilers is being dropped in Indy 11 anyway.
from indy.
I think you should revert the changes to TIdIOHandler.WriteFile and TCustomSSPIConnectionContext.UpdateAndGenerateReply then. The changes cause valid warnings under modern Delphi. Reverting them causes old Delphi to issues warnings again, but these warnings are not valid (and also not present in modern Delphi).
from indy.
Now all is Ok, all warnings are gone in Delphi 7.
from indy.
Related Issues (20)
- When SSL_get_error() returns SSL_ERROR_SYSCALL, include the error from GetLastError()
- documentation can't be downloaded HOT 5
- Assume the highest supported compiler version when a new compiler is released
- CTCP PING does not return correct value HOT 6
- Update IdCustomHTTPServer responses HOT 1
- SCRAM-SHA-1(-PLUS) + SCRAM-SHA-256(-PLUS) + SCRAM-SHA-512(-PLUS) + SCRAM-SHA3-512(-PLUS) supports
- Delphi 2007 w/ Indy 10.6.2.0 Won't Compile (File not found: IdSys.dcu) HOT 2
- EConvertError in TIdX509.notBefore and TIdX509.notAfter properties for 4-digit years
- Tidtelnet.Disconnect cannot be disconnected HOT 2
- No FHeadIndex - A Bug? HOT 4
- Wont Reset Bytes - A Bug? HOT 4
- Rad Studio 12 - Settings compatible HOT 3
- idHttp - IPv6 - IPVersion-ProtocolSwitch on Redirect (HandleRedirects=true) HOT 2
- IdSSLOpenSSL - UTC_Time_Decode - convert to char should be PAnsiChar instead of PChar on Unicode - Solved HOT 1
- Delphi Athena + Indy10 + Ubuntu 22.04.4 HOT 4
- Unable to build for C++ Builder 5 HOT 16
- how to install indy10 on the latest version of Delphi? HOT 2
- no more TCP-TLS in v10.6.3.3 HOT 2
- Cannot make a linux console application with Lazarus HOT 2
- TIdIMAP4: RFC 6154: Add a version of ListMailboxes that return also the mailbox' flags HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from indy.