Replace #ifdef-s with #if-s, and enable -Wundef

...for variables coming from configure.ac.

Signed-off-by: Aron Budea <aron.budea@collabora.com>
Change-Id: I39ebd21c4cb56d2a3bd38fdc35dc59b5f1fd4b49
pull/5097/head
Aron Budea 2022-08-03 04:04:49 +02:00 committed by Jan Holesovsky
parent 85eaefd741
commit d30b423c07
12 changed files with 30 additions and 26 deletions

View File

@ -267,7 +267,7 @@ namespace SigUtil
#ifdef SIGSTKFLT
CASE(STKFLT);
#endif
#if defined(SIGIO) && SIGIO != SIGPOLL
#if defined(SIGIO) && defined(SIGPOLL) && SIGIO != SIGPOLL
CASE(IO);
#endif
#ifdef SIGPWR
@ -277,7 +277,7 @@ namespace SigUtil
CASE(LOST);
#endif
CASE(WINCH);
#if defined(SIGINFO) && SIGINFO != SIGPWR
#if defined(SIGINFO) && defined(SIGPWR) && SIGINFO != SIGPWR
CASE(INFO);
#endif
#undef CASE

View File

@ -7,6 +7,8 @@
#pragma once
#include <config.h>
#include <cassert>
#include <cerrno>
#include <chrono>

View File

@ -835,7 +835,7 @@ AC_SUBST(VEREIGN_URL)
# Test for build environment
AS_IF([test "$ENABLE_GTKAPP" != true],
[CXXFLAGS="$CXXFLAGS -Wall -Wextra -Wshadow"])
[CXXFLAGS="$CXXFLAGS -Wall -Wextra -Wshadow -Wundef"])
CFLAGS="$CFLAGS -Wall -Wextra"
@ -1379,7 +1379,8 @@ else
fi
AS_IF([test "$enable_feature_lock" = "yes"],
[AC_DEFINE([ENABLE_FEATURE_LOCK],1,[Whether to compile and enable feature locking])])
[AC_DEFINE([ENABLE_FEATURE_LOCK],1,[Whether to compile and enable feature locking])],
[AC_DEFINE([ENABLE_FEATURE_LOCK],0,[Whether to compile and enable feature locking])])
LOCKED_COMMANDS=
if test "$enable_feature_lock" = "yes"; then
@ -1493,7 +1494,8 @@ AC_SUBST(UNLOCK_LINK_PER_HOST)
AM_SUBST_NOTMAKE(UNLOCK_LINK_PER_HOST)
AS_IF([test "$enable_feature_restriction" = "yes"],
[AC_DEFINE([ENABLE_FEATURE_RESTRICTION],1,[Whether to compile and enable feature restrictions])])
[AC_DEFINE([ENABLE_FEATURE_RESTRICTION],1,[Whether to compile and enable feature restrictions])],
[AC_DEFINE([ENABLE_FEATURE_RESTRICTION],0,[Whether to compile and enable feature restrictions])])
FEATURE_RESTRICTION_CONFIGURATION=
if test "$enable_feature_restriction" = "yes"; then

View File

@ -298,7 +298,7 @@ bool ChildSession::_handleInput(const char *buffer, int length)
}
else if (tokens.equals(0, "blockingcommandstatus"))
{
#if defined(ENABLE_FEATURE_LOCK) || defined(ENABLE_FEATURE_RESTRICTION)
#if ENABLE_FEATURE_LOCK || ENABLE_FEATURE_RESTRICTION
return updateBlockingCommandStatus(tokens);
#endif
}
@ -706,7 +706,7 @@ bool ChildSession::loadDocument(const StringVector& tokens)
assert(!getDocURL().empty());
assert(!getJailedFilePath().empty());
#if defined(ENABLE_DEBUG) && !MOBILEAPP
#if ENABLE_DEBUG && !MOBILEAPP
if (std::getenv("PAUSEFORDEBUGGER"))
{
std::cerr << getDocURL() << " paused waiting for a debugger to attach: " << getpid() << std::endl;
@ -2726,7 +2726,7 @@ int ChildSession::getSpeed()
return _cursorInvalidatedEvent.size();
}
#if defined(ENABLE_FEATURE_LOCK) || defined(ENABLE_FEATURE_RESTRICTION)
#if ENABLE_FEATURE_LOCK || ENABLE_FEATURE_RESTRICTION
bool ChildSession::updateBlockingCommandStatus(const StringVector& tokens)
{
std::string lockStatus, restrictedStatus;
@ -3089,7 +3089,7 @@ void ChildSession::loKitCallback(const int type, const std::string& payload)
break;
case LOK_COMMAND_BLOCKED:
{
#if defined(ENABLE_FEATURE_LOCK) || defined(ENABLE_FEATURE_RESTRICTION)
#if ENABLE_FEATURE_LOCK || ENABLE_FEATURE_RESTRICTION
LOG_INF("COMMAND_BLOCKED: " << payload);
Parser parser;
Poco::Dynamic::Var var = parser.parse(payload);

View File

@ -302,7 +302,7 @@ private:
bool exportSignAndUploadDocument(const char* buffer, int length, const StringVector& tokens);
bool renderShapeSelection(const StringVector& tokens);
bool removeTextContext(const StringVector& tokens);
#if defined(ENABLE_FEATURE_LOCK) || defined(ENABLE_FEATURE_RESTRICTION)
#if ENABLE_FEATURE_LOCK || ENABLE_FEATURE_RESTRICTION
bool updateBlockingCommandStatus(const StringVector& tokens);
std::string getBlockedCommandType(std::string command);
#endif

View File

@ -866,7 +866,7 @@ private:
{
assert(!_host.empty() && portNumber > 0 && !_port.empty() &&
"Invalid hostname and portNumber for http::Sesssion");
#ifdef ENABLE_DEBUG
#if ENABLE_DEBUG
std::string scheme;
std::string hostString;
std::string portString;

View File

@ -1185,7 +1185,7 @@ public:
fetchAliasGroups(newAppConfig, remoteJson);
#ifdef ENABLE_FEATURE_LOCK
#if ENABLE_FEATURE_LOCK
fetchLockedHostPatterns(newAppConfig, remoteJson);
fetchLockedTranslations(newAppConfig, remoteJson);
fetchUnlockImageUrl(newAppConfig, remoteJson);
@ -1198,7 +1198,7 @@ public:
HostUtil::parseWopiHost(conf);
#ifdef ENABLE_FEATURE_LOCK
#if ENABLE_FEATURE_LOCK
CommandControl::LockManager::parseLockedHost(conf);
#endif
@ -1369,7 +1369,7 @@ public:
newAppConfig.insert(std::make_pair(path + ".host", host));
newAppConfig.insert(std::make_pair(path + ".host[@allow]", booleanToString(allow)));
#ifdef ENABLE_FEATURE_LOCK
#if ENABLE_FEATURE_LOCK
std::string unlockLink;
JsonUtil::findJSONValue(group, "unlock_link", unlockLink);
newAppConfig.insert(std::make_pair(path + ".unlock_link", unlockLink));
@ -1950,7 +1950,7 @@ void COOLWSD::innerInitialize(Application& self)
{ "welcome.enable", "false" },
{ "home_mode.enable", "false" },
{ "feedback.show", "true" },
#ifdef ENABLE_FEATURE_LOCK
#if ENABLE_FEATURE_LOCK
{ "feature_lock.locked_hosts[@allow]", "false"},
{ "feature_lock.locked_hosts.fallback[@read_only]", "false"},
{ "feature_lock.locked_hosts.fallback[@disabled_commands]", "false"},
@ -1967,7 +1967,7 @@ void COOLWSD::innerInitialize(Application& self)
{ "feature_lock.impress_unlock_highlights", IMPRESS_UNLOCK_HIGHLIGHTS },
{ "feature_lock.draw_unlock_highlights", DRAW_UNLOCK_HIGHLIGHTS },
#endif
#ifdef ENABLE_FEATURE_RESTRICTION
#if ENABLE_FEATURE_RESTRICTION
{ "restricted_commands", "" },
#endif
{ "user_interface.mode", "default" },
@ -3608,7 +3608,7 @@ private:
uri.substr(pos + ProxyRemoteLen), socket,
ProxyRequestHandler::getProxyRatingServer());
}
#ifdef ENABLE_FEATURE_LOCK
#if ENABLE_FEATURE_LOCK
else
{
const Poco::URI unlockImageUri =

View File

@ -1142,7 +1142,7 @@ bool ClientSession::loadDocument(const char* /*buffer*/, int /*length*/,
{
oss << " batch=" << getBatchMode();
}
#ifdef ENABLE_FEATURE_LOCK
#if ENABLE_FEATURE_LOCK
sendLockedInfo();
#endif
return forwardToChild(oss.str(), docBroker);
@ -1155,7 +1155,7 @@ bool ClientSession::loadDocument(const char* /*buffer*/, int /*length*/,
return false;
}
#ifdef ENABLE_FEATURE_LOCK
#if ENABLE_FEATURE_LOCK
void ClientSession::sendLockedInfo()
{
Poco::JSON::Object::Ptr lockInfo = new Poco::JSON::Object();

View File

@ -233,7 +233,7 @@ public:
/// Generate an access token for this session via proxy protocol.
const std::string &getOrCreateProxyAccess();
#ifdef ENABLE_FEATURE_LOCK
#if ENABLE_FEATURE_LOCK
void sendLockedInfo();
#endif

View File

@ -845,7 +845,7 @@ bool DocumentBroker::download(const std::shared_ptr<ClientSession>& session, con
}
}
#ifdef ENABLE_FEATURE_RESTRICTION
#if ENABLE_FEATURE_RESTRICTION
Object::Ptr restrictionInfo = new Object();
restrictionInfo->set("IsRestrictedUser", CommandControl::RestrictionManager::isRestrictedUser());

View File

@ -80,7 +80,7 @@ void HostUtil::parseAliases(Poco::Util::LayeredConfiguration& conf)
}
AliasHosts.clear();
#ifdef ENABLE_FEATURE_LOCK
#if ENABLE_FEATURE_LOCK
CommandControl::LockManager::unlockLinkMap.clear();
#endif
@ -102,7 +102,7 @@ void HostUtil::parseAliases(Poco::Util::LayeredConfiguration& conf)
try
{
const Poco::URI realUri(uri);
#ifdef ENABLE_FEATURE_LOCK
#if ENABLE_FEATURE_LOCK
CommandControl::LockManager::mapUnlockLink(realUri.getHost(), path);
#endif
HostUtil::hostList.insert(realUri.getHost());
@ -137,7 +137,7 @@ void HostUtil::parseAliases(Poco::Util::LayeredConfiguration& conf)
const Poco::URI aUri(aliasUri.getScheme() + "://" + x + ':' +
std::to_string(aliasUri.getPort()));
AliasHosts.insert({ aUri.getAuthority(), realUri.getAuthority() });
#ifdef ENABLE_FEATURE_LOCK
#if ENABLE_FEATURE_LOCK
CommandControl::LockManager::mapUnlockLink(aUri.getHost(), path);
#endif
HostUtil::addWopiHost(aUri.getHost(), allow);

View File

@ -96,7 +96,7 @@ void StorageBase::initialize()
HostUtil::parseWopiHost(app.config());
}
#ifdef ENABLE_FEATURE_LOCK
#if ENABLE_FEATURE_LOCK
CommandControl::LockManager::parseLockedHost(app.config());
#endif
@ -860,7 +860,7 @@ WopiStorage::WOPIFileInfo::WOPIFileInfo(const FileInfo &fileInfo,
JsonUtil::findJSONValue(object, "BreadcrumbDocName", _breadcrumbDocName);
JsonUtil::findJSONValue(object, "FileUrl", _fileUrl);
#ifdef ENABLE_FEATURE_LOCK
#if ENABLE_FEATURE_LOCK
bool isUserLocked = false;
JsonUtil::findJSONValue(object, "IsUserLocked", isUserLocked);