Fix warnings in GCC (unused variables, size_t and int comparisons, unhandled enum cases in switch, etc.).

This commit is contained in:
David Capello 2010-08-11 23:42:03 -03:00
parent a2325233f9
commit 7ba3c5df9d
24 changed files with 52 additions and 47 deletions

View File

@ -729,7 +729,6 @@ static void quantize_command(JWidget widget)
static bool sliderRGB_change_hook(JWidget widget, void *data)
{
Palette* palette = get_current_palette();
int r = jslider_get_value(R_slider);
int g = jslider_get_value(G_slider);
int b = jslider_get_value(B_slider);
@ -750,7 +749,6 @@ static bool sliderRGB_change_hook(JWidget widget, void *data)
static bool sliderHSV_change_hook(JWidget widget, void *data)
{
Palette* palette = get_current_palette();
int h = jslider_get_value(H_slider);
int s = jslider_get_value(S_slider);
int v = jslider_get_value(V_slider);
@ -795,7 +793,6 @@ static bool entryRGB_change_hook(JWidget widget, void *data)
static bool entryHSV_change_hook(JWidget widget, void *data)
{
Palette* palette = get_current_palette();
int h = H_entry->getTextInt();
int s = S_entry->getTextInt();
int v = V_entry->getTextInt();

View File

@ -709,7 +709,7 @@ void color_to_formalstring(int imgtype, color_t color,
switch (GET_COLOR_TYPE(color)) {
case COLOR_TYPE_MASK:
uszprintf(buf, size, _("Mask"));
ustrncpy(buf, _("Mask"), size);
break;
case COLOR_TYPE_RGB:

View File

@ -968,7 +968,7 @@ static void write_compressed_image(FILE* f, Image* image)
int output_bytes = compressed.size() - zstream.avail_out;
if (output_bytes > 0) {
if ((fwrite(&compressed[0], 1, output_bytes, f) != output_bytes)
if ((fwrite(&compressed[0], 1, output_bytes, f) != (size_t)output_bytes)
|| ferror(f))
throw ase_exception("Error writing compressed image pixels.\n");
}

View File

@ -523,6 +523,9 @@ static void entry_execute_cmd(JWidget widget, EntryCmd::Type cmd,
switch (cmd) {
case EntryCmd::NoOp:
break;
case EntryCmd::InsertChar:
// delete the entire selection
if (selbeg >= 0) {

View File

@ -81,7 +81,7 @@ static int stream_string_tell(JStream stream);
JStream jstream_new(int size)
{
JStream stream = (JStream)jmalloc0(MAX(size, sizeof(struct jstream)));
JStream stream = (JStream)jmalloc0(MAX(size, (int)sizeof(struct jstream)));
if (!stream)
return NULL;

View File

@ -735,7 +735,7 @@ void jstandard_theme::draw_link_label(JWidget widget, JRect clip)
if (widget->hasMouseOver()) {
int w = jwidget_get_text_length(widget);
int h = jwidget_get_text_height(widget);
//int h = jwidget_get_text_height(widget);
hline(ji_screen,
widget->rc->x1, widget->rc->y2-1, widget->rc->x1+w-1, makecol(0, 0, 255));

View File

@ -841,7 +841,7 @@ void SkinneableTheme::draw_link_label(JWidget widget, JRect clip)
if (widget->hasMouseOver()) {
int w = jwidget_get_text_length(widget);
int h = jwidget_get_text_height(widget);
//int h = jwidget_get_text_height(widget);
hline(ji_screen,
widget->rc->x1, widget->rc->y2-1, widget->rc->x1+w-1, makecol(0, 0, 255));

View File

@ -144,7 +144,7 @@ public:
virtual void merge(const Image* src, int x, int y, int opacity, int blend_mode)
{
BLEND_COLOR blender = Traits::get_blender(blend_mode);
register int mask_color = src->mask_color;
register ase_uint32 mask_color = src->mask_color;
Image* dst = this;
address_t src_address;
address_t dst_address;

View File

@ -302,6 +302,9 @@ bool SortPalette::operator()(ase_uint32 c1, ase_uint32 c2)
value1 = v1;
value2 = v2;
break;
default:
ASSERT(false);
break;
}
break;
}

View File

@ -69,7 +69,7 @@ public:
private:
RGB_MAP* m_allegMap;
gfxobj_id m_palette_id;
size_t m_modifications;
int m_modifications;
};
//////////////////////////////////////////////////////////////////////

View File

@ -1808,7 +1808,7 @@ static UndoChunk* undo_chunk_new(UndoStream* stream, int type, int size)
{
UndoChunk* chunk;
ASSERT(size >= sizeof(UndoChunk));
ASSERT(size >= (int)sizeof(UndoChunk));
chunk = (UndoChunk* )jmalloc0(size);
if (!chunk)

View File

@ -86,7 +86,7 @@ void RecentFiles::addRecentFile(const char* filename)
// If the filename does not exist...
// Does the list is full?
if (recent_files.size() == recent_files_limit) {
if ((int)recent_files.size() == recent_files_limit) {
// Remove the last entry
recent_files.erase(--recent_files.end());
}

View File

@ -38,7 +38,7 @@ const char* ResourceFinder::first()
const char* ResourceFinder::next()
{
if (m_current == m_paths.size())
if (m_current == (int)m_paths.size())
return NULL;
return m_paths[m_current++].c_str();

View File

@ -309,8 +309,8 @@ static void ink_hline8_blur(int x1, int y, int x2, IToolLoop* loop)
static void ink_hline32_replace(int x1, int y, int x2, IToolLoop* loop)
{
int color1 = loop->getPrimaryColor();
int color2 = loop->getSecondaryColor();
ase_uint32 color1 = loop->getPrimaryColor();
ase_uint32 color2 = loop->getSecondaryColor();
int opacity = loop->getOpacity();
DEFINE_INK_PROCESSING_SRCDST

View File

@ -48,7 +48,7 @@
#include "widgets/colbar.h"
#include "widgets/statebar.h"
static ase_uint32 get_shift_from_mask(ase_uint32 mask);
//static ase_uint32 get_shift_from_mask(ase_uint32 mask);
#if defined ALLEGRO_WINDOWS
#include <winalleg.h>
@ -143,14 +143,14 @@ static bool copy_from_sprite(const Sprite* sprite)
return true;
}
static ase_uint32 get_shift_from_mask(ase_uint32 mask)
{
ase_uint32 shift = 0;
for (shift=0; shift<32; ++shift)
if (mask & (1 << shift))
return shift;
return shift;
}
// static ase_uint32 get_shift_from_mask(ase_uint32 mask)
// {
// ase_uint32 shift = 0;
// for (shift=0; shift<32; ++shift)
// if (mask & (1 << shift))
// return shift;
// return shift;
// }
bool clipboard::can_paste()
{

View File

@ -442,8 +442,6 @@ void RenderEngine::renderCheckedBackground(Image* image,
int zoom)
{
int x, y, u, v;
int tile_x = 0;
int tile_y = 0;
int tile_w = 16;
int tile_h = 16;
int c1 = get_color_for_image(image->imgtype, checked_bg_color1);

View File

@ -358,8 +358,8 @@ bool ColorBar::onProcessMessage(JMessage msg)
KB_SHIFT_FLAG)) == KB_CTRL_FLAG) {
int newColorsPerColumn = m_colorsPerColumn;
while (((int)m_entrySize) >= ENTRYSIZE_MIN &&
((int)m_entrySize) <= ENTRYSIZE_MAX &&
while (m_entrySize >= ENTRYSIZE_MIN &&
m_entrySize <= ENTRYSIZE_MAX &&
newColorsPerColumn == m_colorsPerColumn) {
// Increment or decrement m_entrySize until m_colorsPerColumnn changes
m_entrySize += delta;
@ -376,7 +376,7 @@ bool ColorBar::onProcessMessage(JMessage msg)
KB_SHIFT_FLAG)) == KB_ALT_FLAG) {
int old_columns = m_columns;
if (((int)m_columns)+delta < 1)
if (m_columns+delta < 1)
m_columns = 1;
else if (m_columns+delta > 4)
m_columns = 4;
@ -520,7 +520,7 @@ void ColorBar::setHotColor(hotcolor_t hot, color_t color)
}
}
Rect ColorBar::getColumnBounds(size_t column) const
Rect ColorBar::getColumnBounds(int column) const
{
Rect rc = getBounds().shrink(jguiscale());
Rect fgRc = getFgBounds();
@ -532,10 +532,10 @@ Rect ColorBar::getColumnBounds(size_t column) const
return rc;
}
Rect ColorBar::getEntryBounds(size_t index) const
Rect ColorBar::getEntryBounds(int index) const
{
size_t row = (index % m_colorsPerColumn);
size_t col = (index / m_colorsPerColumn);
int row = (index % m_colorsPerColumn);
int col = (index / m_colorsPerColumn);
Rect rc = getColumnBounds(col);
rc.h -= 2*jguiscale();

View File

@ -52,19 +52,19 @@ protected:
private:
int getEntriesCount() const { return m_columns*m_colorsPerColumn; }
color_t getEntryColor(size_t i) const { return color_index(i+m_firstIndex); }
color_t getEntryColor(int i) const { return color_index(i+m_firstIndex); }
color_t getHotColor(hotcolor_t hot);
void setHotColor(hotcolor_t hot, color_t color);
Rect getColumnBounds(size_t column) const;
Rect getEntryBounds(size_t index) const;
Rect getColumnBounds(int column) const;
Rect getEntryBounds(int index) const;
Rect getFgBounds() const;
Rect getBgBounds() const;
void updateStatusBar(color_t color, int msecs);
size_t m_firstIndex;
size_t m_columns;
size_t m_colorsPerColumn;
int m_firstIndex;
int m_columns;
int m_colorsPerColumn;
int m_entrySize;
color_t m_fgcolor;
color_t m_bgcolor;

View File

@ -286,7 +286,6 @@ static void colorselector_set_color2(JWidget widget, color_t color,
Model* exclude_this_model)
{
ColorSelector* colorselector = colorselector_data(widget);
int imgtype = app_get_current_image_type();
Model* m = colorselector->selected_model;
JWidget rgb_rslider = jwidget_find_name(widget, "rgb_r");
JWidget rgb_gslider = jwidget_find_name(widget, "rgb_g");
@ -367,7 +366,6 @@ static void colorselector_set_color2(JWidget widget, color_t color,
static void colorselector_set_paledit_index(JWidget widget, int index, bool select_index_entry)
{
ColorSelector* colorselector = colorselector_data(widget);
PalEdit* pal = static_cast<PalEdit*>(widget->findChild("pal"));
Widget* idx = widget->findChild("idx");
char buf[256];
@ -433,7 +431,6 @@ static bool slider_change_hook(JWidget widget, void* data)
{
Frame* window = static_cast<Frame*>(widget->getRoot());
ColorSelector* colorselector = colorselector_data(window);
PalEdit* pal = static_cast<PalEdit*>(window->findChild("pal"));
Model* m = colorselector->selected_model;
color_t color = colorselector->color;
int i, r, g, b;

View File

@ -279,7 +279,7 @@ void Editor::editor_draw_cursor(int x, int y, bool refresh)
->getToolSettings(current_tool);
int pen_color = get_pen_color(m_sprite);
int new_mask_color;
ase_uint32 new_mask_color;
Pen* pen = editor_get_current_pen();
// Create the extra cel to show the pen preview

View File

@ -1413,6 +1413,10 @@ bool Editor::onProcessMessage(JMessage msg)
switch (wheelAction) {
case WHEEL_NONE:
// Do nothing
break;
case WHEEL_FG:
if (m_state == EDITOR_STATE_STANDBY) {
int newIndex = 0;

View File

@ -101,7 +101,7 @@ int group_button_get_selected(JWidget group)
JWidget sel = find_selected(group);
if (sel)
return (size_t)sel->user_data[1];
return (int)sel->user_data[1];
else
return -1;
}
@ -110,7 +110,7 @@ void group_button_select(JWidget group, int index)
{
JWidget sel = find_selected(group);
if (!sel || (size_t)sel->user_data[1] != index) {
if (!sel || (int)sel->user_data[1] != index) {
sel->setSelected(false);
select_button(group, index);
}
@ -137,7 +137,7 @@ static int select_button(JWidget widget, int index)
JLink link;
if (widget->type == JI_RADIO) {
if ((size_t)widget->user_data[1] == index) {
if ((int)widget->user_data[1] == index) {
widget->setSelected(true);
return true;
}

View File

@ -339,6 +339,9 @@ bool Tabs::onProcessMessage(JMessage msg)
case JM_TIMER: {
switch (m_ani) {
case ANI_NONE:
// Do nothing
break;
case ANI_SCROLL: {
int dir = jmanager_get_capture() == m_button_left ? -1: 1;
setScrollX(m_scrollX + dir*8*msg->timer.count);

View File

@ -354,7 +354,7 @@ const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding )
}
else
{
while ( *p && IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' )
while ( ( *p && IsWhiteSpace( *p ) ) || *p == '\n' || *p =='\r' )
++p;
}