Skip to content

Commit 62db792

Browse files
clopezphiln
authored andcommitted
[WPE][GTK] Fix several warnings when building for ARMv7 (32-bits)
https://bugs.webkit.org/show_bug.cgi?id=247873 Reviewed by Michael Catanzaro. This fixes several warnings that appear when building for ARMv7 (32-bits): - deprecated-enum-enum-conversion - unused-variable - unused-result - overflow - sign-compare It also disables two warnings for old versions of GCC (old versions give false positives). * PerformanceTests/MallocBench/MallocBench/stress_aligned.cpp: (benchmark_stress_aligned): * Source/JavaScriptCore/assembler/ARMv7Assembler.h: (JSC::ARMv7Assembler::revertJumpTo_movT3movtcmpT2): (JSC::ARMv7Assembler::ARMInstructionFormatter::twoWordOp12Reg4FourFours): (JSC::ARMv7Assembler::ARMInstructionFormatter::twoWordOp12Reg4Reg4Imm12): (JSC::ARMv7Assembler::ARMInstructionFormatter::twoWordOp12Reg4Reg4Reg4Imm8): (JSC::ARMv7Assembler::ARMInstructionFormatter::twoWordOp12Reg40Imm3Reg4Imm20Imm5): * Source/WebCore/accessibility/atspi/AccessibilityObjectTextAtspi.cpp: (WebCore::AccessibilityObjectAtspi::characterIndex const): (WebCore::AccessibilityObjectAtspi::selectionChanged): * Source/WebCore/platform/graphics/filters/software/FECompositeSoftwareApplier.cpp: (WebCore::FECompositeSoftwareApplier::applyArithmetic const): * Source/WebCore/platform/graphics/gbm/DMABufReleaseFlag.h: (WebCore::DMABufReleaseFlag::release): * Source/cmake/WebKitCompilerFlags.cmake: Canonical link: https://commits.webkit.org/256792@main
1 parent 6d42734 commit 62db792

5 files changed

Lines changed: 18 additions & 9 deletions

File tree

PerformanceTests/MallocBench/MallocBench/stress_aligned.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ void benchmark_stress_aligned(CommandLine&)
148148

149149
srandom(1); // For consistency between runs.
150150

151-
size_t limit = 0x00001ffffffffffful;
151+
uint64_t limit = 0x00001ffffffffffful;
152152

153153
for (size_t size = 0; size < limit; size = std::max(size, sizeof(void*)) * 2) {
154154
for (size_t alignment = sizeof(void*); alignment < limit; alignment *= 2) {

Source/JavaScriptCore/assembler/ARMv7Assembler.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,7 @@ class ARMv7Assembler {
13721372
twoWordOp5i6Imm4Reg4EncodedImmSecond(right, lo16),
13731373
twoWordOp5i6Imm4Reg4EncodedImmFirst(OP_MOVT, hi16),
13741374
twoWordOp5i6Imm4Reg4EncodedImmSecond(right, hi16),
1375-
static_cast<uint16_t>(OP_CMP_reg_T2 | left)
1375+
static_cast<uint16_t>(static_cast<uint16_t>(OP_CMP_reg_T2) | static_cast<uint16_t>(left))
13761376
};
13771377
performJITMemcpy(address, instruction, sizeof(uint16_t) * 5);
13781378
cacheFlush(address, sizeof(uint16_t) * 5);
@@ -3037,7 +3037,7 @@ class ARMv7Assembler {
30373037

30383038
ALWAYS_INLINE void twoWordOp12Reg4FourFours(OpcodeID1 op, RegisterID reg, FourFours ff)
30393039
{
3040-
m_buffer.putShort(op | reg);
3040+
m_buffer.putShort(static_cast<uint16_t>(op) | static_cast<uint16_t>(reg));
30413041
m_buffer.putShort(ff.m_u.value);
30423042
}
30433043

@@ -3070,19 +3070,19 @@ class ARMv7Assembler {
30703070

30713071
ALWAYS_INLINE void twoWordOp12Reg4Reg4Imm12(OpcodeID1 op, RegisterID reg1, RegisterID reg2, uint16_t imm)
30723072
{
3073-
m_buffer.putShort(op | reg1);
3073+
m_buffer.putShort(static_cast<uint16_t>(op) | static_cast<uint16_t>(reg1));
30743074
m_buffer.putShort((reg2 << 12) | imm);
30753075
}
30763076

30773077
ALWAYS_INLINE void twoWordOp12Reg4Reg4Reg4Imm8(OpcodeID1 op, RegisterID reg1, RegisterID reg2, RegisterID reg3, uint8_t imm)
30783078
{
3079-
m_buffer.putShort(op | reg1);
3079+
m_buffer.putShort(static_cast<uint16_t>(op) | static_cast<uint16_t>(reg1));
30803080
m_buffer.putShort((reg2 << 12) | (reg3 << 8) | imm);
30813081
}
30823082

30833083
ALWAYS_INLINE void twoWordOp12Reg40Imm3Reg4Imm20Imm5(OpcodeID1 op, RegisterID reg1, RegisterID reg2, uint16_t imm1, uint16_t imm2, uint16_t imm3)
30843084
{
3085-
m_buffer.putShort(op | reg1);
3085+
m_buffer.putShort(static_cast<uint16_t>(op) | static_cast<uint16_t>(reg1));
30863086
m_buffer.putShort((imm1 << 12) | (reg2 << 8) | (imm2 << 6) | imm3);
30873087
}
30883088

Source/WebCore/accessibility/atspi/AccessibilityObjectTextAtspi.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ std::optional<unsigned> AccessibilityObjectAtspi::characterIndex(UChar character
523523
if (utf8Text.isNull())
524524
return std::nullopt;
525525

526-
auto length = g_utf8_strlen(utf8Text.data(), -1);
526+
auto length = static_cast<unsigned>(g_utf8_strlen(utf8Text.data(), -1));
527527
if (offset >= length)
528528
return std::nullopt;
529529

@@ -744,7 +744,7 @@ void AccessibilityObjectAtspi::selectionChanged(const VisibleSelection& selectio
744744
if (bounds.y() < 0)
745745
return;
746746

747-
auto length = g_utf8_strlen(utf8Text.data(), -1);
747+
auto length = static_cast<unsigned>(g_utf8_strlen(utf8Text.data(), -1));
748748
auto mapping = offsetMapping(utf16Text);
749749
auto caretOffset = UTF16OffsetToUTF8(mapping, bounds.y());
750750
if (caretOffset <= length)

Source/WebCore/platform/graphics/gbm/DMABufReleaseFlag.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929
#include <sys/eventfd.h>
3030
#include <wtf/Noncopyable.h>
31+
#include <wtf/SafeStrerror.h>
32+
#include <wtf/text/CString.h>
3133
#include <wtf/unix/UnixFileDescriptor.h>
3234

3335
namespace WebCore {
@@ -72,7 +74,8 @@ struct DMABufReleaseFlag {
7274
return;
7375

7476
uint64_t value { 1 };
75-
write(fd.value(), &value, sizeof(uint64_t));
77+
if (write(fd.value(), &value, sizeof(value)) != sizeof(value))
78+
WTFLogAlways("Error writing to the eventfd at DMABufReleaseFlag: %s", safeStrerror(errno).data());
7679
}
7780

7881
UnixFileDescriptor fd;

Source/cmake/WebKitCompilerFlags.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ if (COMPILER_IS_GCC_OR_CLANG)
129129
-Wno-misleading-indentation
130130
-Wno-psabi)
131131

132+
# GCC < 12.0 gives false warnings for mismatched-new-delete <https://webkit.org/b/241516>
133+
if ((CMAKE_CXX_COMPILER_ID MATCHES "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "12.0.0"))
134+
WEBKIT_PREPEND_GLOBAL_COMPILER_FLAGS(-Wno-mismatched-new-delete)
135+
WEBKIT_PREPEND_GLOBAL_COMPILER_FLAGS(-Wno-uninitialized)
136+
endif ()
137+
132138
WEBKIT_PREPEND_GLOBAL_CXX_FLAGS(-Wno-noexcept-type)
133139

134140
# These GCC warnings produce too many false positives to be useful. We'll

0 commit comments

Comments
 (0)