mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-04-10 15:48:06 -05:00

I did a horrible thing with a list macro which builds up a 256-bit bitmap of known SSH-2 message types at compile time, by means of evaluating a conditional expression per known message type and per bitmap word which boils down to (in pseudocode) (shift count in range ? 1 << shift count : 0) I think this is perfectly valid C. If the shift count is out of range, then the use of the << operator in the true branch of the ?: would have undefined behaviour if it were executed - but that's OK, because in that situation, the safe false branch is executed instead. But when the whole thing is a compile-time evaluated constant expression, the compiler can prove statically that the << in the true branch is an out-of-range shift, and at least some compilers will warn about it verbosely. The same compiler *could* also prove statically that that branch isn't taken, and use that to suppress the warning - but at least clang does not. The solution is the same one I used in shift_right_by_one_word and shift_left_by_one_word in mpint.c: inside the true branch, nest a second conditional expression which coerces the shift count to always be in range, by setting it to 0 if it's not. This doesn't affect the output, because the only cases in which the output of the true branch is altered by this transformation are the ones in which the true branch wasn't taken anyway. So this change should make no difference to the output of this macro construction, but it suppresses about 350 pointless warnings from clang.
This is the README for PuTTY, a free Windows and Unix Telnet and SSH client. PuTTY is built using CMake <https://cmake.org/>. To compile in the simplest way (on any of Linux, Windows or Mac), run these commands in the source directory: cmake . cmake --build . Documentation (in various formats including Windows Help and Unix `man' pages) is built from the Halibut (`.but') files in the `doc' subdirectory using `doc/Makefile'. If you aren't using one of our source snapshots, you'll need to do this yourself. Halibut can be found at <https://www.chiark.greenend.org.uk/~sgtatham/halibut/>. The PuTTY home web site is https://www.chiark.greenend.org.uk/~sgtatham/putty/ If you want to send bug reports or feature requests, please read the Feedback section of the web site before doing so. Sending one-line reports saying `it doesn't work' will waste your time as much as ours. See the file LICENCE for the licence conditions.
Description
Languages
C
89.7%
Python
8%
Perl
0.9%
CMake
0.8%
Shell
0.4%
Other
0.1%