mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 16:01:20 +02:00
avoid division by zero
This commit is contained in:
@@ -774,10 +774,11 @@ unsigned char * CPictureViewer::int_Resize(unsigned char *orgin, int ox, int oy,
|
||||
r+=q[0]; g+=q[1]; b+=q[2]; a+=q[3];
|
||||
}
|
||||
}
|
||||
p[0]= uint8_t(r/sq);
|
||||
p[1]= uint8_t(g/sq);
|
||||
p[2]= uint8_t(b/sq);
|
||||
p[3]= uint8_t(a/sq);
|
||||
int sq_tmp = sq ? sq : 1;//avoid division by zero
|
||||
p[0]= uint8_t(r/sq_tmp);
|
||||
p[1]= uint8_t(g/sq_tmp);
|
||||
p[2]= uint8_t(b/sq_tmp);
|
||||
p[3]= uint8_t(a/sq_tmp);
|
||||
}
|
||||
}
|
||||
}else
|
||||
@@ -796,9 +797,10 @@ unsigned char * CPictureViewer::int_Resize(unsigned char *orgin, int ox, int oy,
|
||||
r+=q[0]; g+=q[1]; b+=q[2];
|
||||
}
|
||||
}
|
||||
p[0]= uint8_t(r/sq);
|
||||
p[1]= uint8_t(g/sq);
|
||||
p[2]= uint8_t(b/sq);
|
||||
int sq_tmp = sq ? sq : 1;//avoid division by zero
|
||||
p[0]= uint8_t(r/sq_tmp);
|
||||
p[1]= uint8_t(g/sq_tmp);
|
||||
p[2]= uint8_t(b/sq_tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -2161,9 +2161,9 @@ void CChannelList::paintBody()
|
||||
const int ypos = y+ theight;
|
||||
const int sb = height - theight - footerHeight; // paint scrollbar over full height of main box
|
||||
frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_MENUCONTENT_PLUS_1);
|
||||
|
||||
int sbc= (((*chanlist).size()- 1)/ listmaxshow)+ 1;
|
||||
const int sbs= (selected/listmaxshow);
|
||||
unsigned int listmaxshow_tmp = listmaxshow ? listmaxshow : 1;//avoid division by zero
|
||||
int sbc= (((*chanlist).size()- 1)/ listmaxshow_tmp)+ 1;
|
||||
const int sbs= (selected/listmaxshow_tmp);
|
||||
if (sbc < 1)
|
||||
sbc = 1;
|
||||
|
||||
|
@@ -1137,9 +1137,9 @@ printf("CUpnpBrowserGui::paintItem:s selected %d max %d offset %d\n", selected,
|
||||
ypos = m_y + m_title_height + m_theight;
|
||||
int sb = m_fheight * m_listmaxshow;
|
||||
m_frameBuffer->paintBoxRel(m_x + m_width - 15, ypos, 15, sb, COL_MENUCONTENT_PLUS_1);
|
||||
|
||||
int sbc = ((max + offset - 1) / m_listmaxshow) + 1;
|
||||
int sbs = ((selected + offset) / m_listmaxshow);
|
||||
unsigned int tmp = m_listmaxshow ? m_listmaxshow : 1;//avoid division by zero
|
||||
int sbc = ((max + offset - 1) / tmp) + 1;
|
||||
int sbs = ((selected + offset) / tmp);
|
||||
|
||||
int sbh = 0;
|
||||
if ((sbc > 0) && (sbc > sb-4))
|
||||
|
@@ -221,12 +221,15 @@ int paintButtons( const button_label_ext * const content,
|
||||
}
|
||||
|
||||
if (spacing >= 0)
|
||||
{ /* add half of the inter-object space to the */
|
||||
spacing /= count_labels; /* left and right (this might break vertical */
|
||||
x_button += spacing / 2; /* alignment, but nobody is using this (yet) */
|
||||
} /* and I'm don't know how it should work. */
|
||||
{
|
||||
int tmp = count_labels ? count_labels : 1;//avoid division by zero
|
||||
/* add half of the inter-object space to the */
|
||||
spacing /= tmp; /* left and right (this might break vertical */
|
||||
x_button += spacing / 2; /* alignment, but nobody is using this (yet) */
|
||||
} /* and I'm don't know how it should work. */
|
||||
else
|
||||
{
|
||||
w_text = w_text ? w_text : 1;
|
||||
/* shorten captions relative to their length */
|
||||
for (int i = 0; i < cnt; i++)
|
||||
fwidth[i] = (fwidth[i] * (w_text + spacing)) / w_text; /* spacing is negative...*/
|
||||
@@ -410,8 +413,9 @@ int paintButtons( const int &x,
|
||||
else
|
||||
{
|
||||
/* shorten captions relative to their length */
|
||||
int tmp = w_text ? w_text : 1;//avoid division by zero
|
||||
for (i = 0; i < cnt; i++)
|
||||
fwidth[i] = (fwidth[i] * (w_text + spacing)) / w_text; /* spacing is negative...*/
|
||||
fwidth[i] = (fwidth[i] * (w_text + spacing)) / tmp; /* spacing is negative...*/
|
||||
spacing = 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user