Commit d7a538a5 authored by Gus Grubba's avatar Gus Grubba

CP - Fix compiler warnings (Android)

parent d778158a
......@@ -40,6 +40,7 @@ linux {
DEFINES += QGC_ENABLE_BLUETOOTH
DEFINES += QGC_GST_TAISYNC_ENABLED
DEFINES += QGC_GST_MICROHARD_ENABLED
QMAKE_CXXFLAGS += -Wno-address-of-packed-member
target.path = $$DESTDIR
equals(ANDROID_TARGET_ARCH, x86) {
CONFIG += Androidx86Build
......
......@@ -55,14 +55,13 @@ QT_BEGIN_NAMESPACE
#define BAD_PORT 0
static const char kJniClassName[] {"org/mavlink/qgroundcontrol/QGCActivity"};
static const char kJTag[] {"QGC_QSerialPort"};
static void jniDeviceHasDisconnected(JNIEnv *envA, jobject thizA, jint userDataA)
{
Q_UNUSED(envA);
Q_UNUSED(thizA);
if (userDataA != 0)
((QSerialPortPrivate *)userDataA)->q_ptr->close();
(reinterpret_cast<QSerialPortPrivate*>(userDataA))->q_ptr->close();
}
static void jniDeviceNewData(JNIEnv *envA, jobject thizA, jint userDataA, jbyteArray dataA)
......@@ -70,9 +69,9 @@ static void jniDeviceNewData(JNIEnv *envA, jobject thizA, jint userDataA, jbyteA
Q_UNUSED(thizA);
if (userDataA != 0)
{
jbyte *bytesL = envA->GetByteArrayElements(dataA, NULL);
jbyte *bytesL = envA->GetByteArrayElements(dataA, nullptr);
jsize lenL = envA->GetArrayLength(dataA);
((QSerialPortPrivate *)userDataA)->newDataArrived((char *)bytesL, lenL);
(reinterpret_cast<QSerialPortPrivate*>(userDataA))->newDataArrived(reinterpret_cast<char*>(bytesL), lenL);
envA->ReleaseByteArrayElements(dataA, bytesL, JNI_ABORT);
}
}
......@@ -82,12 +81,12 @@ static void jniDeviceException(JNIEnv *envA, jobject thizA, jint userDataA, jstr
Q_UNUSED(thizA);
if(userDataA != 0)
{
const char *stringL = envA->GetStringUTFChars(messageA, NULL);
const char *stringL = envA->GetStringUTFChars(messageA, nullptr);
QString strL = QString::fromUtf8(stringL);
envA->ReleaseStringUTFChars(messageA, stringL);
if(envA->ExceptionCheck())
envA->ExceptionClear();
((QSerialPortPrivate *)userDataA)->exceptionArrived(strL);
(reinterpret_cast<QSerialPortPrivate*>(userDataA))->exceptionArrived(strL);
}
}
......@@ -95,7 +94,7 @@ static void jniLogDebug(JNIEnv *envA, jobject thizA, jstring messageA)
{
Q_UNUSED(thizA);
const char *stringL = envA->GetStringUTFChars(messageA, NULL);
const char *stringL = envA->GetStringUTFChars(messageA, nullptr);
QString logMessage = QString::fromUtf8(stringL);
envA->ReleaseStringUTFChars(messageA, stringL);
if (envA->ExceptionCheck())
......@@ -107,7 +106,7 @@ static void jniLogWarning(JNIEnv *envA, jobject thizA, jstring messageA)
{
Q_UNUSED(thizA);
const char *stringL = envA->GetStringUTFChars(messageA, NULL);
const char *stringL = envA->GetStringUTFChars(messageA, nullptr);
QString logMessage = QString::fromUtf8(stringL);
envA->ReleaseStringUTFChars(messageA, stringL);
if (envA->ExceptionCheck())
......@@ -190,7 +189,7 @@ bool QSerialPortPrivate::open(QIODevice::OpenMode mode)
"(Landroid/content/Context;Ljava/lang/String;I)I",
QtAndroid::androidActivity().object(),
jnameL.object<jstring>(),
(jint)this);
reinterpret_cast<jint>(this));
cleanJavaException();
isReadStopped = false;
......@@ -395,7 +394,7 @@ void QSerialPortPrivate::startWriting()
bool QSerialPortPrivate::waitForReadyRead(int msecs)
{
int origL = readBuffer.size();
int origL = static_cast<int>(readBuffer.size());
if (origL > 0)
return true;
......@@ -528,7 +527,7 @@ void QSerialPortPrivate::newDataArrived(char *bytesA, int lengthA)
// Always buffered, read data from the port into the read buffer
if (readBufferMaxSize && (bytesToReadL > (readBufferMaxSize - readBuffer.size()))) {
bytesToReadL = readBufferMaxSize - readBuffer.size();
bytesToReadL = static_cast<int>(readBufferMaxSize - readBuffer.size());
if (bytesToReadL <= 0) {
// Buffer is full. User must read data from the buffer
// before we can read more from the port.
......@@ -538,7 +537,7 @@ void QSerialPortPrivate::newDataArrived(char *bytesA, int lengthA)
}
char *ptr = readBuffer.reserve(bytesToReadL);
memcpy(ptr, bytesA, bytesToReadL);
memcpy(ptr, bytesA, static_cast<size_t>(bytesToReadL));
emit q->readyRead();
}
......@@ -617,8 +616,8 @@ qint64 QSerialPortPrivate::writeToPort(const char *data, qint64 maxSize)
}
QAndroidJniEnvironment jniEnv;
jbyteArray jarrayL = jniEnv->NewByteArray(maxSize);
jniEnv->SetByteArrayRegion(jarrayL, 0, maxSize, (jbyte *)data);
jbyteArray jarrayL = jniEnv->NewByteArray(static_cast<jsize>(maxSize));
jniEnv->SetByteArrayRegion(jarrayL, 0, static_cast<jsize>(maxSize), (jbyte*)data);
if (jniEnv->ExceptionCheck())
jniEnv->ExceptionClear();
int resultL = QAndroidJniObject::callStaticMethod<jint>(
......@@ -640,14 +639,6 @@ qint64 QSerialPortPrivate::writeToPort(const char *data, qint64 maxSize)
return resultL;
}
static inline bool evenParity(quint8 c)
{
c ^= c >> 4; //(c7 ^ c3)(c6 ^ c2)(c5 ^ c1)(c4 ^ c0)
c ^= c >> 2; //[(c7 ^ c3)(c5 ^ c1)][(c6 ^ c2)(c4 ^ c0)]
c ^= c >> 1;
return c & 1; //(c7 ^ c3)(c5 ^ c1)(c6 ^ c2)(c4 ^ c0)
}
typedef QMap<qint32, qint32> BaudRateMap;
// The OS specific defines can be found in termios.h
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment