Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lots of build warnings #1665

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
4a20cde
Create warning whitelist system
daleglass Jun 5, 2022
1fd6ae0
Only whitespace changes
daleglass Jun 5, 2022
b01929e
Replace deprecated toList() with values()
daleglass Jun 5, 2022
e3f0a6b
Fix operator precedence warning
daleglass Jun 5, 2022
bb067e1
Replace deprecated Qt code with STL
daleglass Jun 5, 2022
94dfef1
Annotate fall-through
daleglass Jun 5, 2022
37e3936
Rewrite outputBits without sprintf (deprecated)
daleglass Jun 5, 2022
725fd9a
Replace mutex with recursive mutex (deprecated)
daleglass Jun 5, 2022
c3e8350
Replace deprecated qrand
daleglass Jun 5, 2022
59ecaf8
Don't use memcpy with non-trivially-copyable type
daleglass Jun 5, 2022
5e2b232
Remove unused variable
daleglass Jun 5, 2022
8986dff
Fix type range comparison
daleglass Jun 5, 2022
96137e2
Replace deprecated screenCountChanged event
daleglass Jun 5, 2022
756e0be
Replace deprecated QFontMetrics.width()
daleglass Jun 5, 2022
f58f0fd
Replace QTime with QElapsedTimer (deprecated)
daleglass Jun 5, 2022
8709d3b
Remove unused variable
daleglass Jun 5, 2022
e0fc1c8
Ensure memory is cleared to make compiler happy
daleglass Jun 5, 2022
b2d7f81
Fix new[]/delete mismatch warning
daleglass Jun 5, 2022
492ccc4
Replace deprecated qVariantFromValue
daleglass Jun 5, 2022
db2d5cb
Fix deprecated int to flags conversion
daleglass Jun 5, 2022
f3ef7a4
Fix operator precedence warning
daleglass Jun 5, 2022
b809a13
Replace deprecated error() signal
daleglass Jun 5, 2022
e84481a
Fix StrongRef warning
daleglass Jun 5, 2022
7c0415a
Fix signed/unsigned comparison warning
daleglass Jun 5, 2022
6a9a1e1
Fix writing to buffer out of bounds warning
daleglass Jun 5, 2022
66f70e4
Replace use of deprecated sprintf
daleglass Jun 5, 2022
9ac338e
Replace usage of deprecated QWheelEvent members
daleglass Jun 5, 2022
900f162
Use const reference (warning)
daleglass Jun 5, 2022
7d8aa04
Fix writing to buffer out of bounds warning (another one)
daleglass Jun 5, 2022
b0d8414
Fix 'warning: ‘size_t strlen(const char*)’ reading 1 or more bytes fr…
daleglass Jun 5, 2022
366bd7b
Fix typo in CMakeLists.txt
daleglass Jun 5, 2022
9566960
Remove mistaken line from CMakeLists
daleglass Jun 5, 2022
9c4ab1e
Prototype for MSVC support, still need to figure out the right direct…
daleglass Jun 7, 2022
aa9c885
Fix compiler detection for warning whitelisting
daleglass Jun 8, 2022
0a7d815
Apparently Windows compiler detection needs a variable
daleglass Jun 8, 2022
0b4358c
Fix cmake syntax error
daleglass Jun 8, 2022
29b3db8
Don't call CMakeDetermineCXXCompiler on Win32, work around lack of CM…
daleglass Jun 8, 2022
eb32034
Implement Visual C warnings suppression
daleglass Jun 9, 2022
56aa7d5
Rename warning constants
daleglass Jun 14, 2022
737edcd
Update libraries/shared/src/WarningsSuppression.h
daleglass Jun 24, 2022
f26a3f0
Review fixes
daleglass Jul 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,47 @@ if( NOT WIN32 )
message($ENV{CXXFLAGS})
endif()

# WARNINGS
#
# Here we add the ability to whitelist warnings we've determined we can't fix, or are safe to
# ignore for one reason or another. The way of doing so is compiler-specific, so we deal with
# the detection of that in cmake, and just pass it down to the code from here.
#
# We can also treat warnings as errors. Without the whitelist this will almost certainly lead
# to a build failure.

if(NOT DEFINED WARNINGS_WHITELIST)
set(WARNINGS_WHITELIST true CACHE BOOL "Whitelist some warnings we can't currently fix")
endif()

if(NOT DEFINED WARNINGS_AS_ERRORS)
set(WARNINGS_AS_ERRORS false CACHE BOOL "Count warnings as errors")
endif()

if(WARNINGS_WHITELIST)
if (NOT WIN32)
set(CMAKE_PLATFORM_INFO_DIR "${CMAKE_CURRENT_BINARY_DIR}")
include(CMakeDetermineCXXCompiler)
endif()

if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
message("GCC compiler detected, suppressing some unsolvable warnings.")
add_compile_definitions(WARNINGS_WHITELIST_GCC)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message("Clang compiler detected, suppressing some unsolvable warnings.")
add_compile_definitions(WARNINGS_WHITELIST_CLANG)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC" OR (CMAKE_CXX_COMPILER_ID MATCHES "" AND WIN32))
message("Microsoft Visual Studio compiler detected, suppressing some unsolvable warnings.")
add_compile_definitions(WARNINGS_WHITELIST_MSVC)
else()
message("We don't know yet how to whitelist warnings for ${CMAKE_CXX_COMPILER_ID}")
endif()
endif()

if(WARNINGS_AS_ERRORS)
set(ENV{CXXFLAGS} "$ENV{CXXFLAGS} -Werror")
set(ENV{CFLAGS} "$ENV{CXXFLAGS} -Werror")
endif()


if (HIFI_ANDROID)
Expand Down
6 changes: 5 additions & 1 deletion interface/src/AvatarBookmarks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

#include <QtQuick/QQuickWindow>
#include <memory>
#include "WarningsSuppression.h"

void addAvatarEntities(const QVariantList& avatarEntities) {
auto nodeList = DependencyManager::get<NodeList>();
Expand Down Expand Up @@ -167,7 +168,10 @@ void AvatarBookmarks::updateAvatarEntities(const QVariantList &avatarEntities) {
if (propertiesItr != avatarEntityVariantMap.end()) {
EntityItemID id = idItr.value().toUuid();
newAvatarEntities.insert(id);
IGNORE_DEPRECATED_BEGIN
// We're not transitioning to CBOR yet, since it'd break the protocol.
myAvatar->updateAvatarEntity(id, QJsonDocument::fromVariant(propertiesItr.value()).toBinaryData());
IGNORE_DEPRECATED_END
}
}
}
Expand All @@ -186,7 +190,7 @@ void AvatarBookmarks::updateAvatarEntities(const QVariantList &avatarEntities) {
* @property {number} version - The version of the bookmark data format.
* @property {string} avatarUrl - The URL of the avatar model.
* @property {number} avatarScale - The target scale of the avatar.
* @property {Array<Object<"properties",Entities.EntityProperties>>} [avatarEntites] - The avatar entities included with the
* @property {Array<Object<"properties",Entities.EntityProperties>>} [avatarEntites] - The avatar entities included with the
* bookmark.
* @property {AttachmentData[]} [attachments] - The attachments included with the bookmark.
* <p class="important">Deprecated: Use avatar entities instead.
Expand Down
2 changes: 1 addition & 1 deletion interface/src/Bookmarks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ bool Bookmarks::sortOrder(QAction* a, QAction* b) {

void Bookmarks::sortActions(Menu* menubar, MenuWrapper* menu) {
QList<QAction*> actions = menu->actions();
qSort(actions.begin(), actions.end(), sortOrder);
std::sort(actions.begin(), actions.end(), sortOrder);
for (QAction* action : menu->actions()) {
menu->removeAction(action);
}
Expand Down
1 change: 1 addition & 0 deletions interface/src/InterfaceDynamicFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ EntityDynamicPointer interfaceDynamicFactory(EntityDynamicType type, const QUuid
return std::make_shared<ObjectActionOffset>(id, ownerEntity);
case DYNAMIC_TYPE_SPRING:
qDebug() << "The 'spring' Action is deprecated. Replacing with 'tractor' Action.";
/* fall-thru */
case DYNAMIC_TYPE_TRACTOR:
return std::make_shared<ObjectActionTractor>(id, ownerEntity);
case DYNAMIC_TYPE_HOLD:
Expand Down
6 changes: 6 additions & 0 deletions interface/src/avatar/AvatarPackager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,18 @@

#include <mutex>
#include "ui/TabletScriptingInterface.h"
#include "WarningsSuppression.h"

std::once_flag setupQMLTypesFlag;
AvatarPackager::AvatarPackager() {
std::call_once(setupQMLTypesFlag, []() {
IGNORE_DEPRECATED_BEGIN

daleglass marked this conversation as resolved.
Show resolved Hide resolved
qmlRegisterType<FST>();
qmlRegisterType<MarketplaceItemUploader>();

IGNORE_DEPRECATED_END

daleglass marked this conversation as resolved.
Show resolved Hide resolved
qRegisterMetaType<AvatarPackager*>();
qRegisterMetaType<AvatarProject*>();
qRegisterMetaType<AvatarDoctor*>();
Expand Down
61 changes: 33 additions & 28 deletions interface/src/avatar/MyAvatar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
#include "EntityEditPacketSender.h"
#include "MovingEntitiesOperator.h"
#include "SceneScriptingInterface.h"
#include "WarningsSuppression.h"

using namespace std;

Expand Down Expand Up @@ -1146,11 +1147,11 @@ void MyAvatar::updateSensorToWorldMatrix() {
_sensorToWorldMatrixCache.set(_sensorToWorldMatrix);
updateJointFromController(controller::Action::LEFT_HAND, _controllerLeftHandMatrixCache);
updateJointFromController(controller::Action::RIGHT_HAND, _controllerRightHandMatrixCache);

if (hasSensorToWorldScaleChanged) {
emit sensorToWorldScaleChanged(sensorToWorldScale);
}

}

glm::vec3 MyAvatar::getLeftHandPosition() const {
Expand Down Expand Up @@ -1601,7 +1602,7 @@ bool MyAvatar::hasAvatarEntities() const {
void MyAvatar::handleCanRezAvatarEntitiesChanged(bool canRezAvatarEntities) {
if (canRezAvatarEntities) {
// Start displaying avatar entities.
// Allow time for the avatar mixer to be updated with the user's permissions so that it doesn't discard the avatar
// Allow time for the avatar mixer to be updated with the user's permissions so that it doesn't discard the avatar
// entities sent. In theory, typical worst case would be Interface running on same PC as server and the timings of
// Interface and the avatar mixer sending DomainListRequest to the domain server being such that the avatar sends its
// DomainListRequest and gets its DomainList response DOMAIN_SERVER_CHECK_IN_MSECS after Interface does. Allow extra
Expand Down Expand Up @@ -1733,7 +1734,7 @@ void MyAvatar::handleChangedAvatarEntityData() {
}
});
}

}

// CHANGE real entities
Expand Down Expand Up @@ -2017,7 +2018,10 @@ void MyAvatar::updateAvatarEntity(const QUuid& entityID, const QByteArray& entit

bool changed = false;
_avatarEntitiesLock.withWriteLock([&] {
IGNORE_DEPRECATED_BEGIN
// We're not transitioning to CBOR yet, since it'd break the protocol.
auto data = QJsonDocument::fromBinaryData(entityData);
IGNORE_DEPRECATED_END
if (data.isEmpty() || data.isNull() || !data.isObject() || data.object().isEmpty()) {
qDebug() << "ERROR! Trying to update with invalid avatar entity data. Skipping." << data;
} else {
Expand Down Expand Up @@ -2589,7 +2593,7 @@ void MyAvatar::setSkeletonModelURL(const QUrl& skeletonModelURL) {
}
QObject::disconnect(*skeletonConnection);
});

saveAvatarUrl();
emit skeletonChanged();
}
Expand Down Expand Up @@ -2968,9 +2972,9 @@ void MyAvatar::attach(const QString& modelURL, const QString& jointName,
bool allowDuplicates, bool useSaved) {
if (QThread::currentThread() != thread()) {
BLOCKING_INVOKE_METHOD(this, "attach",
Q_ARG(const QString&, modelURL),
Q_ARG(const QString&, jointName),
Q_ARG(const glm::vec3&, translation),
Q_ARG(const QString&, modelURL),
Q_ARG(const QString&, jointName),
Q_ARG(const glm::vec3&, translation),
Q_ARG(const glm::quat&, rotation),
Q_ARG(float, scale),
Q_ARG(bool, isSoft),
Expand Down Expand Up @@ -3068,7 +3072,7 @@ void MyAvatar::setAttachmentData(const QVector<AttachmentData>& attachmentData)
emit attachmentsChanged();
}

QVector<AttachmentData> MyAvatar::getAttachmentData() const {
QVector<AttachmentData> MyAvatar::getAttachmentData() const {
QVector<AttachmentData> attachmentData;

if (!DependencyManager::get<NodeList>()->getThisNodeCanRezAvatarEntities()) {
Expand Down Expand Up @@ -3124,7 +3128,7 @@ void MyAvatar::setAttachmentsVariant(const QVariantList& variant) {
newAttachments.append(attachment);
}
}
setAttachmentData(newAttachments);
setAttachmentData(newAttachments);
}

bool MyAvatar::findAvatarEntity(const QString& modelURL, const QString& jointName, QUuid& entityID) {
Expand Down Expand Up @@ -3515,7 +3519,7 @@ void MyAvatar::updateOrientation(float deltaTime) {
// Smoothly rotate body with arrow keys
float targetSpeed = getDriveKey(YAW) * _yawSpeed;
CameraMode mode = qApp->getCamera().getMode();
bool computeLookAt = isReadyForPhysics() && !qApp->isHMDMode() &&
bool computeLookAt = isReadyForPhysics() && !qApp->isHMDMode() &&
(mode == CAMERA_MODE_FIRST_PERSON_LOOK_AT || mode == CAMERA_MODE_LOOK_AT || mode == CAMERA_MODE_SELFIE);
bool smoothCameraYaw = computeLookAt && mode != CAMERA_MODE_FIRST_PERSON_LOOK_AT;
if (smoothCameraYaw) {
Expand Down Expand Up @@ -3815,16 +3819,16 @@ void MyAvatar::updateOrientation(float deltaTime) {
if (_firstPersonSteadyHeadTimer < FIRST_PERSON_RECENTER_SECONDS) {
if (_firstPersonSteadyHeadTimer > 0.0f) {
_firstPersonSteadyHeadTimer += deltaTime;
}
}
} else {
_shouldTurnToFaceCamera = true;
_firstPersonSteadyHeadTimer = 0.0f;
}
}
} else {
_firstPersonSteadyHeadTimer = deltaTime;
}
}

} else {
head->setBaseYaw(0.0f);
head->setBasePitch(getHead()->getBasePitch() + getDriveKey(PITCH) * _pitchSpeed * deltaTime
Expand Down Expand Up @@ -3902,7 +3906,7 @@ glm::vec3 MyAvatar::scaleMotorSpeed(const glm::vec3 forward, const glm::vec3 rig
zSpeed != 0.0f && xSpeed != 0.0f && !isFlying()){
direction = (zSpeed * forward);
}

auto length = glm::length(direction);
if (length > EPSILON) {
direction /= length;
Expand All @@ -3914,8 +3918,6 @@ glm::vec3 MyAvatar::scaleMotorSpeed(const glm::vec3 forward, const glm::vec3 rig

// Calculate the world-space motor velocity for the avatar.
glm::vec3 MyAvatar::calculateScaledDirection() {
CharacterController::State state = _characterController.getState();

// compute action input
// Determine if we're head or controller relative...
glm::vec3 forward, right;
Expand Down Expand Up @@ -5453,7 +5455,7 @@ void MyAvatar::setIsInSittingState(bool isSitting) {
// In updateSitStandState, we only change state if this timer is above a threshold (STANDING_TIMEOUT, SITTING_TIMEOUT).
// This avoids changing state if the user sits and stands up quickly.
_sitStandStateTimer = 0.0f;

_isInSittingState.set(isSitting);
setResetMode(true);
setSitStandStateChange(true);
Expand Down Expand Up @@ -5541,7 +5543,7 @@ void MyAvatar::setWalkBackwardSpeed(float value) {
changed = false;
break;
}

if (changed && prevVal != value) {
emit walkBackwardSpeedChanged(value);
}
Expand Down Expand Up @@ -5736,22 +5738,25 @@ void MyAvatar::FollowHelper::deactivate() {
}

void MyAvatar::FollowHelper::deactivate(CharacterController::FollowType type) {
assert(static_cast<int>(type) >= 0 && type < CharacterController::FollowType::Count);
int int_type = static_cast<int>(type);
assert(int_type >= 0 && int_type < static_cast<int>(CharacterController::FollowType::Count));
_timeRemaining[(int)type] = 0.0f;
}

// snapFollow: true to snap immediately to the desired transform with regard to 'type',
// eg. activate(FollowType::Rotation, true) snaps the FollowHelper's rotation immediately
// to the rotation of its _followDesiredBodyTransform.
void MyAvatar::FollowHelper::activate(CharacterController::FollowType type, const bool snapFollow) {
assert(static_cast<int>(type) >= 0 && type < CharacterController::FollowType::Count);
int int_type = static_cast<int>(type);
assert(int_type >= 0 && int_type < static_cast<int>(CharacterController::FollowType::Count));

// TODO: Perhaps, the follow time should be proportional to the displacement.
_timeRemaining[(int)type] = snapFollow ? CharacterController::FOLLOW_TIME_IMMEDIATE_SNAP : FOLLOW_TIME;
}

bool MyAvatar::FollowHelper::isActive(CharacterController::FollowType type) const {
assert(static_cast<int>(type) >= 0 && type < CharacterController::FollowType::Count);
int int_type = static_cast<int>(type);
assert(int_type >= 0 && int_type < static_cast<int>(CharacterController::FollowType::Count));
return _timeRemaining[(int)type] > 0.0f;
}

Expand Down Expand Up @@ -5863,7 +5868,7 @@ bool MyAvatar::FollowHelper::shouldActivateHorizontal_userStanding(
}
}
}

if (!stepDetected) {
glm::vec3 defaultHipsPosition = myAvatar.getAbsoluteDefaultJointTranslationInObjectFrame(myAvatar.getJointIndex("Hips"));
glm::vec3 defaultHeadPosition = myAvatar.getAbsoluteDefaultJointTranslationInObjectFrame(myAvatar.getJointIndex("Head"));
Expand Down Expand Up @@ -6697,15 +6702,15 @@ void MyAvatar::useFlow(bool isActive, bool isCollidable, const QVariantMap& phys
/*@jsdoc
* Flow options currently used in flow simulation.
* @typedef {object} MyAvatar.FlowData
* @property {boolean} initialized - <code>true</code> if flow has been initialized for the current avatar, <code>false</code>
* @property {boolean} initialized - <code>true</code> if flow has been initialized for the current avatar, <code>false</code>
* if it hasn't.
* @property {boolean} active - <code>true</code> if flow is enabled, <code>false</code> if it isn't.
* @property {boolean} colliding - <code>true</code> if collisions are enabled, <code>false</code> if they aren't.
* @property {Object<GroupName, MyAvatar.FlowPhysicsData>} physicsData - The physics configuration for each group of joints
* @property {Object<GroupName, MyAvatar.FlowPhysicsData>} physicsData - The physics configuration for each group of joints
* that has been configured.
* @property {Object<JointName, MyAvatar.FlowCollisionsData>} collisions - The collisions configuration for each joint that
* @property {Object<JointName, MyAvatar.FlowCollisionsData>} collisions - The collisions configuration for each joint that
* has collisions configured.
* @property {Object<ThreadName, number[]>} threads - The threads that have been configured, with the first joint's name as the
* @property {Object<ThreadName, number[]>} threads - The threads that have been configured, with the first joint's name as the
* <code>ThreadName</code> and value as an array of the indexes of all the joints in the thread.
*/
/*@jsdoc
Expand Down Expand Up @@ -6756,7 +6761,7 @@ QVariantMap MyAvatar::getFlowData() {
}
groupJointsMap[groupName].push_back(joint.second.getIndex());
}
}
}
for (auto &group : groups) {
QVariantMap settingsObject;
QString groupName = group.first;
Expand Down
7 changes: 7 additions & 0 deletions interface/src/commerce/Wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@
#include "Ledger.h"
#include "ui/SecurityImageProvider.h"
#include "scripting/HMDScriptingInterface.h"
#include "WarningsSuppression.h"

IGNORE_DEPRECATED_BEGIN;
// We're ignoring deprecated warnings in this entire file, since it's pretty much
// entirely obsolete anyway, and probably safe to remove. But until that decision
// is taken, we'll get the OpenSSL annoyances out of the way.
namespace {
const char* KEY_FILE = "hifikey";
const char* INSTRUCTIONS_FILE = "backup_instructions.html";
Expand Down Expand Up @@ -950,3 +955,5 @@ void Wallet::getWalletStatus() {
return;
}
}

IGNORE_DEPRECATED_END
daleglass marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 5 additions & 0 deletions interface/src/scripting/AssetMappingsScriptingInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <NodeList.h>
#include <OffscreenUi.h>
#include <UserActivityLogger.h>
#include "WarningsSuppression.h"

static const int AUTO_REFRESH_INTERVAL = 1000;

Expand Down Expand Up @@ -167,7 +168,11 @@ void AssetMappingsScriptingInterface::getAllMappings(QJSValue callback) {

connect(request, &GetAllMappingsRequest::finished, this, [callback](GetAllMappingsRequest* request) mutable {
auto mappings = request->getMappings();

IGNORE_DEPRECATED_BEGIN
// Still using QScriptEngine
auto map = callback.engine()->newObject();
IGNORE_DEPRECATED_END

for (auto& kv : mappings ) {
map.setProperty(kv.first, kv.second.hash);
Expand Down
Loading