Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Zero as null pointer
Forum Update on Monday, May 27th 2025

Zero as null pointer

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 4 Posters 1.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ODБOïO Offline
    ODБOïO Offline
    ODБOï
    wrote on last edited by
    #1

    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

    JKSHJ 1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      @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.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      1
      • ODБOïO Offline
        ODБOïO Offline
        ODБOï
        wrote on last edited by
        #3

        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);
        
        
        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #4

          Hi
          I think it means you should do

          sftp_open(sftp, pathToSftpFile.toLatin1().data(),
          access_type, nullptr );

          instead of using the (old) zero way.

          ODБOïO 1 Reply Last reply
          4
          • mrjjM mrjj

            Hi
            I think it means you should do

            sftp_open(sftp, pathToSftpFile.toLatin1().data(),
            access_type, nullptr );

            instead of using the (old) zero way.

            ODБOïO Offline
            ODБOïO Offline
            ODБOï
            wrote on last edited by
            #5

            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)
            
            mrjjM 1 Reply Last reply
            0
            • ODБOïO ODБOï

              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)
              
              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #6

              @LeLev
              Yes, anywhere you normally would put a 0 (zero) put
              nullptr instead.

              btw: C++11 is needed to have nullptr

              1 Reply Last reply
              3
              • ODБOïO ODБOï

                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

                JKSHJ Online
                JKSHJ Online
                JKSH
                Moderators
                wrote on last edited by JKSH
                #7

                @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 :)

                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                1 Reply Last reply
                3

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved