aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRodrigo Arias Mallo <rodarima@gmail.com>2024-07-28 16:40:09 +0200
committerRodrigo Arias Mallo <rodarima@gmail.com>2024-08-07 16:50:35 +0200
commit1e2f9219883452ef7da37c3c984b3e3d2939656b (patch)
treed1414af1325ab9f90e37305800e3a748d90ddf9d
parent0220c850a043af46385d6cd6cf4ffa9ceb5696e3 (diff)
Fix pedantic warnings
Reviewed-by: dogma
-rw-r--r--dpi/downloads.cc6
-rw-r--r--dw/fltkcomplexbutton.cc2
-rw-r--r--dw/fltkimgbuf.cc6
-rw-r--r--dw/fltkplatform.cc2
-rw-r--r--dw/fltkui.cc2
-rw-r--r--dw/layout.cc8
-rw-r--r--dw/style.cc14
-rw-r--r--dw/table.cc1
-rw-r--r--dw/textblock.cc33
-rw-r--r--dw/textblock.hh2
-rw-r--r--dw/textblock_iterator.cc5
-rw-r--r--dw/textblock_linebreaking.cc6
-rw-r--r--src/dialog.cc2
-rw-r--r--src/form.cc3
-rw-r--r--src/gif.c8
-rw-r--r--src/html.cc1
-rw-r--r--src/menu.cc4
-rw-r--r--src/uicmd.cc4
18 files changed, 75 insertions, 34 deletions
diff --git a/dpi/downloads.cc b/dpi/downloads.cc
index 90f7b76d..ee805de9 100644
--- a/dpi/downloads.cc
+++ b/dpi/downloads.cc
@@ -679,11 +679,11 @@ static void secs2timestr(int et, char *str)
eh = et / 3600; em = (et % 3600) / 60; es = et % 60;
if (eh == 0) {
if (em == 0)
- snprintf(str, 8, "%ds", es);
+ snprintf(str, 16, "%ds", es);
else
- snprintf(str, 8, "%dm%ds", em, es);
+ snprintf(str, 16, "%dm%ds", em, es);
} else {
- snprintf(str, 8, "%dh%dm", eh, em);
+ snprintf(str, 16, "%dh%dm", eh, em);
}
}
diff --git a/dw/fltkcomplexbutton.cc b/dw/fltkcomplexbutton.cc
index 76af3713..e287b689 100644
--- a/dw/fltkcomplexbutton.cc
+++ b/dw/fltkcomplexbutton.cc
@@ -63,6 +63,7 @@ int ComplexButton::handle(int event) {
return 1;
case FL_PUSH:
if (Fl::visible_focus() && handle(FL_FOCUS)) Fl::focus(this);
+ /* fallthrough */
case FL_DRAG:
if (Fl::event_inside(this)) {
newval = !oldval;
@@ -107,6 +108,7 @@ int ComplexButton::handle(int event) {
value(0);
return 1;
}
+ /* fallthrough */
default:
return 0;
}
diff --git a/dw/fltkimgbuf.cc b/dw/fltkimgbuf.cc
index df387dfb..4eae450b 100644
--- a/dw/fltkimgbuf.cc
+++ b/dw/fltkimgbuf.cc
@@ -324,7 +324,8 @@ inline void FltkImgbuf::scaleBuffer (const core::byte *src, int srcWidth,
gammaMap2 = findGammaCorrectionTable (1 / gamma);
}
- for(int x = 0; x < destWidth; x++)
+ int *v = new int[bpp];
+ for(int x = 0; x < destWidth; x++) {
for(int y = 0; y < destHeight; y++) {
int xo1 = x * srcWidth / destWidth;
int xo2 = lout::misc::max ((x + 1) * srcWidth / destWidth, xo1 + 1);
@@ -332,7 +333,6 @@ inline void FltkImgbuf::scaleBuffer (const core::byte *src, int srcWidth,
int yo2 = lout::misc::max ((y + 1) * srcHeight / destHeight, yo1 + 1);
int n = (xo2 - xo1) * (yo2 - yo1);
- int v[bpp];
for(int i = 0; i < bpp; i++)
v[i] = 0;
@@ -349,6 +349,8 @@ inline void FltkImgbuf::scaleBuffer (const core::byte *src, int srcWidth,
pd[i] =
scaleMode == BEAUTIFUL_GAMMA ? gammaMap1[v[i] / n] : v[i] / n;
}
+ }
+ delete[] v;
}
void FltkImgbuf::copyRow (int row, const core::byte *data)
diff --git a/dw/fltkplatform.cc b/dw/fltkplatform.cc
index 948c1444..0b7ee2e9 100644
--- a/dw/fltkplatform.cc
+++ b/dw/fltkplatform.cc
@@ -497,7 +497,7 @@ void FltkPlatform::detachView (core::View *view)
{
if (this->view != view)
MSG_ERR("FltkPlatform::detachView: this->view: %p view: %p\n",
- this->view, view);
+ (void *) this->view, (void *) view);
for (container::typed::Iterator <ui::FltkResource> it =
resources->iterator (); it.hasNext (); ) {
diff --git a/dw/fltkui.cc b/dw/fltkui.cc
index 712b914f..e454f85b 100644
--- a/dw/fltkui.cc
+++ b/dw/fltkui.cc
@@ -460,7 +460,7 @@ void FltkResource::detachView (FltkView *view)
{
if (this->view != view)
MSG_ERR("FltkResource::detachView: this->view: %p view: %p\n",
- this->view, view);
+ (void *) this->view, (void *) view);
this->view = NULL;
}
diff --git a/dw/layout.cc b/dw/layout.cc
index a6b77aaf..5b3000c0 100644
--- a/dw/layout.cc
+++ b/dw/layout.cc
@@ -504,8 +504,10 @@ void Layout::attachView (View *view)
void Layout::detachView (View *view)
{
- if (this->view != view)
- MSG_ERR("detachView: this->view: %p view %p\n", this->view, view);
+ if (this->view != view) {
+ MSG_ERR("detachView: this->view: %p view %p\n",
+ (void *) this->view, (void *) view);
+ }
view->setLayout (NULL);
platform->detachView (view);
@@ -865,7 +867,7 @@ void Layout::resizeIdle ()
enterResizeIdle ();
- static int calls = 0;
+ //static int calls = 0;
// There are two commits, 2863:b749629fbfc9 and 4645:ab70f9ce4353, the second
// reverting the former. Interrestingly, the second fixes a bug. However, it
diff --git a/dw/style.cc b/dw/style.cc
index 4c4351a8..f362710e 100644
--- a/dw/style.cc
+++ b/dw/style.cc
@@ -773,6 +773,7 @@ static void drawBorderTop(View *view, Style *style,
break;
case BORDER_DOTTED:
dotted = true;
+ /* fallthrough */
case BORDER_DASHED:
w = style->borderWidth.top;
view->drawTypedLine(style->borderColor.top, shading,
@@ -782,6 +783,7 @@ static void drawBorderTop(View *view, Style *style,
case BORDER_SOLID:
case BORDER_INSET:
inset = true;
+ /* fallthrough */
case BORDER_OUTSET:
if (style->borderStyle.top != BORDER_SOLID)
shading = (inset) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
@@ -801,6 +803,7 @@ static void drawBorderTop(View *view, Style *style,
break;
case BORDER_RIDGE:
ridge = true;
+ /* fallthrough */
case BORDER_GROOVE:
d = style->borderWidth.top & 1;
points[0].x = x1;
@@ -870,6 +873,7 @@ static void drawBorderBottom(View *view, Style *style,
break;
case BORDER_DOTTED:
dotted = true;
+ /* fallthrough */
case BORDER_DASHED:
w = style->borderWidth.bottom;
view->drawTypedLine(style->borderColor.bottom, shading,
@@ -879,6 +883,7 @@ static void drawBorderBottom(View *view, Style *style,
case BORDER_SOLID:
case BORDER_INSET:
inset = true;
+ /* fallthrough */
case BORDER_OUTSET:
if (style->borderStyle.bottom != BORDER_SOLID)
shading = (inset) ? Color::SHADING_LIGHT : Color::SHADING_DARK;
@@ -898,6 +903,7 @@ static void drawBorderBottom(View *view, Style *style,
break;
case BORDER_RIDGE:
ridge = true;
+ /* fallthrough */
case BORDER_GROOVE:
w = style->borderWidth.bottom;
d = w & 1;
@@ -969,6 +975,7 @@ static void drawBorderLeft(View *view, Style *style,
break;
case BORDER_DOTTED:
dotted = true;
+ /* fallthrough */
case BORDER_DASHED:
w = style->borderWidth.left;
view->drawTypedLine(style->borderColor.left, shading,
@@ -978,6 +985,7 @@ static void drawBorderLeft(View *view, Style *style,
case BORDER_SOLID:
case BORDER_INSET:
inset = true;
+ /* fallthrough */
case BORDER_OUTSET:
if (style->borderStyle.left != BORDER_SOLID)
shading = (inset) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
@@ -996,6 +1004,7 @@ static void drawBorderLeft(View *view, Style *style,
break;
case BORDER_RIDGE:
ridge = true;
+ /* fallthrough */
case BORDER_GROOVE:
w = style->borderWidth.left;
d = w & 1;
@@ -1066,6 +1075,7 @@ static void drawBorderRight(View *view, Style *style,
break;
case BORDER_DOTTED:
dotted = true;
+ /* fallthrough */
case BORDER_DASHED:
w = style->borderWidth.right;
view->drawTypedLine(style->borderColor.right, shading,
@@ -1075,6 +1085,7 @@ static void drawBorderRight(View *view, Style *style,
case BORDER_SOLID:
case BORDER_INSET:
inset = true;
+ /* fallthrough */
case BORDER_OUTSET:
if (style->borderStyle.right != BORDER_SOLID)
shading = (inset) ? Color::SHADING_LIGHT : Color::SHADING_DARK;
@@ -1093,6 +1104,7 @@ static void drawBorderRight(View *view, Style *style,
break;
case BORDER_RIDGE:
ridge = true;
+ /* fallthrough */
case BORDER_GROOVE:
w = style->borderWidth.right;
d = w & 1;
@@ -1419,6 +1431,7 @@ void numtostr (int num, char *buf, int buflen, ListStyleType listStyleType)
case LIST_STYLE_TYPE_LOWER_ALPHA:
case LIST_STYLE_TYPE_LOWER_LATIN:
start_ch = 'a';
+ /* fallthrough */
case LIST_STYLE_TYPE_UPPER_ALPHA:
case LIST_STYLE_TYPE_UPPER_LATIN:
i0 = num - 1;
@@ -1433,6 +1446,7 @@ void numtostr (int num, char *buf, int buflen, ListStyleType listStyleType)
break;
case LIST_STYLE_TYPE_LOWER_ROMAN:
low = true;
+ /* fallthrough */
case LIST_STYLE_TYPE_UPPER_ROMAN:
i0 = num;
i1 = i0/10; i2 = i1/10; i3 = i2/10;
diff --git a/dw/table.cc b/dw/table.cc
index b16eedfc..582c8184 100644
--- a/dw/table.cc
+++ b/dw/table.cc
@@ -714,6 +714,7 @@ void Table::setColExtreme (int col, ExtrMod mod, void *data, int value)
switch (mod) {
case DATA:
((misc::SimpleVector<int>*)data)->set (col, value);
+ /* fallthrough */
default:
setExtreme (colExtremes->getRef(col), mod, value);
diff --git a/dw/textblock.cc b/dw/textblock.cc
index 0cef739b..870ff9e6 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -1309,7 +1309,7 @@ void Textblock::drawWord (Line *line, int wordIndex1, int wordIndex2,
totalWidth += w->size.width;
}
- char text[l + (drawHyphen ? strlen (hyphenDrawChar) : 0) + 1];
+ char *text = new char[l + (drawHyphen ? strlen (hyphenDrawChar) : 0) + 1];
int p = 0;
for (int i = wordIndex1; i <= wordIndex2; i++) {
const char * t = words->getRef(i)->content.text;
@@ -1325,6 +1325,8 @@ void Textblock::drawWord (Line *line, int wordIndex1, int wordIndex2,
drawWord0 (wordIndex1, wordIndex2, text, totalWidth, drawHyphen,
style, view, area, xWidget, yWidgetBase);
+
+ delete[] text;
}
}
@@ -2066,10 +2068,13 @@ void Textblock::addText (const char *text, size_t len,
// Store hyphen positions.
int n = 0, totalLenCharRemoved = 0;
- int partPenaltyIndex[numParts - 1];
- int partStart[numParts], partEnd[numParts];
- bool charRemoved[numParts - 1], canBeHyphenated[numParts + 1];
- bool permDivChar[numParts - 1], unbreakableForMinWidth[numParts - 1];
+ int *partPenaltyIndex = new int[numParts - 1];
+ int *partStart = new int[numParts];
+ int *partEnd = new int[numParts];
+ bool *charRemoved = new bool[numParts - 1];
+ bool *canBeHyphenated = new bool[numParts + 1];
+ bool *permDivChar = new bool[numParts - 1];
+ bool *unbreakableForMinWidth = new bool[numParts - 1];
canBeHyphenated[0] = canBeHyphenated[numParts] = true;
partStart[0] = 0;
partEnd[numParts - 1] = len;
@@ -2134,8 +2139,9 @@ void Textblock::addText (const char *text, size_t len,
// Get text without removed characters, e. g. hyphens.
const char *textWithoutHyphens;
- char textWithoutHyphensBuf[len - totalLenCharRemoved];
- int *breakPosWithoutHyphens, breakPosWithoutHyphensBuf[numParts - 1];
+ char *textWithoutHyphensBuf = new char[len - totalLenCharRemoved];
+ int *breakPosWithoutHyphens;
+ int *breakPosWithoutHyphensBuf = new int[numParts - 1];
if (totalLenCharRemoved == 0) {
// No removed characters: take original arrays.
@@ -2164,7 +2170,7 @@ void Textblock::addText (const char *text, size_t len,
PUTCHAR(textWithoutHyphens[i]);
PRINTF("'\n");
- core::Requisition wordSize[numParts];
+ core::Requisition *wordSize = new core::Requisition[numParts];
calcTextSizes (textWithoutHyphens, len - totalLenCharRemoved, style,
numParts - 1, breakPosWithoutHyphens, wordSize);
@@ -2228,6 +2234,17 @@ void Textblock::addText (const char *text, size_t len,
correctLastWordExtremes ();
}
}
+
+ delete[] partPenaltyIndex;
+ delete[] partStart;
+ delete[] partEnd;
+ delete[] charRemoved;
+ delete[] canBeHyphenated;
+ delete[] permDivChar;
+ delete[] unbreakableForMinWidth;
+ delete[] textWithoutHyphensBuf;
+ delete[] breakPosWithoutHyphensBuf;
+ delete[] wordSize;
}
DBG_OBJ_LEAVE ();
diff --git a/dw/textblock.hh b/dw/textblock.hh
index 0e635b99..d02e6b7b 100644
--- a/dw/textblock.hh
+++ b/dw/textblock.hh
@@ -8,7 +8,7 @@
// These were used when improved line breaking and hyphenation were implemented.
// Should be, bit by bit, replaced by RTFL (see ../lout/debug.hh).
-#define PRINTF(fmt, ...)
+#define PRINTF(...)
#define PUTCHAR(ch)
#ifdef DBG_RTFL
diff --git a/dw/textblock_iterator.cc b/dw/textblock_iterator.cc
index 14631eba..b0c20eb2 100644
--- a/dw/textblock_iterator.cc
+++ b/dw/textblock_iterator.cc
@@ -113,10 +113,11 @@ void Textblock::TextblockIterator::highlight (int start, int end,
oldEndIndex != textblock->hlEnd[layer].index ||
oldEndChar != textblock->hlEnd[layer].nChar)
textblock->queueDrawRange (index1, index2);
- } else
+ } else {
highlightOOF (start, end, layer);
+ }
- DBG_OBJ_LEAVE_O (getWidget ());
+ DBG_OBJ_LEAVE_O (getWidget ());
}
void Textblock::TextblockIterator::unhighlight (int direction,
diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc
index c02453f7..713ad530 100644
--- a/dw/textblock_linebreaking.cc
+++ b/dw/textblock_linebreaking.cc
@@ -1421,7 +1421,7 @@ int Textblock::hyphenateWord (int wordIndex, int *addIndex1)
if (numBreaks > 0) {
Word origWord = *hyphenatedWord;
- core::Requisition wordSize[numBreaks + 1];
+ core::Requisition *wordSize = new core::Requisition[numBreaks + 1];
calcTextSizes (origWord.content.text, strlen (origWord.content.text),
origWord.style, numBreaks, breakPos, wordSize);
@@ -1506,8 +1506,10 @@ int Textblock::hyphenateWord (int wordIndex, int *addIndex1)
origWord.spaceStyle->unref ();
free (breakPos);
- } else
+ delete[] wordSize;
+ } else {
words->getRef(wordIndex)->flags &= ~Word::CAN_BE_HYPHENATED;
+ }
return numBreaks;
}
diff --git a/src/dialog.cc b/src/dialog.cc
index da623f98..70771be9 100644
--- a/src/dialog.cc
+++ b/src/dialog.cc
@@ -184,7 +184,7 @@ const char *a_Dialog_input(const char *title, const char *msg)
if (!pm) {
int n_it = dList_length(prefs.search_urls);
pm = new Fl_Menu_Item[n_it+1];
- memset(pm, '\0', sizeof(Fl_Menu_Item[n_it+1]));
+ memset(pm, '\0', sizeof(*pm));
for (int i = 0, j = 0; i < n_it; i++) {
char *label, *url, *source;
source = (char *)dList_nth_data(prefs.search_urls, i);
diff --git a/src/form.cc b/src/form.cc
index aeaa35bd..8234c0a3 100644
--- a/src/form.cc
+++ b/src/form.cc
@@ -1720,9 +1720,8 @@ void DilloHtmlInput::activate(DilloHtmlForm *form, int num_entry_fields,
case DILLO_HTML_INPUT_PASSWORD:
if (!(prefs.enterpress_forces_submit || num_entry_fields == 1)) {
break;
- } else {
- /* fall through */
}
+ /* fallthrough */
case DILLO_HTML_INPUT_SUBMIT:
case DILLO_HTML_INPUT_BUTTON_SUBMIT:
case DILLO_HTML_INPUT_IMAGE:
diff --git a/src/gif.c b/src/gif.c
index 2346e2ae..a104ca1d 100644
--- a/src/gif.c
+++ b/src/gif.c
@@ -975,7 +975,7 @@ static size_t Gif_process_bytes(DilloGif *gif, const uchar_t *ibuf,
ibuf += mysize;
if (gif->state != 1)
break;
-
+ /* fallthrough */
case 1:
mysize = Gif_get_descriptor(gif, Buf, ibuf, tmp_bufsize);
if (!mysize)
@@ -983,7 +983,7 @@ static size_t Gif_process_bytes(DilloGif *gif, const uchar_t *ibuf,
tmp_bufsize -= mysize;
ibuf += mysize;
gif->state = 2;
-
+ /* fallthrough */
case 2:
/* Ok, this loop construction looks weird. It implements the <Data>* of
* the GIF grammar. All sorts of stuff is allocated to set up for the
@@ -996,7 +996,7 @@ static size_t Gif_process_bytes(DilloGif *gif, const uchar_t *ibuf,
ibuf += mysize;
if (gif->state != 3)
break;
-
+ /* fallthrough */
case 3:
/* get an image byte */
/* The users sees all of this stuff */
@@ -1005,7 +1005,7 @@ static size_t Gif_process_bytes(DilloGif *gif, const uchar_t *ibuf,
break;
ibuf += mysize;
tmp_bufsize -= mysize;
-
+ /* fallthrough */
default:
/* error - just consume all input */
tmp_bufsize = 0;
diff --git a/src/html.cc b/src/html.cc
index 4e2b73d1..b667e5a3 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -4130,6 +4130,7 @@ static void Html_process_tag(DilloHtml *html, char *tag, int tagsize)
html->ReqTagClose = true;
/* Don't break! Open tags may also close themselves */
+ /* fallthrough */
default:
/* Close function */
diff --git a/src/menu.cc b/src/menu.cc
index 865b843b..b045bf66 100644
--- a/src/menu.cc
+++ b/src/menu.cc
@@ -397,7 +397,7 @@ void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
if (cssUrls && cssUrls->size () > 0) {
stylesheets = new Fl_Menu_Item[cssUrls->size() + 1];
- memset(stylesheets, '\0', sizeof(Fl_Menu_Item[cssUrls->size() + 1]));
+ memset(stylesheets, '\0', sizeof(*stylesheets));
for (j = 0; j < cssUrls->size(); j++) {
DilloUrl *url = cssUrls->get(j);
@@ -638,7 +638,7 @@ void a_Menu_history_popup(BrowserWindow *bw, int x, int y, int direction)
;
pm = new Fl_Menu_Item[n + 1];
- memset(pm, '\0', sizeof(Fl_Menu_Item[n + 1]));
+ memset(pm, '\0', sizeof(*pm));
for (i = 0; i < n; i++) {
pm[i].label(FL_NORMAL_LABEL, a_History_get_title(history_list[i], 1));
diff --git a/src/uicmd.cc b/src/uicmd.cc
index d289df0c..03d191ad 100644
--- a/src/uicmd.cc
+++ b/src/uicmd.cc
@@ -1268,7 +1268,7 @@ void a_UIcmd_view_page_source(BrowserWindow *bw, const DilloUrl *url)
Dstr *dstr_url;
DilloUrl *vs_url;
static int post_id = 0;
- char tag[8];
+ char tag[16];
const char *content_type = a_Nav_get_content_type(url);
a_Misc_parse_content_type(content_type, &major, NULL, NULL);
@@ -1281,7 +1281,7 @@ void a_UIcmd_view_page_source(BrowserWindow *bw, const DilloUrl *url)
if (URL_FLAGS(url) & URL_Post) {
/* append a custom string to differentiate POST URLs */
post_id = (post_id < 9999) ? post_id + 1 : 0;
- snprintf(tag, 8, "_%.4d", post_id);
+ snprintf(tag, 16, "_%.4d", post_id);
dStr_append(dstr_url, tag);
}
vs_url = a_Url_new(dstr_url->str, NULL);