1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00
putty-source/nocmdline.c
Simon Tatham 0112936ef7 Replace assert(false) with an unreachable() macro.
Taking a leaf out of the LLVM code base: this macro still includes an
assert(false) so that the message will show up in a typical build, but
it follows it up with a call to a function explicitly marked as no-
return.

So this ought to do a better job of convincing compilers that once a
code path hits this function it _really doesn't_ have to still faff
about with making up a bogus return value or filling in a variable
that 'might be used uninitialised' in the following code that won't be
reached anyway.

I've gone through the existing code looking for the assert(false) /
assert(0) idiom and replaced all the ones I found with the new macro,
which also meant I could remove a few pointless return statements and
variable initialisations that I'd already had to put in to placate
compiler front ends.
2019-01-03 08:12:28 +00:00

43 lines
1.4 KiB
C

/*
* nocmdline.c - stubs in applications which don't do the
* standard(ish) PuTTY tools' command-line parsing
*/
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include "putty.h"
/*
* Stub version of the function in cmdline.c which provides the
* password to SSH authentication by remembering it having been passed
* as a command-line option. If we're not doing normal command-line
* handling, then there is no such option, so that function always
* returns failure.
*/
int cmdline_get_passwd_input(prompts_t *p)
{
return -1;
}
/*
* The main cmdline_process_param function is normally called from
* applications' main(). An application linking against this stub
* module shouldn't have a main() that calls it in the first place :-)
* but it is just occasionally called by other supporting functions,
* such as one in uxputty.c which sometimes handles a non-option
* argument by making up equivalent options and passing them back to
* this function. So we have to provide a link-time stub of this
* function, but it had better not end up being called at run time.
*/
int cmdline_process_param(const char *p, char *value,
int need_save, Conf *conf)
{
unreachable("cmdline_process_param should never be called");
}
/*
* This variable will be referred to, so it has to exist. It's ignored.
*/
int cmdline_tooltype = 0;