Commit 96f00a4d authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

CI: Enable clazy qstring-arg check

parent 5ecbb51f
......@@ -44,11 +44,11 @@ build_clang_tidy:
- echo 'deb-src http://deb.debian.org/debian unstable main' >> /etc/apt/sources.list
- apt-get update
- apt-get build-dep --yes --no-install-recommends okular
- apt-get install --yes --no-install-recommends ninja-build clang clang-tidy python python-yaml libkf5crash-dev libkf5purpose-dev libegl-dev jq
- apt-get install --yes --no-install-recommends ninja-build clazy clang clang-tidy python python-yaml libkf5crash-dev libkf5purpose-dev libegl-dev jq
script:
- srcdir=`pwd` && mkdir -p /tmp/okular_build && cd /tmp/okular_build && CC=clang CXX=clang++ cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -G Ninja $srcdir && cat compile_commands.json | jq '[.[] | select(.file | contains("'"$srcdir"'"))]' > compile_commands.aux.json && cat compile_commands.aux.json | jq '[.[] | select(.file | contains("/synctex/")| not)]' > compile_commands.json
- ninja
- srcdir=`pwd` && mkdir -p /tmp/okular_build && cd /tmp/okular_build && CC=clang CXX=clazy CXXFLAGS="-Werror -Wno-deprecated-declarations" cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -G Ninja $srcdir && cat compile_commands.json | jq '[.[] | select(.file | contains("'"$srcdir"'"))]' > compile_commands.aux.json && cat compile_commands.aux.json | jq '[.[] | select(.file | contains("/synctex/")| not)]' > compile_commands.json
- CLAZY_CHECKS="qstring-arg" ninja
# Fix the poppler header, remove when debian:unstable ships poppler 0.82 or later
- sed -i "N;N;N;N; s#class MediaRendition\;\nclass MovieAnnotation\;\nclass ScreenAnnotation;#class MediaRendition\;#g" /usr/include/poppler/qt5/poppler-link.h
- "run-clang-tidy -header-filter='.*/okular/.*' -checks='-*,performance-*,bugprone-*,readability-inconsistent-declaration-parameter-name,readability-string-compare,modernize-redundant-void-arg,modernize-use-bool-literals,modernize-make-unique,modernize-make-shared,modernize-use-override,modernize-use-equals-delete,modernize-use-emplace,modernize-loop-convert,modernize-use-nullptr,-bugprone-macro-parentheses,-bugprone-narrowing-conversions,-bugprone-branch-clone,-bugprone-incorrect-roundings' -config=\"{WarningsAsErrors: '*'}\""
......@@ -91,10 +91,10 @@ private slots:
void testAlert();
void testPrintD();
void testPrintD_data();
#endif
private:
Okular::Document *m_document;
QMap<QString, Okular::FormField*> m_fields;
#endif
};
#ifdef HAVE_POPPLER_0_79
......
......@@ -19,7 +19,7 @@
static const QColor RED = QColor(255, 0, 0);
static const QColor GREEN = QColor(0, 255, 0.0);
static const QColor BLUE = QColor(0, 0, 255);
// static const QColor BLUE = QColor(0, 0, 255);
class ModifyAnnotationPropertiesTest : public QObject
{
......
......@@ -887,8 +887,8 @@ void PartTest::testSaveAs()
QString annotName;
QTemporaryFile archiveSave( QStringLiteral( "%1/okrXXXXXX.okular" ).arg( QDir::tempPath() ) );
QTemporaryFile nativeDirectSave( QStringLiteral( "%1/okrXXXXXX.%2" ).arg( QDir::tempPath() ).arg ( extension ) );
QTemporaryFile nativeFromArchiveFile( QStringLiteral( "%1/okrXXXXXX.%2" ).arg( QDir::tempPath() ).arg ( extension ) );
QTemporaryFile nativeDirectSave( QStringLiteral( "%1/okrXXXXXX.%2" ).arg( QDir::tempPath(), extension ) );
QTemporaryFile nativeFromArchiveFile( QStringLiteral( "%1/okrXXXXXX.%2" ).arg( QDir::tempPath(), extension ) );
QVERIFY( archiveSave.open() );
archiveSave.close();
QVERIFY( nativeDirectSave.open() );
......@@ -1071,10 +1071,10 @@ void PartTest::testSaveAsUndoStackAnnotations()
// when saving to a file format not supporting those. However, this button is only sensible
// and available for "Save As", but not for "Save". By alternately saving to saveFile1 and
// saveFile2 we always force "Save As", so closeDialogHelper keeps working.
QTemporaryFile saveFile1( QStringLiteral( "%1/okrXXXXXX_1.%2" ).arg( QDir::tempPath() ).arg ( extension ) );
QTemporaryFile saveFile1( QStringLiteral( "%1/okrXXXXXX_1.%2" ).arg( QDir::tempPath(), extension ) );
QVERIFY( saveFile1.open() );
saveFile1.close();
QTemporaryFile saveFile2( QStringLiteral( "%1/okrXXXXXX_2.%2" ).arg( QDir::tempPath() ).arg ( extension ) );
QTemporaryFile saveFile2( QStringLiteral( "%1/okrXXXXXX_2.%2" ).arg( QDir::tempPath(), extension ) );
QVERIFY( saveFile2.open() );
saveFile2.close();
......
......@@ -86,6 +86,9 @@ static KJSObject eventGetTarget( KJSContext *ctx, void *object )
return JSField::wrapField( ctx, target, event->targetPage() );
break;
}
default:
{
}
}
return KJSUndefined();
}
......
......@@ -104,9 +104,8 @@ static KJSObject printd( KJSContext *context, void *,
}
QLocale locale( "en_US" );
QStringList str = arguments.at( 1 ).toString( context ).split( QRegularExpression( "\\W") );
QString myStr = QStringLiteral( "%1/%2/%3 %4:%5:%6" ).arg( str[1] ).
arg( str[2] ).arg( str[3] ).arg( str[4] ).arg( str[5] ).arg( str[6] );
const QStringList str = arguments.at( 1 ).toString( context ).split( QRegularExpression( "\\W") );
QString myStr = QStringLiteral( "%1/%2/%3 %4:%5:%6" ).arg( str[1], str[2], str[3], str[4], str[5], str[6] );
QDateTime date = locale.toDateTime( myStr, QStringLiteral( "MMM/d/yyyy H:m:s" ) );
......
......@@ -612,8 +612,8 @@ bool EBook_CHM::getInfoFromWindows()
if ( !RetrieveObject(&ui, buffer, 0, WIN_HEADER_LEN) )
return false;
unsigned int entries = get_int32_le( (unsigned int *)(buffer) );
unsigned int entry_size = get_int32_le( (unsigned int *)(buffer + 0x04) );
unsigned int entries = get_int32_le( reinterpret_cast<unsigned int *>(buffer) );
unsigned int entry_size = get_int32_le( reinterpret_cast<unsigned int *>(buffer + 0x04) );
QVector<unsigned char> uptr(entries * entry_size);
unsigned char* raw = (unsigned char*) uptr.data();
......@@ -628,10 +628,10 @@ bool EBook_CHM::getInfoFromWindows()
{
unsigned int offset = i * entry_size;
unsigned int off_title = get_int32_le( (unsigned int *)(raw + offset + 0x14) );
unsigned int off_home = get_int32_le( (unsigned int *)(raw + offset + 0x68) );
unsigned int off_hhc = get_int32_le( (unsigned int *)(raw + offset + 0x60) );
unsigned int off_hhk = get_int32_le( (unsigned int *)(raw + offset + 0x64) );
unsigned int off_title = get_int32_le( reinterpret_cast<unsigned int *>(raw + offset + 0x14) );
unsigned int off_home = get_int32_le( reinterpret_cast<unsigned int *>(raw + offset + 0x68) );
unsigned int off_hhc = get_int32_le( reinterpret_cast<unsigned int *>(raw + offset + 0x60) );
unsigned int off_hhk = get_int32_le( reinterpret_cast<unsigned int *>(raw + offset + 0x64) );
factor = off_title / 4096;
......@@ -901,9 +901,9 @@ void EBook_CHM::fillTopicsUrlMap()
for ( LONGUINT64 i = 0; i < m_chmTOPICS.length; i += TOPICS_ENTRY_LEN )
{
unsigned int off_title = get_int32_le( (unsigned int *)(topics.data() + i + 4) );
unsigned int off_url = get_int32_le( (unsigned int *)(topics.data() + i + 8) );
off_url = get_int32_le( (unsigned int *)( urltbl.data() + off_url + 8) ) + 8;
unsigned int off_title = get_int32_le( reinterpret_cast<unsigned int *>(topics.data() + i + 4) );
unsigned int off_url = get_int32_le( reinterpret_cast<unsigned int *>(topics.data() + i + 8) );
off_url = get_int32_le( reinterpret_cast<unsigned int *>( urltbl.data() + off_url + 8) ) + 8;
QUrl url = pathToUrl( (const char*) urlstr.data() + off_url );
......
......@@ -253,7 +253,7 @@ glyph* TeXFont_PFB::getGlyph(quint16 ch, bool generateCharacterPixmap, const QCo
for(unsigned int y=0; y<slot->bitmap.rows; y++) {
quint8 *srcScanLine = slot->bitmap.buffer + y*slot->bitmap.pitch;
unsigned int *destScanLine = (unsigned int *)imgi.scanLine(y);
unsigned int *destScanLine = reinterpret_cast<unsigned int *>(imgi.scanLine(y));
for(unsigned int col=0; col<slot->bitmap.width; col++) {
quint16 data = *srcScanLine;
// The value stored in "data" now has the following meaning:
......
......@@ -295,7 +295,7 @@ glyph* TeXFont_PK::getGlyph(quint16 ch, bool generateCharacterPixmap, const QCol
quint8 *srcScanLine = xydata;
for(int y=0; y<shrunk_height; y++) {
unsigned int *destScanLine = (unsigned int *)im32.scanLine(y);
unsigned int *destScanLine = reinterpret_cast<unsigned int *>(im32.scanLine(y));
for(int col=0; col<shrunk_width; col++) {
quint16 data = *srcScanLine;
// The value stored in "data" now has the following meaning:
......@@ -317,8 +317,8 @@ glyph* TeXFont_PK::getGlyph(quint16 ch, bool generateCharacterPixmap, const QCol
#define ADD(a, b) ((quint32 *) (((char *) a) + b))
#define SUB(a, b) ((quint32 *) (((char *) a) - b))
#define ADD(a, b) (reinterpret_cast<quint32 *>(((char *) a) + b))
#define SUB(a, b) (reinterpret_cast<quint32 *>(((char *) a) - b))
......@@ -534,7 +534,7 @@ void TeXFont_PK::read_PK_char(unsigned int ch)
characterBitmaps[ch]->bits = new char[size != 0 ? size : 1];
}
cp = (quint32 *) characterBitmaps[ch]->bits;
cp = reinterpret_cast<quint32 *>(characterBitmaps[ch]->bits);
/*
* read character data into *cp
......@@ -618,7 +618,7 @@ void TeXFont_PK::read_PK_char(unsigned int ch)
}
paint_switch = 1 - paint_switch;
}
if (cp != ((quint32 *) (characterBitmaps[ch]->bits + bytes_wide * characterBitmaps[ch]->h)))
if (cp != (reinterpret_cast<quint32 *> (characterBitmaps[ch]->bits + bytes_wide * characterBitmaps[ch]->h)))
oops(i18n("Wrong number of bits stored: char. %1, font %2", ch, parent->filename));
if (rows_left != 0 || h_bit != characterBitmaps[ch]->w)
oops(i18n("Bad pk file (%1), too many bits", parent->filename));
......@@ -704,7 +704,7 @@ void TeXFont_PK::read_PK_char(unsigned int ch)
}
paint_switch = 1 - paint_switch;
}
if (cp != ((quint32 *) (characterBitmaps[ch]->bits + bytes_wide * characterBitmaps[ch]->h)))
if (cp != (reinterpret_cast<quint32 *> (characterBitmaps[ch]->bits + bytes_wide * characterBitmaps[ch]->h)))
oops(i18n("Wrong number of bits stored: char. %1, font %2", ch, parent->filename));
if (rows_left != 0 || h_bit != characterBitmaps[ch]->w)
oops(i18n("Bad pk file (%1), too many bits", parent->filename));
......
......@@ -61,7 +61,7 @@ fontPool::fontPool(bool useFontHinting)
// extension, alpha channels are either supported, or silently
// ignored.
QImage start(1, 1, QImage::Format_ARGB32); // Generate a 1x1 image, black with alpha=0x10
quint32 *destScanLine = (quint32 *)start.scanLine(0);
quint32 *destScanLine = reinterpret_cast<quint32 *>(start.scanLine(0));
*destScanLine = 0x80000000;
QPixmap intermediate = QPixmap::fromImage(start);
QPixmap dest(1,1);
......
......@@ -22,7 +22,7 @@ static const char FAXMAGIC[] = "\000PC Research, Inc\000\000\000\000\000\000";
/* rearrange input bits into t16bits lsb-first chunks */
static void normalize( pagenode *pn, int revbits, int swapbytes, size_t length )
{
t32bits *p = (t32bits *) pn->data;
t32bits *p = reinterpret_cast<t32bits *>( pn->data );
switch ( (revbits<<1) | swapbytes )
{
......@@ -101,8 +101,8 @@ static unsigned char* getstrip( pagenode *pn, int strip )
data = new uchar[ roundup ];
/* clear the last 2 t32bits, to force the expander to terminate
even if the file ends in the middle of a fax line */
*((t32bits *) data + roundup/4 - 2) = 0;
*((t32bits *) data + roundup/4 - 1) = 0;
*(reinterpret_cast<t32bits*>( data + roundup/4 - 2)) = 0;
*(reinterpret_cast<t32bits*>( data + roundup/4 - 1)) = 0;
/* we expect to get it in one gulp... */
if ( !file.seek(offset) || (size_t) file.read( (char *)data, pn->length ) != pn->length )
......@@ -112,7 +112,7 @@ static unsigned char* getstrip( pagenode *pn, int strip )
}
file.close();
pn->data = (t16bits *)data;
pn->data = reinterpret_cast<t16bits *>(data);
if ( pn->strips == nullptr && memcmp( data, FAXMAGIC, sizeof( FAXMAGIC ) - 1 ) == 0 )
{
......@@ -137,7 +137,7 @@ static unsigned char* getstrip( pagenode *pn, int strip )
if ( pn->strips == nullptr )
pn->rowsperstrip = pn->size.height();
pn->dataOrig = (t16bits *)data;
pn->dataOrig = reinterpret_cast<t16bits *>(data);
return data;
}
......@@ -156,8 +156,8 @@ static void draw_line( pixnum *run, int lineNum, pagenode *pn )
if ( lineNum >= pn->size.height() )
return;
p = (t32bits *)(pn->imageData + lineNum*(2-pn->vres)*pn->bytes_per_line);
p1 =(t32bits *)(pn->vres ? nullptr : p + pn->bytes_per_line/sizeof(*p));
p = reinterpret_cast<t32bits*>(pn->imageData + lineNum*(2-pn->vres)*pn->bytes_per_line);
p1 =reinterpret_cast<t32bits*>(pn->vres ? nullptr : p + pn->bytes_per_line/sizeof(*p));
r = run;
acc = 0;
......@@ -277,8 +277,8 @@ bool FaxDocument::load()
for ( int y= height - 1; y >= 0; --y )
{
quint32 offset = y * bytes_per_line;
quint32 *source = (quint32 *) (d->mPageNode.imageData + offset);
quint32 *dest = (quint32 *) (bytes.data() + offset);
quint32 *source = reinterpret_cast<quint32 *> (d->mPageNode.imageData + offset);
quint32 *dest = reinterpret_cast<quint32 *> (bytes.data() + offset);
for ( int x= (bytes_per_line/4) - 1; x >= 0; --x )
{
quint32 dv = 0, sv = *source;
......
......@@ -10,7 +10,7 @@ check_cxx_source_compiles("
#include <QImage>
int main()
{
Poppler::Page *p;
Poppler::Page *p = nullptr;
p->renderToImage(0, 0, 0, 0, 0, 0, Poppler::Page::Rotate0, nullptr, nullptr, nullptr, QVariant());
return 0;
}
......@@ -22,10 +22,10 @@ check_cxx_source_compiles("
#include <poppler-link.h>
int main()
{
Poppler::FormField *f;
Poppler::FormField *f = nullptr;
f->setReadOnly(true);
f->setVisible(true);
Poppler::Link *l;
Poppler::Link *l = nullptr;
l->nextLinks();
}
" HAVE_POPPLER_0_64)
......@@ -35,7 +35,7 @@ check_cxx_source_compiles("
#include <poppler-form.h>
int main()
{
Poppler::FormField *f;
Poppler::FormField *f = nullptr;
f->additionalAction(Poppler::Annotation::CursorEnteringAction);
}
" HAVE_POPPLER_0_65)
......@@ -46,6 +46,7 @@ check_cxx_source_compiles("
int main()
{
auto f = &Poppler::SignatureValidationInfo::reason;
(void)f;
}
" HAVE_POPPLER_0_68)
......@@ -65,6 +66,7 @@ check_cxx_source_compiles("
int main()
{
QString s = Poppler::Version::string();
(void)s;
return 0;
}
" HAVE_POPPLER_0_73)
......@@ -75,7 +77,7 @@ check_cxx_source_compiles("
int main()
{
Poppler::FormFieldIcon icon(nullptr);
Poppler::FormFieldButton *button;
Poppler::FormFieldButton *button = nullptr;
button->setIcon( icon );
return 0;
}
......@@ -87,6 +89,7 @@ int main()
{
Poppler::FontInfo info;
QString substituteName = info.substituteName();
(void)substituteName;
return 0;
}
" HAVE_POPPLER_0_80)
......
......@@ -251,7 +251,7 @@ QImage TIFFGenerator::image( Okular::PixmapRequest * request )
orientation = ORIENTATION_TOPLEFT;
QImage image( width, height, QImage::Format_RGB32 );
uint32 * data = (uint32 *)image.bits();
uint32 * data = reinterpret_cast<uint32 *>(image.bits());
// read data
if ( TIFFReadRGBAImageOriented( d->tiff, width, height, data, orientation ) != 0 )
......@@ -389,7 +389,7 @@ bool TIFFGenerator::print( QPrinter& printer )
continue;
QImage image( width, height, QImage::Format_RGB32 );
uint32 * data = (uint32 *)image.bits();
uint32 * data = reinterpret_cast<uint32 *>(image.bits());
// read data
if ( TIFFReadRGBAImageOriented( d->tiff, width, height, data, ORIENTATION_TOPLEFT ) != 0 )
......
......@@ -77,7 +77,7 @@ QString serializeOptions(const QCommandLineParser &args)
QString serializeOptions(bool startInPresentation, bool showPrintDialog, bool showPrintDialogAndExit, bool unique, bool noRaise, const QString &page, const QString &find)
{
return QStringLiteral("%1:%2:%3:%4:%5:%6:%7").arg(startInPresentation).arg(showPrintDialog).arg(showPrintDialogAndExit).arg(unique).arg(noRaise).arg(page).arg(QString(find.toLatin1().toBase64()));
return QStringLiteral("%1:%2:%3:%4:%5:%6:%7").arg(startInPresentation).arg(showPrintDialog).arg(showPrintDialogAndExit).arg(unique).arg(noRaise).arg(page, QString::fromLatin1(find.toLatin1().toBase64()));
}
bool unserializeOptions(const QString &serializedOptions, bool *presentation, bool *print, bool *print_and_exit, bool *unique, bool *noraise, QString *page, QString *find)
......
......@@ -269,7 +269,7 @@ void colorizeImage( QImage & grayImage, const QColor & color, unsigned int destA
grayImage = grayImage.convertToFormat( QImage::Format_ARGB32_Premultiplied );
// iterate over all pixels changing the alpha component value
unsigned int * data = (unsigned int *)grayImage.bits();
unsigned int * data = reinterpret_cast<unsigned int *>(grayImage.bits());
unsigned int pixels = grayImage.width() * grayImage.height();
int red = color.red(),
green = color.green(),
......
......@@ -372,7 +372,7 @@ void PagePainter::paintCroppedPageOnPainter( QPainter * destPainter, const Okula
break;
case Okular::SettingsCore::EnumRenderMode::BlackWhite:
// Manual Gray and Contrast
unsigned int * data = (unsigned int *)backImage.bits();
unsigned int * data = reinterpret_cast<unsigned int *>(backImage.bits());
int val, pixels = backImage.width() * backImage.height(),
con = Okular::Settings::bWContrast(), thr = 255 - Okular::Settings::bWThreshold();
for( int i = 0; i < pixels; ++i )
......@@ -850,7 +850,7 @@ static inline int qt_div_255(int x) { return (x + (x>>8) + 0x80) >> 8; }
void PagePainter::changeImageAlpha( QImage & image, unsigned int destAlpha )
{
// iterate over all pixels changing the alpha component value
unsigned int * data = (unsigned int *)image.bits();
unsigned int * data = reinterpret_cast<unsigned int *>(image.bits());
unsigned int pixels = image.width() * image.height();
int source, sourceAlpha;
......
......@@ -1302,8 +1302,8 @@ void PresentationWidget::generateOverlay()
color = pal.color( QPalette::Active, QPalette::Highlight );
int sRed = color.red(), sGreen = color.green(), sBlue = color.blue();
// pointers
unsigned int * data = (unsigned int *)image.bits(),
* shadowData = (unsigned int *)shadow.bits(),
unsigned int * data = reinterpret_cast<unsigned int *>(image.bits()),
* shadowData = reinterpret_cast<unsigned int *>(shadow.bits()),
pixels = image.width() * image.height();
// cache data (reduce computation time to 26%!)
int c1 = -1, c2 = -1, cR = 0, cG = 0, cB = 0, cA = 0;
......
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