Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix a bunch of -Wall warnings, part 3 #595

Merged
merged 17 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
e8e60c2
cp_stats: fix compiler warnings [-Wunused-const-variable]
benoit-pierre Aug 1, 2024
4891978
docxfmt & odtfmt: fix compiler warnings [-Woverloaded-virtual]
benoit-pierre Aug 1, 2024
c254597
docxfmt: fix compiler warnings [-Woverloaded-virtual]
benoit-pierre Aug 1, 2024
c1d9610
docxfmt: fix compiler warning [-Wunused-const-variable]
benoit-pierre Aug 1, 2024
7079bef
docxfmt: fix compiler warning [-Wunused-private-field]
benoit-pierre Aug 1, 2024
7ce911b
lvdrawbuf: fix compiler warning [-Wunused-function]
benoit-pierre Aug 1, 2024
3d56978
lvfntman: fix spurious compiler warning [-Wmaybe-uninitialized]
benoit-pierre Aug 1, 2024
b29b5f2
lvimg: fix compiler warning [-Wmisleading-indentation]
benoit-pierre Aug 1, 2024
330a2a9
lvmemman: fix compiler warning [-Wmissing-braces]
benoit-pierre Aug 1, 2024
cffecac
lvrend: fix spurious compiler warning [-Wmaybe-uninitialized]
benoit-pierre Aug 1, 2024
dbe0d6a
lvstsheet: fix spurious compiler warning [-Wmaybe-uninitialized]
benoit-pierre Aug 1, 2024
ae0791c
lvtextfm: fix compiler warning [-Wmaybe-uninitialized]
benoit-pierre Aug 1, 2024
9d00e13
lvtinydom: fix compiler warning [-Wunneeded-internal-declaration]
benoit-pierre Aug 1, 2024
19e71b4
lvxml: fix compiler warning [-Wmisleading-indentation]
benoit-pierre Aug 1, 2024
9bab237
lvxml: fix compiler warning [-Wunused-private-field]
benoit-pierre Aug 1, 2024
faec570
mathml: fix compiler warning [-Wmaybe-uninitialized]
benoit-pierre Aug 1, 2024
4b300d7
pdbfmt: fix compiler warning [-Wmissing-braces]
benoit-pierre Aug 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crengine/include/lvtinydom.h
Original file line number Diff line number Diff line change
Expand Up @@ -2689,6 +2689,7 @@
ignore_font_names = !_fontFamilyFonts[0].empty(); // [0] holds this boolean option (false if empty, true if not)
return _fontFamilyFonts[idx];
}
ignore_font_names = false;
return lString8::empty_str;
}

Expand Down Expand Up @@ -3088,7 +3089,7 @@
insideTag(false), styleDetectionState(0), pathSubstitutions(100), baseElement(NULL), lastBaseElement(NULL),
headStyleState(0), insideHtmlTag(false)
{
setCodeBase( fragmentFilePath );

Check warning on line 3092 in crengine/include/lvtinydom.h

View workflow job for this annotation

GitHub Actions / Static linting

Call to virtual method 'ldomDocumentFragmentWriter::setCodeBase' during construction bypasses virtual dispatch
}
/// destructor
virtual ~ldomDocumentFragmentWriter() { }
Expand Down
2 changes: 2 additions & 0 deletions crengine/src/cp_stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ static const dbl_char_stat_t dbl_ch_stat_cp1250_cs1[256] = {
};


#if 0

static const short ch_stat_iso8859_2_cs2[256]={
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,// 0..15
Expand Down Expand Up @@ -601,6 +602,7 @@ static const dbl_char_stat_t dbl_ch_stat_iso8859_2_cs2[256] = {
{0xec,0x6a,0x0025}, {0xec,0x6b,0x0023}, {0xec,0x6c,0x0051}, {0xec,0x74,0x001d}, {0xed,0x20,0x00d8}, {0xed,0x63,0x0029}, {0xed,0x6b,0x002f}, {0xed,0x6d,0x0041}, {0xed,0x74,0x0024}, {0xf8,0x65,0x0087}, {0xf8,0x69,0x0045}, {0xf8,0xed,0x003c}, {0xf9,0x20,0x0027}, {0xfd,0x20,0x0060}, {0xfd,0x63,0x001d}, {0xfd,0x6d,0x0020}, // 240..255
};

#endif


static const short ch_stat_cp1250_pl1[256]={
Expand Down
70 changes: 32 additions & 38 deletions crengine/src/docxfmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@
DOCX_LAST_ITEM
};

enum docx_multilevel_type {
docx_hybrid_multilevel,
docx_multilevel,
docx_singlelevel
};

#define DOCX_NUM_FMT(itm) docx_numFormat_##itm ,
#define DOCX_TAG(itm)
enum docx_numFormat_type {
Expand Down Expand Up @@ -215,10 +209,6 @@
DOCX_LAST_ITEM
};

const struct item_def_t no_elements[] = {
DOCX_LAST_ITEM
};

const struct item_def_t jc_attr_values[] = {
{ css_ta_left, U"left"},
{ css_ta_right, U"right" },
Expand Down Expand Up @@ -337,7 +327,6 @@
class docxAbstractNum : public LVRefCounter
{
private:
docx_multilevel_type m_multilevel;
css_length_t m_abstractNumId;
LVHashTable<lUInt32, docxNumLevelRef> m_levels;
public:
Expand Down Expand Up @@ -442,7 +431,8 @@
{
}
ldomNode * handleTagOpen(int tagId);
void handleAttribute(const lChar32 * attrname, const lChar32 * attrvalue);
void handleAttribute(const lChar32 * nsname, const lChar32 * attrname, const lChar32 * attrvalue);
void start() { docx_ElementHandler::start(); };
void start(odx_rPr *rPr);
void reset();
};
Expand All @@ -457,7 +447,7 @@
{
}
ldomNode * handleTagOpen(int tagId);
void handleAttribute(const lChar32 * attrname, const lChar32 * attrvalue);
void handleAttribute(const lChar32 * nsname, const lChar32 * attrname, const lChar32 * attrvalue);
void handleTagClose( const lChar32 * nsname, const lChar32 * tagname );
void reset() { m_level = 1; }
};
Expand All @@ -484,7 +474,7 @@
{
}
ldomNode * handleTagOpen(int tagId);
void handleAttribute(const lChar32 * attrname, const lChar32 * attrvalue);
void handleAttribute(const lChar32 * nsname, const lChar32 * attrname, const lChar32 * attrvalue);
void handleText( const lChar32 * text, int len, lUInt32 flags );
void handleTagClose( const lChar32 * nsname, const lChar32 * tagname );
void reset();
Expand All @@ -500,8 +490,9 @@
{
}
ldomNode * handleTagOpen(int tagId);
void handleAttribute(const lChar32 * attrname, const lChar32 * attrvalue);
void handleAttribute(const lChar32 * nsname, const lChar32 * attrname, const lChar32 * attrvalue);
void handleTagClose( const lChar32 * nsname, const lChar32 * tagname );
void start() { docx_ElementHandler::start(); };
void start(odx_pPr *pPr);
void reset();
};
Expand All @@ -518,7 +509,7 @@
{
}
ldomNode * handleTagOpen(int tagId);
void handleAttribute(const lChar32 * attrname, const lChar32 * attrvalue);
void handleAttribute(const lChar32 * nsname, const lChar32 * attrname, const lChar32 * attrvalue);
void handleTagClose( const lChar32 * nsname, const lChar32 * tagname );
void reset() { m_target.clear(); m_rHandler.reset(); m_runCount = 0; }
};
Expand All @@ -545,7 +536,7 @@
{
}
ldomNode * handleTagOpen(int tagId);
void handleAttribute(const lChar32 * attrname, const lChar32 * attrvalue);
void handleAttribute(const lChar32 * nsname, const lChar32 * attrname, const lChar32 * attrvalue);
void handleTagClose( const lChar32 * nsname, const lChar32 * tagname );
void reset();
};
Expand Down Expand Up @@ -587,7 +578,7 @@
{
}
ldomNode * handleTagOpen(int tagId);
void handleAttribute(const lChar32 * attrname, const lChar32 * attrvalue);
void handleAttribute(const lChar32 * nsname, const lChar32 * attrname, const lChar32 * attrvalue);
void handleTagClose( const lChar32 * nsname, const lChar32 * tagname );
void reset();
};
Expand All @@ -607,7 +598,7 @@
{
}
ldomNode * handleTagOpen(int tagId);
void handleAttribute(const lChar32 * attrname, const lChar32 * attrvalue);
void handleAttribute(const lChar32 * nsname, const lChar32 * attrname, const lChar32 * attrvalue);
void handleTagClose( const lChar32 * nsname, const lChar32 * tagname );
};

Expand Down Expand Up @@ -646,7 +637,7 @@
{
}
ldomNode * handleTagOpen(int tagId);
void handleAttribute(const lChar32 * attrname, const lChar32 * attrvalue);
void handleAttribute(const lChar32 * nsname, const lChar32 * attrname, const lChar32 * attrvalue);
void handleTagClose( const lChar32 * nsname, const lChar32 * tagname );
void start();
};
Expand All @@ -663,7 +654,7 @@
docx_ElementHandler(reader, writer, context, docx_el_styles, styles_elements),
m_styleHandler(reader, writer, context),
m_pPrHandler(reader, writer, context),
m_rPrHandler(reader, writer, context)

Check warning on line 657 in crengine/src/docxfmt.cpp

View workflow job for this annotation

GitHub Actions / Static linting

7 uninitialized fields at the end of the constructor call
{
}
/// destructor
Expand All @@ -686,11 +677,14 @@
m_rPrHandler(reader, writer, context)
{
}
void start() {
docx_ElementHandler::start();
}
void start(docxNumLevel* level) {
m_lvl = level;
docx_ElementHandler::start();
start();
}
void handleAttribute(const lChar32 * attrname, const lChar32 * attrvalue);
void handleAttribute(const lChar32 * nsname, const lChar32 * attrname, const lChar32 * attrvalue);
ldomNode * handleTagOpen(int tagId);
void reset();
};
Expand All @@ -706,7 +700,7 @@
m_lvlHandler(reader, writer, context)
{
}
void handleAttribute(const lChar32 * attrname, const lChar32 * attrvalue);
void handleAttribute(const lChar32 * nsname, const lChar32 * attrname, const lChar32 * attrvalue);
ldomNode * handleTagOpen(int tagId);
void handleTagClose( const lChar32 * nsname, const lChar32 * tagname );
void start();
Expand All @@ -723,7 +717,7 @@
m_lvlHandler(reader, writer, context)
{
}
void handleAttribute(const lChar32 * attrname, const lChar32 * attrvalue);
void handleAttribute(const lChar32 * nsname, const lChar32 * attrname, const lChar32 * attrvalue);
ldomNode * handleTagOpen(int tagId);
void handleTagClose( const lChar32 * nsname, const lChar32 * tagname );
void start();
Expand All @@ -739,7 +733,7 @@
docx_numberingHandler(docXMLreader * reader, ldomDocumentWriter *writer, docxImportContext *context) :
docx_ElementHandler(reader, writer, context, docx_el_numbering, numbering_elements),
m_numHandler(reader, writer, context),
m_abstractNumHandler(reader, writer, context)

Check warning on line 736 in crengine/src/docxfmt.cpp

View workflow job for this annotation

GitHub Actions / Static linting

11 uninitialized fields at the end of the constructor call
{
}
ldomNode * handleTagOpen(int tagId);
Expand Down Expand Up @@ -854,7 +848,7 @@
return NULL;
}

void docx_rPrHandler::handleAttribute(const lChar32 * attrname, const lChar32 * attrvalue)
void docx_rPrHandler::handleAttribute(const lChar32 * nsname, const lChar32 * attrname, const lChar32 * attrvalue)
{
int attr_value;
switch(m_state) {
Expand Down Expand Up @@ -926,7 +920,7 @@
void docx_rPrHandler::start(odx_rPr * const rPr)
{
m_rPr = rPr;
docx_ElementHandler::start();
start();
}

void docx_rHandler::handleInstruction(lString32 &instruction, lString32 parameters)
Expand Down Expand Up @@ -980,7 +974,7 @@
return NULL;
}

void docx_rHandler::handleAttribute(const lChar32 *attrname, const lChar32 *attrvalue)
void docx_rHandler::handleAttribute(const lChar32 * nsname, const lChar32 *attrname, const lChar32 *attrvalue)
{
if( (docx_el_footnoteReference == m_state || docx_el_endnoteReference == m_state) &&
!lStr_cmp(attrname, "id") ) {
Expand Down Expand Up @@ -1110,7 +1104,7 @@
return NULL;
}

void docx_pPrHandler::handleAttribute(const lChar32 * attrname, const lChar32 * attrvalue)
void docx_pPrHandler::handleAttribute(const lChar32 * nsname, const lChar32 * attrname, const lChar32 * attrvalue)
{
switch(m_state) {
case docx_el_pStyle:
Expand Down Expand Up @@ -1277,7 +1271,7 @@
return NULL;
}

void docx_pHandler::handleAttribute(const lChar32 *attrname, const lChar32 *attrvalue)
void docx_pHandler::handleAttribute(const lChar32 * nsname, const lChar32 *attrname, const lChar32 *attrvalue)
{
if( docx_el_bookmarkStart == m_state && !lStr_cmp(attrname, "name") ) {
m_writer->OnTagOpen(U"", U"a");
Expand Down Expand Up @@ -1380,7 +1374,7 @@
return NULL;
}

void docx_styleHandler::handleAttribute(const lChar32 * attrname, const lChar32 * attrvalue)
void docx_styleHandler::handleAttribute(const lChar32 * nsname, const lChar32 * attrname, const lChar32 * attrvalue)
{
switch(m_state) {
case docx_el_style:
Expand Down Expand Up @@ -1727,7 +1721,7 @@
return NULL;
}

void docx_lvlHandler::handleAttribute(const lChar32 *attrname, const lChar32 *attrvalue)
void docx_lvlHandler::handleAttribute(const lChar32 * nsname, const lChar32 *attrname, const lChar32 *attrvalue)
{
css_length_t result;

Expand Down Expand Up @@ -1842,7 +1836,7 @@
return NULL;
}

void docx_footnotesHandler::handleAttribute(const lChar32 *attrname, const lChar32 *attrvalue)
void docx_footnotesHandler::handleAttribute(const lChar32 * nsname, const lChar32 *attrname, const lChar32 *attrvalue)
{
switch(m_state) {
case docx_el_footnote:
Expand Down Expand Up @@ -1892,7 +1886,7 @@
return NULL;
}

void docx_hyperlinkHandler::handleAttribute(const lChar32 *attrname, const lChar32 *attrvalue)
void docx_hyperlinkHandler::handleAttribute(const lChar32 * nsname, const lChar32 *attrname, const lChar32 *attrvalue)
{
if( docx_el_hyperlink == m_state) {
if ( !lStr_cmp(attrname, "id") ) {
Expand Down Expand Up @@ -1923,7 +1917,7 @@
return NULL;
}

void docx_drawingHandler::handleAttribute(const lChar32 *attrname, const lChar32 *attrvalue)
void docx_drawingHandler::handleAttribute(const lChar32 * nsname, const lChar32 *attrname, const lChar32 *attrvalue)
{
if( m_state == docx_el_blip && !lStr_cmp(attrname, "embed") ) {
lString32 imgPath = m_importContext->getImageTarget(lString32(attrvalue));
Expand Down Expand Up @@ -1990,7 +1984,7 @@
return NULL;
}

void docx_tblHandler::handleAttribute(const lChar32 *attrname, const lChar32 *attrvalue)
void docx_tblHandler::handleAttribute(const lChar32 * nsname, const lChar32 *attrname, const lChar32 *attrvalue)
{
if( m_state == docx_el_gridSpan && !lStr_cmp( attrname, "val" ) ) {
m_colSpan = lString32(attrvalue).atoi();
Expand Down Expand Up @@ -2117,7 +2111,7 @@
return NULL;
}

void docx_abstractNumHandler::handleAttribute(const lChar32 * attrname, const lChar32 * attrvalue)
void docx_abstractNumHandler::handleAttribute(const lChar32 * nsname, const lChar32 * attrname, const lChar32 * attrvalue)
{
switch(m_state) {
case docx_el_abstractNum:
Expand Down Expand Up @@ -2153,7 +2147,7 @@
docx_ElementHandler::start();
}

void docx_numHandler::handleAttribute(const lChar32 *attrname, const lChar32 *attrvalue)
void docx_numHandler::handleAttribute(const lChar32 * nsname, const lChar32 *attrname, const lChar32 *attrvalue)
{
switch(m_state) {
case docx_el_num:
Expand Down Expand Up @@ -2223,7 +2217,7 @@
{
docxNumLevelRef levelRef = m_overrides.get(level);
if( !levelRef.isNull() )
return levelRef.get();

Check warning on line 2220 in crengine/src/docxfmt.cpp

View workflow job for this annotation

GitHub Actions / Static linting

Use of memory after it is freed
docxAbstractNumRef baseRef = getBase(context);
if( !baseRef.isNull() )
return baseRef->getLevel(level);
Expand All @@ -2248,14 +2242,14 @@
m_levels.set(docxLevel->getLevel().value, docxLevel);
}

docxAbstractNum::docxAbstractNum() : m_multilevel(docx_singlelevel),
docxAbstractNum::docxAbstractNum() :
m_abstractNumId(css_val_unspecified, 0), m_levels(10)
{
}

docxNumLevel *docxAbstractNum::getLevel(int level)
{
return m_levels.get(level).get();

Check warning on line 2252 in crengine/src/docxfmt.cpp

View workflow job for this annotation

GitHub Actions / Static linting

Use of memory after it is freed
}

void docxAbstractNum::reset()
Expand Down
2 changes: 2 additions & 0 deletions crengine/src/lvdrawbuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1606,9 +1606,11 @@ inline static lUInt32 BB(lUInt32 color) {
return color & 0xFF;
}

#if 0
inline static lUInt32 RRGGBB(lUInt32 r, lUInt32 g, lUInt32 b) {
return ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | (b & 0xFF);
}
#endif

inline static lUInt32 AARRGGBB(lUInt32 a, lUInt32 r, lUInt32 g, lUInt32 b) {
return ((a & 0xFF) << 24) | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | (b & 0xFF);
Expand Down
2 changes: 1 addition & 1 deletion crengine/src/lvfntman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ class LVFontCache
{
int base_weight = bold ? 700 : 400;
LVFontDef * best_def = NULL;
int best_delta;
int best_delta = INT_MAX;
for ( int i=0; i<_registered_list.length(); i++ ) {
if (_registered_list[i]->getDef()->getDocumentId() == -1) {
LVFontDef * fdef = _registered_list[i]->getDef();
Expand Down
2 changes: 1 addition & 1 deletion crengine/src/lvimg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ bool LVPngImageSource::Decode( LVImageDecoderCallback * callback )
png_set_packing(png_ptr);

//if (color_type == PNG_COLOR_TYPE_RGB)
png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);
png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);
Frenzie marked this conversation as resolved.
Show resolved Hide resolved

//if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
// png_set_swap_alpha(png_ptr);
Expand Down
3 changes: 2 additions & 1 deletion crengine/src/lvmemman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ void crSetSignalHandler()
if (signals_are_set)
return;
signals_are_set = true;
struct sigaction handler = { 0 };
struct sigaction handler;
memset(&handler, 0, sizeof (handler));
handler.sa_sigaction = cr_sigaction;
handler.sa_flags = SA_RESETHAND;
#define CATCHSIG(X) sigaction(X, &handler, &old_sa[X])
Expand Down
4 changes: 1 addition & 3 deletions crengine/src/lvrend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1729,7 +1729,7 @@ class CCRTable {
int count = txform->GetLineCount();
for (int i=0; i<count; i++) {
const formatted_line_t * line = txform->GetLineInfo(i);
int link_insert_pos; // used if is_single_column
int link_insert_pos = -1; // used if is_single_column, -1 for append
if ( is_single_column ) {
int line_flags = 0;
// Honor widows and orphans
Expand All @@ -1751,8 +1751,6 @@ class CCRTable {
continue;
if ( line->flags & LTEXT_LINE_PARA_IS_RTL )
link_insert_pos = row->single_col_context->getCurrentLinksCount();
else
link_insert_pos = -1; // append
}
for ( int w=0; w<line->word_count; w++ ) { // check link start flag for every word
if ( line->words[w].flags & LTEXT_WORD_IS_LINK_START ) {
Expand Down
4 changes: 2 additions & 2 deletions crengine/src/lvstsheet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7096,8 +7096,8 @@ bool LVStyleSheet::gatherNodeMatchingRulesets(ldomNode * node, const char * str,
for (;*str;) {
// new section
bool match = false;
const char * start;
const char * end;
const char * start = NULL;
const char * end = NULL;
bool err = false;
for (;*str;) {
if ( !match ) {
Expand Down
4 changes: 4 additions & 0 deletions crengine/src/lvtextfm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5822,6 +5822,10 @@ static void drawBorder(LVDrawBuf * buf, int x0, int x1, int y, int h, ldomNode *
case 1: border_style = style->border_style_right; break;
case 2: border_style = style->border_style_bottom; break;
case 3: border_style = style->border_style_left; break;
default:
assert(0);
border_style = css_border_none;
break;
}
int dot, interval;
switch (border_style){
Expand Down
2 changes: 2 additions & 0 deletions crengine/src/lvtinydom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ lUInt32 calcGlobalSettingsHash(int documentId, bool already_rendered)
return hash;
}

#if 0
static void dumpRendMethods( ldomNode * node, lString32 prefix )
{
lString32 name = prefix;
Expand All @@ -438,6 +439,7 @@ static void dumpRendMethods( ldomNode * node, lString32 prefix )
dumpRendMethods( node->getChildNode(i), prefix + " ");
}
}
#endif



Expand Down
Loading
Loading