#52 can't compile with -Werror: control reaches end of non-void

v1.0 (example)
closed
nobody
None
5
2015-04-02
2012-09-26
aapoaapo
No

svn:r4772
dooble.pro defaults to -Werror, but:
cc1plus: warnings being treated as errors
Source/dmisc.cc: In static member function 'static QByteArray dmisc::encodedString(const QByteArray&, bool)':
Source/dmisc.cc:867: warning: control reaches end of non-void function

Discussion

  • Guess Who

    Guess Who - 2012-09-26

    What gcc version are you using? Does the error occur on the N900? The build works fine on Linux (gcc 4.6.3) and OS X (gcc 4.2.1). I looked at the source and under all cases the return is a QByteArray.

     
  • Guess Who

    Guess Who - 2012-09-26

    If you remove the outermost else, will the compilation complete successfully?

    QByteArray dmisc::encodedString(const QByteArray &byteArray,
    const bool shouldEncode)
    {
    QMutexLocker locker(&s_cipherMutex);

    if(s_cryptOK && shouldEncode)
    {
    QByteArray iv;
    gcry_error_t err = 0;

    gcry_cipher_reset(s_cipherCtx);

    if((err = setInitializationVector(iv)) != 0)
    {
    logError(QObject::tr("dmisc::encodedString(): "
    "setInitializationVector() failure (%1).").
    arg(gcry_strerror(err)));
    return byteArray;
    }
    else
    {
    size_t blockLength = gcry_cipher_get_algo_blklen(s_algorithm);

    if(blockLength == 0)
    {
    logError(QObject::tr("dmisc::encodedString(): "
    "gcry_cipher_get_algo_blklen() returned "
    "zero."));
    return byteArray;
    }

    QByteArray encodedArray(byteArray);

    /*
    ** Block ciphers require the length of the buffers
    ** to be multiples of the cipher's block size.
    */

    if(encodedArray.isEmpty())
    encodedArray = encodedArray.leftJustified(blockLength, 0);
    else
    encodedArray = encodedArray.leftJustified
    (blockLength * qCeil((qreal) encodedArray.length() / (qreal)
    blockLength), 0);

    encodedArray.append(QByteArray(blockLength, 0));

    char byte = 0xFF & (encodedArray.length() - byteArray.length());

    encodedArray.remove(encodedArray.length() - 1, 1);
    encodedArray.append(byte);

    if((err = gcry_cipher_encrypt(s_cipherCtx,
    const_cast<char *> (encodedArray.
    constData()),
    (size_t) encodedArray.length(),
    (const void *) 0,
    (size_t) 0)) == 0)
    return iv + encodedArray;
    else
    {
    logError(QObject::tr("dmisc::encodedString(): "
    "gcry_cipher_encrypt() failure (%1).").
    arg(gcry_strerror(err)));
    return byteArray;
    }
    }
    }

    return byteArray;
    }

     
  • Guess Who

    Guess Who - 2012-09-26

    Removed the outer else. Let's see if the changes help ultra-conservative compilers.

     
  • aapoaapo

    aapoaapo - 2012-09-27

    Yes, this is on N900 (ARM).
    Report is with g++-4.2.1
    I can use g++-4.6 and it works.
    but -mtune=cortex-a8 needs additional flag: -march=armv7-a
    but g++-4.6 is 20x slower than g++4.2. (2min versus 40min)

    4.2 is x86 to ARM cross compiler (used inside emulated qemu)
    4.6 is ARM to ARM compiler (used in qemu without emulation)

    -----
    Removing 'else' helps with gcc-4.2. (fixed)
    -----

    Here is next warning. Happens with gcc-4.2 and gcc-4.6, this is slightly more verbose:
    g++-4.6 -c -pipe -g -march=armv7-a -mtune=cortex-a8 -Wall -Wcast-align -Wcast-qual -Wextra -Woverloaded-virtual -Wpointer-arith -Wall -W -D_REENTRANT -DQT_GL_NO_SCISSOR_TEST -DQT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH=1024 -DDOOBLE_MINIMUM_GCRYPT_VERSION=0x010490 -DQT_WEBKIT_LIB -DQT_SQL_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/linux-g++-maemo5 -I. -I/targets/FREMANTLE_ARMEL/usr/include/QtCore -I/targets/FREMANTLE_ARMEL/usr/include/QtNetwork -I/targets/FREMANTLE_ARMEL/usr/include/QtGui -I/targets/FREMANTLE_ARMEL/usr/include/QtSql -I/targets/FREMANTLE_ARMEL/usr/include/QtWebKit -I/targets/FREMANTLE_ARMEL/usr/include -IInclude -I/targets/FREMANTLE_ARMEL/usr/include -I/usr/local/libgcrypt/include -I/usr/local/libgpg-error/include -Itemp/moc -IInclude -o temp/obj/dsettings.o Source/dsettings.cc

    In file included from /targets/FREMANTLE_ARMEL/usr/include/QtCore/QMap:1:0,
    from Source/dsettings.cc:51:
    /targets/FREMANTLE_ARMEL/usr/include/QtCore/qmap.h: In static member function 'static QMap<Key, T>::Node* QMap<Key, T>::concrete(QMapData::Node*) [with Key = QString, T = QString, QMap<Key, T>::Node = QMapNode<QString, QString>]':
    /targets/FREMANTLE_ARMEL/usr/include/QtCore/qmap.h:531:28: instantiated from 'T& QMap<Key, T>::operator[](const Key&) [with Key = QString, T = QString]'
    Source/dsettings.cc:602:44: instantiated from here
    /targets/FREMANTLE_ARMEL/usr/include/QtCore/qmap.h:180:83: warning: cast from 'char*' to 'QMap<QString, QString>::Node* {aka QMapNode<QString, QString>*}' increases required alignment of target type [-Wcast-align]
    /targets/FREMANTLE_ARMEL/usr/include/QtCore/qmap.h: In static member function 'static QMap<Key, T>::Node* QMap<Key, T>::concrete(QMapData::Node*) [with Key = int, T = QtConcurrent::ResultItem, QMap<Key, T>::Node = QMapNode<int, QtConcurrent::ResultItem>]':
    /targets/FREMANTLE_ARMEL/usr/include/QtCore/qmap.h:645:82: instantiated from 'void QMap<Key, T>::freeData(QMapData*) [with Key = int, T = QtConcurrent::ResultItem]'
    /targets/FREMANTLE_ARMEL/usr/include/QtCore/qmap.h:187:59: instantiated from 'QMap<Key, T>::~QMap() [with Key = int, T = QtConcurrent::ResultItem]'
    //usr/include/QtCore/qtconcurrentresultstore.h:137:32: instantiated from here
    /targets/FREMANTLE_ARMEL/usr/include/QtCore/qmap.h:180:83: warning: cast from 'char*' to 'QMap<int, QtConcurrent::ResultItem>::Node* {aka QMapNode<int, QtConcurrent::ResultItem>*}' increases required alignment of target type [-Wcast-align]

     
  • Guess Who

    Guess Who - 2012-09-27

    Remove the cast-align flag. These compiler sensitivies are not apparent in Linux, OS X, and Windows. What version of Qt are you using?

     
  • aapoaapo

    aapoaapo - 2012-09-27

    svn-4776
    Without cast-align it compiles with -Werror.

    ----
    Qt is: 4.7.0~git20100909-0maemo1+0m5

     
  • Guess Who

    Guess Who - 2012-09-28
    • status: open --> closed-fixed
     
  • Guess Who

    Guess Who - 2012-09-28

    Closing this ticket.

     
  • Guess Who

    Guess Who - 2015-04-02
    • status: closed-fixed --> closed
    • Group: --> v1.0 (example)
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks