Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-10014

Problems with qt_error_string on linux

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 4.6.3
    • 4.6.0, 4.6.1, 4.6.2
    • Other
    • None
    • Linux
    • e3894396b663ff674c4af19b87b34bdf688c19b2

    Description

      qglobal.cpp

      QString qt_error_string(int errorCode)
      {
          ...
      #elif !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX)
              QByteArray buf(1024, '\0');
              strerror_r(errorCode, buf.data(), buf.size());
              ret = QString::fromLocal8Bit(buf.constData());
      #else
              ret = QString::fromLocal8Bit(strerror(errorCode));
      #endif
          ...
      }
      

      The GNU-specific strerror_r() function so does not work, and in the buffer (buf) writes nothing.

      man strerror >
      The GNU-specific strerror_r() returns a pointer to a string containing the error message. This may be either a pointer to a string that the function stores in buf, or a pointer to some (immutable) static string (in which case buf is unused).

      *****************************************************************************************

      And as a result we will not see any message if we will try to print out it as follows
      fprintf(stderr, "%s\n", qt_error_string(ENAMETOOLONG).toLocal8Bit().constData());

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            tmacieir Thiago Macieira (closed Nokia identity) (Inactive)
            yuriy_lalym Yuriy Lalym
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes