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 2 #593

Merged
merged 8 commits into from
Jul 29, 2024
7 changes: 3 additions & 4 deletions crengine/src/docxfmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,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 666 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 Down Expand Up @@ -739,7 +739,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 742 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 @@ -1623,10 +1623,9 @@
}

docxImportContext::docxImportContext(OpcPackage *package, ldomDocument *doc) :
odx_ImportContext(doc), m_abstractNumbers(16),
m_Numbers(16), m_footNoteCount(0), m_endNoteCount(0),
m_inField(false), m_linkNode(NULL), m_pStyle(NULL),
m_package(package)
odx_ImportContext(doc), m_abstractNumbers(16), m_Numbers(16),
m_package(package), m_footNoteCount(0), m_endNoteCount(0),
m_inField(false), m_linkNode(NULL), m_pStyle(NULL)
{
}

Expand Down Expand Up @@ -2224,7 +2223,7 @@
{
docxNumLevelRef levelRef = m_overrides.get(level);
if( !levelRef.isNull() )
return levelRef.get();

Check warning on line 2226 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 Down Expand Up @@ -2256,7 +2255,7 @@

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

Check warning on line 2258 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
4 changes: 2 additions & 2 deletions crengine/src/hyphman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1359,7 +1359,7 @@ lUInt8 UserHyphDict::init(lString32 filename, bool reload)
char mask[HYPHENATION_LENGTH];
lvsize_t pos = 0; // pos in puffer
while (pos < count ) {
int i;
unsigned i;
for ( i = 0; i < WORD_LENGTH-1; ++i ) { // -1 because of trailing NULL
if ( buf[pos] == ';' ) {
++pos;
Expand Down Expand Up @@ -1450,7 +1450,7 @@ bool UserHyphDict::getMask(lChar32 *word, char *mask)
lString32 UserHyphDict::getHyphenation(const char *word)
{
lString32 orig_word_str(word);
size_t orig_len = orig_word_str.length();
int orig_len = orig_word_str.length();

// Given some combined words like stairway2heaven, we want to get the first potential part
// as the candidate for hyphenation for a clearer layout, with smaller gaps.
Expand Down
4 changes: 2 additions & 2 deletions crengine/src/lvstsheet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1888,8 +1888,8 @@ class AtRuleLogicalConditionParser {
int level;
bool malformed;
lxmlDocBase * doc;
lChar32 stop_char;
lChar32 stop_char2;
char stop_char;
char stop_char2;
AtRuleLogicalConditionParser(lxmlDocBase * d, char stopchar='{', char stopchar2=0)
: doc(d), stop_char(stopchar), stop_char2(stopchar2) {
malformed = false;
Expand Down
10 changes: 5 additions & 5 deletions crengine/src/lvtextfm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ class LVFormatter {
embedded_float_t * flt = m_pbuffer->floats[i];
if (flt->to_position) // ignore not yet positioned floats
continue;
if (flt->y <= y && flt->y + flt->height > y) { // this float is spanning this y
if (flt->y <= y && flt->y + (int)flt->height > y) { // this float is spanning this y
if (flt->is_right) {
if (flt->x < fl_right_min_x)
fl_right_min_x = flt->x;
Expand Down Expand Up @@ -753,7 +753,7 @@ class LVFormatter {
embedded_float_t * flt = m_pbuffer->floats[i];
if (flt->to_position) // ignore not yet positioned floats (even if
continue; // there shouldn't be any when this is called)
if (flt->y < m_y && flt->y + flt->height > m_y) {
if (flt->y < m_y && flt->y + (int)flt->height > m_y) {
has_ongoing_float = true;
break;
}
Expand Down Expand Up @@ -824,7 +824,7 @@ class LVFormatter {
embedded_float_t * flt = m_pbuffer->floats[i];
if (flt->to_position) // ignore not yet positioned floats, as they
continue; // are not yet running past m_y
if (flt->y < m_y && flt->y + flt->height > m_y) {
if (flt->y < m_y && flt->y + (int)flt->height > m_y) {
m_has_ongoing_float = true;
break;
}
Expand Down Expand Up @@ -862,7 +862,7 @@ class LVFormatter {
embedded_float_t * flt = m_pbuffer->floats[i];
if (flt->to_position) // ignore not yet positioned floats
continue;
if (flt->y <= y && flt->y + flt->height > y) { // this float is spanning this y
if (flt->y <= y && flt->y + (int)flt->height > y) { // this float is spanning this y
if (flt->is_right) {
if (flt->x < fl_right_min_x)
fl_right_min_x = flt->x;
Expand Down Expand Up @@ -6407,7 +6407,7 @@ void LFormattedText::Draw( LVDrawBuf * buf, int x, int y, ldomMarkedRangeList *
int top_overflow = fmt.getTopOverflow();
int bottom_overflow = fmt.getBottomOverflow();

if (y + flt->y - top_overflow < clip.bottom && y + flt->y + flt->height + bottom_overflow > clip.top) {
if (y + flt->y - top_overflow < clip.bottom && y + flt->y + (int)flt->height + bottom_overflow > clip.top) {
// DrawDocument() parameters (y0 + doc_y must be equal to our y,
// doc_y just shift the viewport, so anything outside is not drawn).
int x0 = x + flt->x;
Expand Down
11 changes: 3 additions & 8 deletions crengine/src/lvtinydom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2705,12 +2705,9 @@ bool tinyNodeCollection::loadNodeData(lUInt16 type, ldomNode ** list, int nodeco
// buf contains `sz' ldomNode items
// _elemList, _textList (as `list' argument) must always be TNC_PART_LEN size
// add into `list' zero filled (TNC_PART_LEN - sz) items
list[i] = (ldomNode *)realloc(buf, TNC_PART_LEN * sizeof(ldomNode));
if (NULL == list[i]) {
free(buf);
CRLog::error("Not enough memory!");
list[i] = cr_realloc(buf, TNC_PART_LEN);
if (NULL == list[i])
return false;
}
memset( list[i] + sz, 0, (TNC_PART_LEN - sz) * sizeof(ldomNode) );
}
for (int j=0; j<sz; j++) {
Expand Down Expand Up @@ -9650,7 +9647,7 @@ ldomXPointer ldomDocument::createXPointer( lvPoint pt, int direction, bool stric
// Ignore fake floats (no srctext) made from outer floats footprint
if ( flt->srctext == NULL )
continue;
if (pt.x >= flt->x && pt.x < flt->x + flt->width && pt.y >= flt->y && pt.y < flt->y + flt->height ) {
if (pt.x >= flt->x && pt.x < flt->x + flt->width && pt.y >= flt->y && pt.y < flt->y + (int)flt->height ) {
// pt is inside this float.
ldomNode * node = (ldomNode *) flt->srctext->object; // floatBox node
ldomXPointer inside_ptr = createXPointer( orig_pt, direction, strictBounds, node );
Expand Down Expand Up @@ -15733,8 +15730,6 @@ void ldomDocumentWriterFilter::OnAttribute( const lChar32 * nsname, const lChar3
return;
}

lUInt16 id = _currNode->_element->getNodeId();

// Add the attribute
lUInt16 attr_ns = (nsname && nsname[0]) ? _document->getNsNameIndex( nsname ) : 0;
lUInt16 attr_id = (attrname && attrname[0]) ? _document->getAttrNameIndex( attrname ) : 0;
Expand Down
4 changes: 2 additions & 2 deletions crengine/src/mathml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1944,8 +1944,8 @@ static void fixupMathML( ldomNode * node, bool is_in_script ) {
const mathml_operator_dict_entry * infix = NULL;
const mathml_operator_dict_entry * prefix = NULL;
const mathml_operator_dict_entry * postfix = NULL;
bool found = getOperatorProperties((const lChar32 *)text.c_str(), infix, prefix, postfix);
// printf("%s %d %d %d %d\n", UnicodeToLocal(text).c_str(), found, infix, prefix, postfix);
/*bool found =*/ getOperatorProperties((const lChar32 *)text.c_str(), infix, prefix, postfix);
// printf("%s %d %d %d %d\n", UnicodeToLocal(text).c_str(), found, infix, prefix, postfix);

// The "form" (prefix/infix/postfix) to be used depends on various things:
// https://mathml-refresh.github.io/mathml-core/#dictionary-based-attributes
Expand Down
Loading