diff --git a/server/netmisc.c b/server/netmisc.c index ec4e8d28df..199e6d719b 100644 --- a/server/netmisc.c +++ b/server/netmisc.c @@ -31,14 +31,46 @@ void net_ver(nut_ctype_t *client, size_t numarg, const char **arg) { + int pkgurlHasNutOrg = 0; NUT_UNUSED_VARIABLE(arg); + if (numarg != 0) { send_err(client, NUT_ERR_INVALID_ARGUMENT); return; } - sendback(client, "Network UPS Tools upsd %s - https://www.networkupstools.org/\n", - UPS_VERSION); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic ignored "-Wunreachable-code" +#endif +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunreachable-code" +#endif + if (PACKAGE_URL && strstr(PACKAGE_URL, "networkupstools.org")) { + pkgurlHasNutOrg = 1; + } else { + upsdebugx(1, "%s: WARNING: PACKAGE_URL of this build does not point to networkupstools.org!", __func__); + } + + /* NOTE: Some compilers deduce that macro-based decisions about + * NUT_VERSION_IS_RELEASE make one of codepaths unreachable in + * a particular build. So we pragmatically handwave this away. + */ + sendback(client, "Network UPS Tools upsd %s - %s%s%s\n", + UPS_VERSION, + PACKAGE_URL ? PACKAGE_URL : "", + (PACKAGE_URL && !pkgurlHasNutOrg) ? " or " : "", + pkgurlHasNutOrg ? "" : "https://www.networkupstools.org/" + ); +#ifdef __clang__ +#pragma clang diagnostic pop +#endif +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic pop +#endif } void net_netver(nut_ctype_t *client, size_t numarg, const char **arg)