Zero as null pointer
-
wrote on 11 Dec 2018, 15:17 last edited by
Hello,
I use libssh in my qt project.
after i updated my Qt and QtCreator versions i have this warnings :zero as null pointer constant
file = sftp_open(sftp, pathToSftpFile.toLatin1().data(), access_type, 0); if (file == NULL) { return SSH_ERROR; }
How to fix this please ?
Do i have to fix the code or change the Compilers warning level ?Thank you
windows
MinGW 64bit
Qt 5.12 -
@LeLev said in Zero as null pointer:
sftp_open(sftp, pathToSftpFile.toLatin1().data(),
access_type, 0);what is the signature of sftp_open ? Can appropriately typecast it.
-
wrote on 11 Dec 2018, 15:24 last edited by
hi,
@dheerendra said in Zero as null pointer:what is the signature of sftp_open
LIBSSH_API sftp_file sftp_open(sftp_session session, const char *file, int accesstype,mode_t mode);
-
Lifetime Qt Championwrote on 11 Dec 2018, 15:25 last edited by mrjj 12 Nov 2018, 15:25
Hi
I think it means you should dosftp_open(sftp, pathToSftpFile.toLatin1().data(),
access_type, nullptr );instead of using the (old) zero way.
-
Hi
I think it means you should dosftp_open(sftp, pathToSftpFile.toLatin1().data(),
access_type, nullptr );instead of using the (old) zero way.
wrote on 11 Dec 2018, 15:27 last edited byhi,
@mrjj said in Zero as null pointer:I think it means you should do
sftp_open(sftp, pathToSftpFile.toLatin1().data(),
access_type, nullptr );so the test should look like this ?
if (file == nullptr)
-
hi,
@mrjj said in Zero as null pointer:I think it means you should do
sftp_open(sftp, pathToSftpFile.toLatin1().data(),
access_type, nullptr );so the test should look like this ?
if (file == nullptr)
Lifetime Qt Championwrote on 11 Dec 2018, 15:30 last edited by mrjj 12 Nov 2018, 15:31@LeLev
Yes, anywhere you normally would put a 0 (zero) put
nullptr instead.btw: C++11 is needed to have nullptr
-
Hello,
I use libssh in my qt project.
after i updated my Qt and QtCreator versions i have this warnings :zero as null pointer constant
file = sftp_open(sftp, pathToSftpFile.toLatin1().data(), access_type, 0); if (file == NULL) { return SSH_ERROR; }
How to fix this please ?
Do i have to fix the code or change the Compilers warning level ?Thank you
windows
MinGW 64bit
Qt 5.12@mrjj said in Zero as null pointer:
C++11 is needed to have nullptr
C++11 is also needed for Qt 5.12, so that requirement is guaranteed in this case :)
3/7