Skip to content

Commit 00ad945

Browse files
committed
lint: remove reinterpret_cast lint
Unhelpful.
1 parent be5e5fc commit 00ad945

File tree

15 files changed

+40
-39
lines changed

15 files changed

+40
-39
lines changed

.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Checks: >
1717
-cppcoreguidelines-avoid-goto,
1818
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
1919
-cppcoreguidelines-avoid-do-while,
20+
-cppcoreguidelines-pro-type-reinterpret-cast,
2021
google-global-names-in-headers,
2122
google-readability-casting,
2223
google-runtime-int,

src/core/logging.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -486,22 +486,22 @@ void WriteBuffer::writeBytes(const char* data, qsizetype length) {
486486
}
487487

488488
void WriteBuffer::writeU8(quint8 data) {
489-
this->writeBytes(reinterpret_cast<char*>(&data), 1); // NOLINT
489+
this->writeBytes(reinterpret_cast<char*>(&data), 1);
490490
}
491491

492492
void WriteBuffer::writeU16(quint16 data) {
493493
data = qToLittleEndian(data);
494-
this->writeBytes(reinterpret_cast<char*>(&data), 2); // NOLINT
494+
this->writeBytes(reinterpret_cast<char*>(&data), 2);
495495
}
496496

497497
void WriteBuffer::writeU32(quint32 data) {
498498
data = qToLittleEndian(data);
499-
this->writeBytes(reinterpret_cast<char*>(&data), 4); // NOLINT
499+
this->writeBytes(reinterpret_cast<char*>(&data), 4);
500500
}
501501

502502
void WriteBuffer::writeU64(quint64 data) {
503503
data = qToLittleEndian(data);
504-
this->writeBytes(reinterpret_cast<char*>(&data), 8); // NOLINT
504+
this->writeBytes(reinterpret_cast<char*>(&data), 8);
505505
}
506506

507507
void DeviceReader::setDevice(QIODevice* device) { this->device = device; }
@@ -518,19 +518,19 @@ qsizetype DeviceReader::peekBytes(char* data, qsizetype length) {
518518
bool DeviceReader::skip(qsizetype length) { return this->device->skip(length) == length; }
519519

520520
bool DeviceReader::readU8(quint8* data) {
521-
return this->readBytes(reinterpret_cast<char*>(data), 1); // NOLINT
521+
return this->readBytes(reinterpret_cast<char*>(data), 1);
522522
}
523523

524524
bool DeviceReader::readU16(quint16* data) {
525-
return this->readBytes(reinterpret_cast<char*>(data), 2); // NOLINT
525+
return this->readBytes(reinterpret_cast<char*>(data), 2);
526526
}
527527

528528
bool DeviceReader::readU32(quint32* data) {
529-
return this->readBytes(reinterpret_cast<char*>(data), 4); // NOLINT
529+
return this->readBytes(reinterpret_cast<char*>(data), 4);
530530
}
531531

532532
bool DeviceReader::readU64(quint64* data) {
533-
return this->readBytes(reinterpret_cast<char*>(data), 8); // NOLINT
533+
return this->readBytes(reinterpret_cast<char*>(data), 8);
534534
}
535535

536536
void EncodedLogWriter::setDevice(QIODevice* target) { this->buffer.setDevice(target); }
@@ -712,18 +712,18 @@ void EncodedLogWriter::writeVarInt(quint32 n) {
712712

713713
bool EncodedLogReader::readVarInt(quint32* slot) {
714714
auto bytes = std::array<quint8, 7>();
715-
auto readLength = this->reader.peekBytes(reinterpret_cast<char*>(bytes.data()), 7); // NOLINT
715+
auto readLength = this->reader.peekBytes(reinterpret_cast<char*>(bytes.data()), 7);
716716

717717
if (bytes[0] != 0xff && readLength >= 1) {
718-
auto n = *reinterpret_cast<quint8*>(bytes.data()); // NOLINT
718+
auto n = *reinterpret_cast<quint8*>(bytes.data());
719719
if (!this->reader.skip(1)) return false;
720720
*slot = qFromLittleEndian(n);
721721
} else if ((bytes[1] != 0xff || bytes[2] != 0xff) && readLength >= 3) {
722-
auto n = *reinterpret_cast<quint16*>(bytes.data() + 1); // NOLINT
722+
auto n = *reinterpret_cast<quint16*>(bytes.data() + 1);
723723
if (!this->reader.skip(3)) return false;
724724
*slot = qFromLittleEndian(n);
725725
} else if (readLength == 7) {
726-
auto n = *reinterpret_cast<quint32*>(bytes.data() + 3); // NOLINT
726+
auto n = *reinterpret_cast<quint32*>(bytes.data() + 3);
727727
if (!this->reader.skip(7)) return false;
728728
*slot = qFromLittleEndian(n);
729729
} else return false;

src/core/util.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class DropEmitter {
6565
template <class O>
6666
DropEmitter(O* object, void (*signal)(O*))
6767
: object(object)
68-
, signal(*reinterpret_cast<void (*)(void*)>(signal)) {} // NOLINT
68+
, signal(*reinterpret_cast<void (*)(void*)>(signal)) {}
6969

7070
DropEmitter() = default;
7171

src/dbus/dbusmenu/dbusmenu.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ QQmlListProperty<QsMenuEntry> DBusMenuItem::children() {
105105
}
106106

107107
qsizetype DBusMenuItem::childrenCount(QQmlListProperty<QsMenuEntry>* property) {
108-
return reinterpret_cast<DBusMenuItem*>(property->object)->enabledChildren.count(); // NOLINT
108+
return reinterpret_cast<DBusMenuItem*>(property->object)->enabledChildren.count();
109109
}
110110

111111
QsMenuEntry* DBusMenuItem::childAt(QQmlListProperty<QsMenuEntry>* property, qsizetype index) {
112-
auto* item = reinterpret_cast<DBusMenuItem*>(property->object); // NOLINT
112+
auto* item = reinterpret_cast<DBusMenuItem*>(property->object);
113113
return item->menu->items.value(item->enabledChildren.at(index));
114114
}
115115

src/dbus/properties.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ QDBusError demarshallVariant(const QVariant& variant, const QMetaType& type, voi
3737

3838
if (variant.metaType() == type) {
3939
if (type.id() == QMetaType::QVariant) {
40-
*reinterpret_cast<QVariant*>(slot) = variant; // NOLINT
40+
*reinterpret_cast<QVariant*>(slot) = variant;
4141
} else {
4242
type.destruct(slot);
4343
type.construct(slot, variant.constData());

src/io/fileview.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ void FileViewWriter::write(
281281
if (shouldCancel.loadAcquire()) return;
282282

283283
if (doAtomicWrite) {
284-
if (!reinterpret_cast<QSaveFile*>(file.get())->commit()) { // NOLINT
284+
if (!reinterpret_cast<QSaveFile*>(file.get())->commit()) {
285285
qmlWarning(view) << "Write of " << state.path << " failed: Atomic commit failed.";
286286
}
287287
}

src/services/greetd/connection.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ void GreetdConnection::onSocketReady() {
160160
qint32 length = 0;
161161

162162
this->socket.read(
163-
reinterpret_cast<char*>(&length), // NOLINT
163+
reinterpret_cast<char*>(&length),
164164
sizeof(qint32)
165165
);
166166

@@ -249,7 +249,7 @@ void GreetdConnection::sendRequest(const QJsonObject& json) {
249249
}
250250

251251
this->socket.write(
252-
reinterpret_cast<char*>(&length), // NOLINT
252+
reinterpret_cast<char*>(&length),
253253
sizeof(qint32)
254254
);
255255

src/services/notifications/dbusimage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ QImage DBusNotificationImage::createImage() const {
1515
auto format = this->hasAlpha ? QImage::Format_RGBA8888 : QImage::Format_RGB888;
1616

1717
return QImage(
18-
reinterpret_cast<const uchar*>(this->data.data()), // NOLINT
18+
reinterpret_cast<const uchar*>(this->data.data()),
1919
this->width,
2020
this->height,
2121
format

src/services/pam/conversation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void PamConversation::onMessage() {
8080
auto type = PamIpcEvent::Exit;
8181

8282
auto ok = this->pipes.readBytes(
83-
reinterpret_cast<char*>(&type), // NOLINT
83+
reinterpret_cast<char*>(&type),
8484
sizeof(PamIpcEvent)
8585
);
8686

@@ -90,7 +90,7 @@ void PamConversation::onMessage() {
9090
auto code = PamIpcExitCode::OtherError;
9191

9292
ok = this->pipes.readBytes(
93-
reinterpret_cast<char*>(&code), // NOLINT
93+
reinterpret_cast<char*>(&code),
9494
sizeof(PamIpcExitCode)
9595
);
9696

@@ -113,7 +113,7 @@ void PamConversation::onMessage() {
113113
PamIpcRequestFlags flags {};
114114

115115
ok = this->pipes.readBytes(
116-
reinterpret_cast<char*>(&flags), // NOLINT
116+
reinterpret_cast<char*>(&flags),
117117
sizeof(PamIpcRequestFlags)
118118
);
119119

src/services/pam/ipc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ std::string PamIpcPipes::readString(bool* ok) const {
4545
if (ok != nullptr) *ok = false;
4646

4747
uint32_t length = 0;
48-
if (!this->readBytes(reinterpret_cast<char*>(&length), sizeof(length))) { // NOLINT
48+
if (!this->readBytes(reinterpret_cast<char*>(&length), sizeof(length))) {
4949
return "";
5050
}
5151

@@ -61,7 +61,7 @@ std::string PamIpcPipes::readString(bool* ok) const {
6161

6262
bool PamIpcPipes::writeString(const std::string& string) const {
6363
uint32_t length = string.length();
64-
if (!this->writeBytes(reinterpret_cast<char*>(&length), sizeof(length))) { // NOLINT
64+
if (!this->writeBytes(reinterpret_cast<char*>(&length), sizeof(length))) {
6565
return false;
6666
}
6767

0 commit comments

Comments
 (0)