From fbf2c37e640ddaf86845dd610c5d5f86aa9ed52d Mon Sep 17 00:00:00 2001 From: Stefan Gerlach Date: Wed, 26 Jul 2023 10:05:36 +0200 Subject: [PATCH] Fix warnings: zero as null pointer constant Fix more warnings: zero as null pointer constant --- QXlsx/header/xlsxchart.h | 2 +- QXlsx/header/xlsxconditionalformatting.h | 2 +- QXlsx/source/xlsxabstractsheet.cpp | 4 +++- QXlsx/source/xlsxcell.cpp | 2 +- QXlsx/source/xlsxcellformula.cpp | 8 ++++++-- QXlsx/source/xlsxcellrange.cpp | 4 +++- QXlsx/source/xlsxcellreference.cpp | 4 +++- QXlsx/source/xlsxchart.cpp | 12 ++++++++---- QXlsx/source/xlsxchartsheet.cpp | 12 ++++++++---- QXlsx/source/xlsxconditionalformatting.cpp | 12 +++++++++--- QXlsx/source/xlsxdatavalidation.cpp | 8 ++++++-- QXlsx/source/xlsxdatetype.cpp | 4 +++- QXlsx/source/xlsxdocument.cpp | 8 ++++---- QXlsx/source/xlsxdrawinganchor.cpp | 12 ++++++++---- QXlsx/source/xlsxformat.cpp | 8 ++++++-- QXlsx/source/xlsxrelationships.cpp | 4 +++- QXlsx/source/xlsxrichstring.cpp | 8 ++++++-- QXlsx/source/xlsxstyles.cpp | 4 +++- QXlsx/source/xlsxworkbook.cpp | 16 +++++++++------- QXlsx/source/xlsxworksheet.cpp | 8 ++++++-- QXlsx/source/xlsxzipreader.cpp | 4 +++- chartsquestions/sat_calc.cpp | 4 +++- 22 files changed, 103 insertions(+), 47 deletions(-) diff --git a/QXlsx/header/xlsxchart.h b/QXlsx/header/xlsxchart.h index 4b178d7..ba68d26 100644 --- a/QXlsx/header/xlsxchart.h +++ b/QXlsx/header/xlsxchart.h @@ -56,7 +56,7 @@ public: public: void addSeries(const CellRange &range, - AbstractSheet *sheet = NULL, + AbstractSheet *sheet = nullptr, bool headerH = false, bool headerV = false, bool swapHeaders = false); diff --git a/QXlsx/header/xlsxconditionalformatting.h b/QXlsx/header/xlsxconditionalformatting.h index 4ddfdf0..4fbdb5c 100644 --- a/QXlsx/header/xlsxconditionalformatting.h +++ b/QXlsx/header/xlsxconditionalformatting.h @@ -121,7 +121,7 @@ private: private: bool saveToXml(QXmlStreamWriter &writer) const; - bool loadFromXml(QXmlStreamReader &reader, Styles *styles = NULL); + bool loadFromXml(QXmlStreamReader &reader, Styles *styles = nullptr); QSharedDataPointer d; }; diff --git a/QXlsx/source/xlsxabstractsheet.cpp b/QXlsx/source/xlsxabstractsheet.cpp index 69a4f5e..c38f583 100644 --- a/QXlsx/source/xlsxabstractsheet.cpp +++ b/QXlsx/source/xlsxabstractsheet.cpp @@ -16,7 +16,9 @@ AbstractSheetPrivate::AbstractSheetPrivate(AbstractSheet *p, AbstractSheet::Crea sheetState = AbstractSheet::SS_Visible; } -AbstractSheetPrivate::~AbstractSheetPrivate() {} +AbstractSheetPrivate::~AbstractSheetPrivate() +{ +} /*! \class AbstractSheet diff --git a/QXlsx/source/xlsxcell.cpp b/QXlsx/source/xlsxcell.cpp index 7a0e49b..b756c85 100644 --- a/QXlsx/source/xlsxcell.cpp +++ b/QXlsx/source/xlsxcell.cpp @@ -85,7 +85,7 @@ Cell::Cell(const Cell *const cell) */ Cell::~Cell() { - if (NULL != d_ptr) + if (nullptr != d_ptr) delete d_ptr; } diff --git a/QXlsx/source/xlsxcellformula.cpp b/QXlsx/source/xlsxcellformula.cpp index 5ac5c9b..01528ce 100644 --- a/QXlsx/source/xlsxcellformula.cpp +++ b/QXlsx/source/xlsxcellformula.cpp @@ -40,7 +40,9 @@ CellFormulaPrivate::CellFormulaPrivate(const CellFormulaPrivate &other) { } -CellFormulaPrivate::~CellFormulaPrivate() {} +CellFormulaPrivate::~CellFormulaPrivate() +{ +} /*! \class CellFormula @@ -110,7 +112,9 @@ CellFormula &CellFormula::operator=(const CellFormula &other) /*! * Destroys this formula. */ -CellFormula::~CellFormula() {} +CellFormula::~CellFormula() +{ +} /*! * Returns the type of the formula. diff --git a/QXlsx/source/xlsxcellrange.cpp b/QXlsx/source/xlsxcellrange.cpp index 63e7b58..eabadd6 100644 --- a/QXlsx/source/xlsxcellrange.cpp +++ b/QXlsx/source/xlsxcellrange.cpp @@ -106,7 +106,9 @@ CellRange::CellRange(const CellRange &other) /*! Destroys the range. */ -CellRange::~CellRange() {} +CellRange::~CellRange() +{ +} /*! Convert the range to string notation, such as "A1:B5". diff --git a/QXlsx/source/xlsxcellreference.cpp b/QXlsx/source/xlsxcellreference.cpp index 173b2f5..df885cf 100644 --- a/QXlsx/source/xlsxcellreference.cpp +++ b/QXlsx/source/xlsxcellreference.cpp @@ -127,7 +127,9 @@ CellReference::CellReference(const CellReference &other) /*! Destroys the Reference. */ -CellReference::~CellReference() {} +CellReference::~CellReference() +{ +} /*! Convert the Reference to string notation, such as "A1" or "$A$1". diff --git a/QXlsx/source/xlsxchart.cpp b/QXlsx/source/xlsxchart.cpp index 914dfc7..4af5912 100644 --- a/QXlsx/source/xlsxchart.cpp +++ b/QXlsx/source/xlsxchart.cpp @@ -20,7 +20,9 @@ ChartPrivate::ChartPrivate(Chart *q, Chart::CreateFlag flag) { } -ChartPrivate::~ChartPrivate() {} +ChartPrivate::~ChartPrivate() +{ +} /*! * \internal @@ -42,7 +44,9 @@ Chart::Chart(AbstractSheet *parent, CreateFlag flag) /*! * Destroys the chart. */ -Chart::~Chart() {} +Chart::~Chart() +{ +} /*! * Add the data series which is in the range \a range of the \a sheet. @@ -1320,7 +1324,7 @@ bool ChartPrivate::loadXmlAxisValAx(QXmlStreamReader &reader) */ bool ChartPrivate::loadXmlAxisEG_AxShared(QXmlStreamReader &reader, XlsxAxis *axis) { - Q_ASSERT(NULL != axis); + Q_ASSERT(nullptr != axis); Q_ASSERT(reader.name().endsWith(QLatin1String("Ax"))); QString name = reader.name().toString(); // @@ -1999,7 +2003,7 @@ QString ChartPrivate::GetAxisPosString(XlsxAxis::AxisPos axisPos) const QString ChartPrivate::GetAxisName(XlsxAxis *axis) const { QString strAxisName; - if (NULL == axis) + if (nullptr == axis) return strAxisName; QString pos = GetAxisPosString(axis->axisPos); // l, t, r, b diff --git a/QXlsx/source/xlsxchartsheet.cpp b/QXlsx/source/xlsxchartsheet.cpp index 0674fa3..c344f07 100644 --- a/QXlsx/source/xlsxchartsheet.cpp +++ b/QXlsx/source/xlsxchartsheet.cpp @@ -18,11 +18,13 @@ QT_BEGIN_NAMESPACE_XLSX ChartsheetPrivate::ChartsheetPrivate(Chartsheet *p, Chartsheet::CreateFlag flag) : AbstractSheetPrivate(p, flag) - , chart(0) + , chart(nullptr) { } -ChartsheetPrivate::~ChartsheetPrivate() {} +ChartsheetPrivate::~ChartsheetPrivate() +{ +} /*! \class Chartsheet @@ -66,13 +68,15 @@ Chartsheet *Chartsheet::copy(const QString &distName, int distId) const //: Todo Q_UNUSED(distName) Q_UNUSED(distId) - return 0; + return nullptr; } /*! * Destroys this workssheet. */ -Chartsheet::~Chartsheet() {} +Chartsheet::~Chartsheet() +{ +} /*! * Returns the chart object of the sheet. diff --git a/QXlsx/source/xlsxconditionalformatting.cpp b/QXlsx/source/xlsxconditionalformatting.cpp index 04fb5c0..78b54e4 100644 --- a/QXlsx/source/xlsxconditionalformatting.cpp +++ b/QXlsx/source/xlsxconditionalformatting.cpp @@ -14,7 +14,9 @@ QT_BEGIN_NAMESPACE_XLSX -ConditionalFormattingPrivate::ConditionalFormattingPrivate() {} +ConditionalFormattingPrivate::ConditionalFormattingPrivate() +{ +} ConditionalFormattingPrivate::ConditionalFormattingPrivate( const ConditionalFormattingPrivate &other) @@ -22,7 +24,9 @@ ConditionalFormattingPrivate::ConditionalFormattingPrivate( { } -ConditionalFormattingPrivate::~ConditionalFormattingPrivate() {} +ConditionalFormattingPrivate::~ConditionalFormattingPrivate() +{ +} void ConditionalFormattingPrivate::writeCfVo(QXmlStreamWriter &writer, const XlsxCfVoData &cfvo) const @@ -151,7 +155,9 @@ ConditionalFormatting &ConditionalFormatting::operator=(const ConditionalFormatt /*! * Destroy the object. */ -ConditionalFormatting::~ConditionalFormatting() {} +ConditionalFormatting::~ConditionalFormatting() +{ +} /*! * Add a hightlight rule with the given \a type, \a formula1, \a formula2, diff --git a/QXlsx/source/xlsxdatavalidation.cpp b/QXlsx/source/xlsxdatavalidation.cpp index d1abb87..7c63af0 100644 --- a/QXlsx/source/xlsxdatavalidation.cpp +++ b/QXlsx/source/xlsxdatavalidation.cpp @@ -49,7 +49,9 @@ DataValidationPrivate::DataValidationPrivate(const DataValidationPrivate &other) { } -DataValidationPrivate::~DataValidationPrivate() {} +DataValidationPrivate::~DataValidationPrivate() +{ +} /*! * \class DataValidation @@ -143,7 +145,9 @@ DataValidation &DataValidation::operator=(const DataValidation &other) /*! * Destroy the object. */ -DataValidation::~DataValidation() {} +DataValidation::~DataValidation() +{ +} /*! Returns the validation type. diff --git a/QXlsx/source/xlsxdatetype.cpp b/QXlsx/source/xlsxdatetype.cpp index 20a804f..f757c65 100644 --- a/QXlsx/source/xlsxdatetype.cpp +++ b/QXlsx/source/xlsxdatetype.cpp @@ -9,7 +9,9 @@ QT_BEGIN_NAMESPACE_XLSX -DateType::DateType() {} +DateType::DateType() +{ +} /* DateType::DateType(bool is1904) diff --git a/QXlsx/source/xlsxdocument.cpp b/QXlsx/source/xlsxdocument.cpp index 8efebb5..f3424d4 100644 --- a/QXlsx/source/xlsxdocument.cpp +++ b/QXlsx/source/xlsxdocument.cpp @@ -699,7 +699,7 @@ Chart *Document::insertChart(int row, int col, const QSize &size) { if (Worksheet *sheet = currentWorksheet()) return sheet->insertChart(row, col, size); - return 0; + return nullptr; } /*! @@ -1012,7 +1012,7 @@ Cell *Document::cellAt(const CellReference &pos) const { if (Worksheet *sheet = currentWorksheet()) return sheet->cellAt(pos); - return 0; + return nullptr; } /*! @@ -1025,7 +1025,7 @@ Cell *Document::cellAt(int row, int col) const { if (Worksheet *sheet = currentWorksheet()) return sheet->cellAt(row, col); - return 0; + return nullptr; } /*! @@ -1209,7 +1209,7 @@ Worksheet *Document::currentWorksheet() const if (st && st->sheetType() == AbstractSheet::ST_WorkSheet) return static_cast(st); else - return 0; + return nullptr; } /*! diff --git a/QXlsx/source/xlsxdrawinganchor.cpp b/QXlsx/source/xlsxdrawinganchor.cpp index e2f108b..50a19ad 100644 --- a/QXlsx/source/xlsxdrawinganchor.cpp +++ b/QXlsx/source/xlsxdrawinganchor.cpp @@ -57,7 +57,9 @@ DrawingAnchor::DrawingAnchor(Drawing *drawing, ObjectType objectType) m_id = m_drawing->anchors.size(); // must be unique in one drawing{x}.xml file. } -DrawingAnchor::~DrawingAnchor() {} +DrawingAnchor::~DrawingAnchor() +{ +} void DrawingAnchor::setObjectPicture(const QImage &img) { @@ -898,9 +900,11 @@ void DrawingAnchor::saveXmlObjectShape(QXmlStreamWriter &writer) const writer.writeStartElement(QStringLiteral("a:blip")); writer.writeAttribute( QStringLiteral("r:embed"), - QStringLiteral("rId%1").arg(m_drawing->relationships()->count())); // sp_blip_rembed - // QStringLiteral("rId%1").arg(m_drawing->relationships()->count()) - // can't made new pic + QStringLiteral("rId%1").arg( + m_drawing->relationships() + ->count())); // sp_blip_rembed + // QStringLiteral("rId%1").arg(m_drawing->relationships()->count()) + // can't made new pic writer.writeAttribute( QStringLiteral("xmlns:r"), QStringLiteral("http://schemas.openxmlformats.org/officeDocument/2006/relationships")); diff --git a/QXlsx/source/xlsxformat.cpp b/QXlsx/source/xlsxformat.cpp index 13bbc9e..ff9f099 100644 --- a/QXlsx/source/xlsxformat.cpp +++ b/QXlsx/source/xlsxformat.cpp @@ -58,7 +58,9 @@ FormatPrivate::FormatPrivate(const FormatPrivate &other) { } -FormatPrivate::~FormatPrivate() {} +FormatPrivate::~FormatPrivate() +{ +} /*! * \class Format @@ -202,7 +204,9 @@ Format &Format::operator=(const Format &other) /*! * Destroys this format. */ -Format::~Format() {} +Format::~Format() +{ +} /*! * Returns the number format identifier. diff --git a/QXlsx/source/xlsxrelationships.cpp b/QXlsx/source/xlsxrelationships.cpp index 6c7c596..b1e9c1e 100644 --- a/QXlsx/source/xlsxrelationships.cpp +++ b/QXlsx/source/xlsxrelationships.cpp @@ -17,7 +17,9 @@ const QLatin1String schema_msPackage("http://schemas.microsoft.com/office/2006/r const QLatin1String schema_package("http://schemas.openxmlformats.org/package/2006/relationships"); // const QString schema_worksheet = // QStringLiteral("http://schemas.openxmlformats.org/officeDocument/2006/relationships"); -Relationships::Relationships() {} +Relationships::Relationships() +{ +} QList Relationships::documentRelationships(const QString &relativeType) const { diff --git a/QXlsx/source/xlsxrichstring.cpp b/QXlsx/source/xlsxrichstring.cpp index d63f172..af126a4 100644 --- a/QXlsx/source/xlsxrichstring.cpp +++ b/QXlsx/source/xlsxrichstring.cpp @@ -26,7 +26,9 @@ RichStringPrivate::RichStringPrivate(const RichStringPrivate &other) { } -RichStringPrivate::~RichStringPrivate() {} +RichStringPrivate::~RichStringPrivate() +{ +} /*! \class RichString @@ -62,7 +64,9 @@ RichString::RichString(const RichString &other) /*! Destructs the string. */ -RichString::~RichString() {} +RichString::~RichString() +{ +} /*! Assigns \a other to this string and returns a reference to this string diff --git a/QXlsx/source/xlsxstyles.cpp b/QXlsx/source/xlsxstyles.cpp index 833caf8..b777803 100644 --- a/QXlsx/source/xlsxstyles.cpp +++ b/QXlsx/source/xlsxstyles.cpp @@ -69,7 +69,9 @@ Styles::Styles(CreateFlag flag) } } -Styles::~Styles() {} +Styles::~Styles() +{ +} Format Styles::xfFormat(int idx) const { diff --git a/QXlsx/source/xlsxworkbook.cpp b/QXlsx/source/xlsxworkbook.cpp index 98fe24d..4213e09 100644 --- a/QXlsx/source/xlsxworkbook.cpp +++ b/QXlsx/source/xlsxworkbook.cpp @@ -55,7 +55,9 @@ Workbook::Workbook(CreateFlag flag) { } -Workbook::~Workbook() {} +Workbook::~Workbook() +{ +} bool Workbook::isDate1904() const { @@ -193,7 +195,7 @@ AbstractSheet *Workbook::addSheet(const QString &name, int sheetId, AbstractShee if (sheetId > d->last_sheet_id) d->last_sheet_id = sheetId; - AbstractSheet *sheet = NULL; + AbstractSheet *sheet = nullptr; if (type == AbstractSheet::ST_WorkSheet) { // create work sheet (value sheet) sheet = new Worksheet(name, sheetId, this, F_LoadFromExists); @@ -217,12 +219,12 @@ AbstractSheet *Workbook::insertSheet(int index, const QString &name, AbstractShe QString sheetName = createSafeSheetName(name); if (index > d->last_sheet_id) { // User tries to insert, where no sheet has gone before. - return 0; + return nullptr; } if (!sheetName.isEmpty()) { // If user given an already in-used name, we should not continue any more! if (d->sheetNames.contains(sheetName)) - return 0; + return nullptr; } else { if (type == AbstractSheet::ST_WorkSheet) { do { @@ -236,13 +238,13 @@ AbstractSheet *Workbook::insertSheet(int index, const QString &name, AbstractShe } while (d->sheetNames.contains(sheetName)); } else { qWarning("unsupported sheet type."); - return 0; + return nullptr; } } ++d->last_sheet_id; - AbstractSheet *sheet = NULL; + AbstractSheet *sheet = nullptr; if (type == AbstractSheet::ST_WorkSheet) { sheet = new Worksheet(sheetName, d->last_sheet_id, this, F_NewFromScratch); } else if (type == AbstractSheet::ST_ChartSheet) { @@ -385,7 +387,7 @@ AbstractSheet *Workbook::sheet(int index) const { Q_D(const Workbook); if (index < 0 || index >= d->sheets.size()) - return 0; + return nullptr; return d->sheets.at(index).data(); } diff --git a/QXlsx/source/xlsxworksheet.cpp b/QXlsx/source/xlsxworksheet.cpp index 2843f9b..32a79e5 100644 --- a/QXlsx/source/xlsxworksheet.cpp +++ b/QXlsx/source/xlsxworksheet.cpp @@ -59,7 +59,9 @@ WorksheetPrivate::WorksheetPrivate(Worksheet *p, Worksheet::CreateFlag flag) { } -WorksheetPrivate::~WorksheetPrivate() {} +WorksheetPrivate::~WorksheetPrivate() +{ +} /* Calculate the "spans" attribute of the tag. This is an @@ -220,7 +222,9 @@ Worksheet *Worksheet::copy(const QString &distName, int distId) const /*! * Destroys this workssheet. */ -Worksheet::~Worksheet() {} +Worksheet::~Worksheet() +{ +} /*! * Returns whether sheet is protected. diff --git a/QXlsx/source/xlsxzipreader.cpp b/QXlsx/source/xlsxzipreader.cpp index aac845f..dc2cb5e 100644 --- a/QXlsx/source/xlsxzipreader.cpp +++ b/QXlsx/source/xlsxzipreader.cpp @@ -18,7 +18,9 @@ ZipReader::ZipReader(QIODevice *device) init(); } -ZipReader::~ZipReader() {} +ZipReader::~ZipReader() +{ +} void ZipReader::init() { diff --git a/chartsquestions/sat_calc.cpp b/chartsquestions/sat_calc.cpp index 4b21b07..a3ddb61 100644 --- a/chartsquestions/sat_calc.cpp +++ b/chartsquestions/sat_calc.cpp @@ -13,7 +13,9 @@ sat_calc::sat_calc() : output_line_count(5) { } -sat_calc::~sat_calc() {} +sat_calc::~sat_calc() +{ +} void sat_calc::get_chromatogram(const QString &chromatogram) {