Skip to content

Commit a38c640

Browse files
author
Gin
committed
fix 64-to-32 type conversion errors on mac
1 parent cb5a532 commit a38c640

File tree

12 files changed

+18
-16
lines changed

12 files changed

+18
-16
lines changed

ClientSource/Connection/SerialConnectionPOSIX.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class SerialConnection : public StreamConnection{
148148
void recv_loop(){
149149
char buffer[32];
150150
while (!m_exit.load(std::memory_order_acquire)){
151-
int actual = read(m_fd, buffer, sizeof(buffer));
151+
ssize_t actual = read(m_fd, buffer, sizeof(buffer));
152152
if (actual > 0){
153153
on_recv(buffer, actual);
154154
}

Common/Cpp/Sockets/ClientSocket_POSIX.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class ClientSocket_POSIX final : public AbstractClientSocket{
7878

7979
while (bytes > 0){
8080
size_t current = std::min<size_t>(bytes, BLOCK_SIZE);
81-
int current_sent = ::send(m_socket, ptr, (int)current, MSG_DONTWAIT);
81+
ssize_t current_sent = ::send(m_socket, ptr, (int)current, MSG_DONTWAIT);
8282
if (current_sent != -1){
8383
sent += current;
8484
if ((size_t)current_sent < current){
@@ -183,7 +183,7 @@ class ClientSocket_POSIX final : public AbstractClientSocket{
183183
char buffer[BUFFER_SIZE];
184184

185185
while (true){
186-
int bytes;
186+
ssize_t bytes;
187187
int error = 0;
188188
{
189189
std::unique_lock<std::mutex> lg(m_lock);

Common/Qt/Options/EditableTableWidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ EditableTableWidget::EditableTableWidget(QWidget& parent, EditableTableOption& v
5959
header << QString::fromStdString(name);
6060
}
6161
header << "" << "" << "";
62-
m_table->setColumnCount(header.size());
62+
m_table->setColumnCount(int(header.size()));
6363
m_table->setHorizontalHeaderLabels(header);
6464

6565
QFont font;

Common/Qt/Options/StaticTableWidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ StaticTableWidget::StaticTableWidget(QWidget& parent, StaticTableOption& value)
5454
for (const std::string& name : m_value.make_header()){
5555
header << QString::fromStdString(name);
5656
}
57-
m_table->setColumnCount(header.size());
57+
m_table->setColumnCount(int(header.size()));
5858
m_table->setRowCount((int)table.size());
5959
m_table->setHorizontalHeaderLabels(header);
6060

SerialPrograms/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2515,7 +2515,7 @@ else() # macOS and Linux
25152515
# /usr/local/Cellar/opencv/4.5.5_3/include/opencv4/opencv2/core/mat.inl.hpp:2116:9: error: '_Atomic' is a C11 extension
25162516
# when compiling OpenCV
25172517
# target_compile_options(SerialPrograms PRIVATE -Wall -Wextra -Wpedantic -Werror -Wno-c11-extensions)
2518-
target_compile_options(SerialPrograms PRIVATE -Wall -Wextra -Wpedantic -Werror)
2518+
target_compile_options(SerialPrograms PRIVATE -Wall -Wextra -Wpedantic -Werror -Wshorten-64-to-32)
25192519
else()
25202520
# Assume GCC
25212521
target_compile_options(SerialPrograms PRIVATE -Wall -Wextra -Wpedantic -Werror -fno-strict-aliasing)

SerialPrograms/Source/CommonFramework/AudioPipeline/IO/AudioFileLoader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ void AudioFileLoader::sendBufferFromWavFileOnTimer(){
186186
const int wavBytesPerFrame = wavAudioFormat.bytesPerFrame();
187187
const int wavBytesToRead = (int)(wavBytesPerFrame * m_frames_per_timeout);
188188
m_rawBuffer.resize(wavBytesToRead);
189-
const int wavBytesRead = m_wavFile->read(m_rawBuffer.data(), wavBytesToRead);
189+
const int64_t wavBytesRead = m_wavFile->read(m_rawBuffer.data(), wavBytesToRead);
190190
m_rawBuffer.resize(wavBytesRead);
191191

192192
if (wavBytesRead == 0){

SerialPrograms/Source/CommonFramework/Notifications/EventNotificationOption.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ struct EventNotificationOption::Data{
115115
, m_null_screenshot(LockMode::UNLOCK_WHILE_RUNNING, "---")
116116
, m_screenshot(ImageAttachmentMode::NO_SCREENSHOT)
117117
, m_tags(false, LockMode::UNLOCK_WHILE_RUNNING, "Notifs", "")
118-
, m_rate_limit_seconds(LockMode::UNLOCK_WHILE_RUNNING, rate_limit.count())
118+
, m_rate_limit_seconds(LockMode::UNLOCK_WHILE_RUNNING, uint32_t(rate_limit.count()))
119119
, m_last_sent(WallClock::min())
120120
, m_global_enable(true)
121121
{}
@@ -132,7 +132,7 @@ struct EventNotificationOption::Data{
132132
, m_null_screenshot(LockMode::UNLOCK_WHILE_RUNNING, "---")
133133
, m_screenshot(ImageAttachmentMode::NO_SCREENSHOT)
134134
, m_tags(false, LockMode::UNLOCK_WHILE_RUNNING, tags_to_str(tags), "")
135-
, m_rate_limit_seconds(LockMode::UNLOCK_WHILE_RUNNING, rate_limit.count())
135+
, m_rate_limit_seconds(LockMode::UNLOCK_WHILE_RUNNING, uint32_t(rate_limit.count()))
136136
, m_last_sent(WallClock::min())
137137
, m_global_enable(true)
138138
{}
@@ -150,7 +150,7 @@ struct EventNotificationOption::Data{
150150
, m_null_screenshot(LockMode::UNLOCK_WHILE_RUNNING, "---")
151151
, m_screenshot(screenshot)
152152
, m_tags(false, LockMode::UNLOCK_WHILE_RUNNING, tags_to_str(tags), "")
153-
, m_rate_limit_seconds(LockMode::UNLOCK_WHILE_RUNNING, rate_limit.count())
153+
, m_rate_limit_seconds(LockMode::UNLOCK_WHILE_RUNNING, uint32_t(rate_limit.count()))
154154
, m_last_sent(WallClock::min())
155155
, m_global_enable(true)
156156
{}

SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/CameraWidgetQt6.5.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,8 @@ VideoSnapshot CameraVideoSource::snapshot(){
245245
}
246246

247247
WallClock time1 = current_time();
248-
m_stats_conversion.report_data(m_logger, std::chrono::duration_cast<std::chrono::microseconds>(time1 - time0).count());
248+
const int64_t duration = std::chrono::duration_cast<std::chrono::microseconds>(time1 - time0).count();
249+
m_stats_conversion.report_data(m_logger, uint32_t(duration));
249250

250251
// Update the cached image.
251252
m_last_image = std::move(image);

SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/CameraWidgetQt6.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ VideoSnapshot CameraVideoSource::snapshot(){
216216
m_last_image_seqnum = frame_seqnum;
217217

218218
WallClock time1 = current_time();
219-
m_stats_conversion.report_data(m_logger, std::chrono::duration_cast<std::chrono::microseconds>(time1 - time0).count());
219+
const int64_t duration = std::chrono::duration_cast<std::chrono::microseconds>(time1 - time0).count();
220+
m_stats_conversion.report_data(m_logger, uint32_t(duration));
220221

221222
return VideoSnapshot(m_last_image, m_last_image_timestamp);
222223
}

SerialPrograms/Source/CommonFramework/Windows/DpiScaler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ int scale_dpi_height(int height){
3434

3535

3636
void scale_dpi_token(QString& str, int dpi){
37-
int length = str.length();
37+
size_t length = str.length();
3838
if (length < 3){
3939
return;
4040
}
@@ -44,7 +44,7 @@ void scale_dpi_token(QString& str, int dpi){
4444

4545
// Parse the integer in front.
4646
int64_t value = 0;
47-
for (int c = 0; c < length - 2; c++){
47+
for (size_t c = 0; c < length - 2; c++){
4848
QChar ch = str[c];
4949
if (!('0' <= ch && ch <= '9')){
5050
return;

0 commit comments

Comments
 (0)