[atomix] Fixed compilation warnings
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [atomix] Fixed compilation warnings
- Date: Mon, 29 Aug 2016 23:23:55 +0000 (UTC)
commit 4a4e88965548d9428016f9024740799696d5f09f
Author: Robert Roth <robert roth off gmail com>
Date: Tue Aug 30 02:23:09 2016 +0300
Fixed compilation warnings
src/board-gtk.c | 48 ++++++++++++++++++++----------------------------
src/clock.c | 5 +++--
src/goal-view.c | 6 +++++-
src/goal.c | 10 +++++-----
src/level-manager.c | 4 ++--
src/main.c | 7 ++++---
src/playfield.c | 46 +++++++++++++++++++++-------------------------
src/tile.c | 5 ++++-
8 files changed, 64 insertions(+), 67 deletions(-)
---
diff --git a/src/board-gtk.c b/src/board-gtk.c
index 06dfe82..3013e95 100644
--- a/src/board-gtk.c
+++ b/src/board-gtk.c
@@ -86,7 +86,7 @@ static void render_tile (Tile *tile, gint row, gint col);
GtkWidget* create_tile (double x, double y, Tile *tile);
void move_item (GtkWidget *item, ItemDirection direc);
int move_item_anim (void *data);
-static GtkWidget *get_item_by_row_col (gint row, gint col);
+static GtkWidget *get_item_by_row_col (guint row, guint col);
static void selector_move_to (SelectorData *data, guint row, guint col);
static void selector_unselect (SelectorData *data);
@@ -99,7 +99,7 @@ static void selector_arrows_hide (SelectorData *data);
/* Function implementations */
-static GtkWidget *get_item_by_row_col (gint row, gint col)
+static GtkWidget *get_item_by_row_col (guint row, guint col)
{
gint width, height;
gint item_point_x, item_point_y;
@@ -167,10 +167,12 @@ void move_item (GtkWidget *item, ItemDirection direc)
case RIGHT:
tmp_col = tmp_col + 1;
break;
+ default:
+ break;
}
- if (tmp_row < 0 || tmp_row >= playfield_get_n_rows (board_sce) ||
- tmp_col < 0 || tmp_col >= playfield_get_n_cols (board_sce))
+ if (tmp_row >= playfield_get_n_rows (board_sce) ||
+ tmp_col >= playfield_get_n_cols (board_sce))
break;
tile = playfield_get_tile (board_sce, tmp_row, tmp_col);
@@ -220,7 +222,7 @@ void move_item (GtkWidget *item, ItemDirection direc)
}
int move_item_anim (void *data) {
- AnimData *anim_data = (AnimData *) data;
+ //AnimData *anim_data = (AnimData *) data;
gint x, y;
if (anim_data->counter > 0) {
@@ -437,8 +439,8 @@ void board_gtk_init (Theme * theme, gpointer canvas)
selector_data = selector_create ();
}
-void board_gtk_render () {
- gint row, col;
+void board_gtk_render (void) {
+ guint row, col;
Tile *tile;
g_return_if_fail (board_theme != NULL);
@@ -477,35 +479,25 @@ void board_gtk_render () {
}
static void render_tile (Tile *tile, gint row, gint col) {
- gboolean create = FALSE;
TileType type;
gint x, y;
type = tile_get_tile_type (tile);
switch (type) {
case TILE_TYPE_ATOM:
- create = TRUE;
- break;
-
case TILE_TYPE_WALL:
- create = TRUE;
- break;
-
case TILE_TYPE_SHADOW:
- create = TRUE;
+ convert_to_canvas (board_theme, board_env, row, col, &x, &y);
+ create_tile (x, y, tile);
break;
case TILE_TYPE_UNKNOWN:
case TILE_TYPE_FLOOR:
+ case TILE_TYPE_NONE:
+ case TILE_TYPE_LAST:
default:
break;
}
-
-
- if (create) {
- convert_to_canvas (board_theme, board_env, row, col, &x, &y);
- create_tile (x, y, tile);
- }
}
static void show_sensitive (GtkWidget *widget)
@@ -764,7 +756,7 @@ gboolean board_gtk_handle_key_event (GObject * canvas, GdkEventKey * event,
gpointer data)
{
GtkWidget *item;
- gint new_row, new_col;
+ guint new_row, new_col;
Tile *tile;
g_return_val_if_fail (selector_data != NULL, FALSE);
@@ -805,7 +797,7 @@ gboolean board_gtk_handle_key_event (GObject * canvas, GdkEventKey * event,
selector_data->mouse_steering = FALSE;
if (!selector_data->selected) {
new_col--;
- if (new_col >= 0) {
+ if (new_col < playfield_get_n_cols (board_env)) {
selector_show (selector_data);
selector_move_to (selector_data, new_row, new_col);
}
@@ -833,7 +825,7 @@ gboolean board_gtk_handle_key_event (GObject * canvas, GdkEventKey * event,
selector_data->mouse_steering = FALSE;
if (!selector_data->selected) {
new_row--;
- if (new_row >= 0) {
+ if (new_row < playfield_get_n_rows (board_env)) {
selector_show (selector_data);
selector_move_to (selector_data, new_row, new_col);
}
@@ -906,7 +898,7 @@ static void check_for_arrow (gint r, gint c, GtkWidget *arrow) {
static void selector_arrows_show (SelectorData *data)
{
- gint r, c;
+ guint r, c;
if (board_sce == NULL)
{
@@ -916,7 +908,7 @@ static void selector_arrows_show (SelectorData *data)
r = data->row - 1;
c = data->col;
- if (r >= 0)
+// if (r >= 0)
check_for_arrow (r, c, data->arrow_top);
r = data->row;
@@ -934,7 +926,7 @@ static void selector_arrows_show (SelectorData *data)
r = data->row;
c = data->col - 1;
- if (c >= 0)
+// if (c >= 0)
check_for_arrow (r, c, data->arrow_left);
if (data->mouse_steering)
@@ -950,9 +942,9 @@ static void selector_arrows_show (SelectorData *data)
static void selector_select (SelectorData *data, GtkWidget *item)
{
- g_return_if_fail (data != NULL);
gint x, y;
+ g_return_if_fail (data != NULL);
gtk_container_child_get (GTK_CONTAINER(board_canvas), item, "x", &x, "y", &y, NULL);
data->selected = TRUE;
diff --git a/src/clock.c b/src/clock.c
index 895508a..346e430 100644
--- a/src/clock.c
+++ b/src/clock.c
@@ -51,8 +51,9 @@ GType clock_get_type (void)
static void clock_destroy (GtkWidget *object)
{
- g_return_if_fail (object != NULL);
Clock *clock = CLOCK (object);
+
+ g_return_if_fail (object != NULL);
clock_stop (clock);
GTK_WIDGET_CLASS (parent_class)->destroy (object);
@@ -98,7 +99,7 @@ static gint clock_timer_callback (gpointer data)
return TRUE;
}
-GtkWidget *clock_new ()
+GtkWidget *clock_new (void)
{
Clock *clock = CLOCK (g_object_new (TYPE_CLOCK, NULL));
diff --git a/src/goal-view.c b/src/goal-view.c
index 6d03ea8..f67ec3b 100644
--- a/src/goal-view.c
+++ b/src/goal-view.c
@@ -50,7 +50,7 @@ void goal_view_render (Goal *goal)
static void render_view (Goal *goal)
{
PlayField *pf;
- gint row, col;
+ guint row, col;
gdouble x;
gdouble y;
Tile *tile;
@@ -86,6 +86,10 @@ static void render_view (Goal *goal)
case TILE_TYPE_WALL:
case TILE_TYPE_UNKNOWN:
+ case TILE_TYPE_NONE:
+ case TILE_TYPE_FLOOR:
+ case TILE_TYPE_SHADOW:
+ case TILE_TYPE_LAST:
default:
break;
}
diff --git a/src/goal.c b/src/goal.c
index bb2b4a0..9cc4dfa 100644
--- a/src/goal.c
+++ b/src/goal.c
@@ -145,7 +145,7 @@ static int find_tile (gconstpointer p1, gconstpointer p2)
Goal *goal_new (PlayField *pf)
{
Goal *goal;
- gint row, col;
+ guint row, col;
Tile *tile;
goal = GOAL (g_object_new (GOAL_TYPE, NULL));
@@ -218,8 +218,8 @@ gboolean goal_reached (Goal *goal, PlayField *pf,
TileData *td;
TileData pattern;
PositionOffset *po;
- gint start_row;
- gint start_col;
+ guint start_row;
+ guint start_col;
g_return_val_if_fail (IS_GOAL (goal), FALSE);
g_return_val_if_fail (goal->priv->index != NULL, FALSE);
@@ -245,8 +245,8 @@ gboolean goal_reached (Goal *goal, PlayField *pf,
start_row = row_anchor - po->vert;
start_col = col_anchor - po->horiz;
- if (start_row >= 0 && start_row < playfield_get_n_rows (pf) &&
- start_col >= 0 && start_col < playfield_get_n_cols (pf))
+ if (start_row < playfield_get_n_rows (pf) &&
+ start_col < playfield_get_n_cols (pf))
{
comp_res =
compare_playfield_with_goal (goal, pf, start_row, start_col);
diff --git a/src/level-manager.c b/src/level-manager.c
index fd19f82..ca1101b 100644
--- a/src/level-manager.c
+++ b/src/level-manager.c
@@ -151,13 +151,13 @@ static GMarkupParser sequence_parser =
static void create_level_sequence (LevelManager *lm, gchar *file)
{
- g_return_if_fail (IS_LEVEL_MANAGER (lm));
-
GFile *sequence_file;
gchar *sequence_contents;
gsize sequence_length;
GMarkupParseContext *parse_context;
+ g_return_if_fail (IS_LEVEL_MANAGER (lm));
+
if (!g_file_test (file, G_FILE_TEST_IS_REGULAR)) {
g_warning ("File not found: %s.", file);
return;
diff --git a/src/main.c b/src/main.c
index d2342a1..cd9bab8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -222,6 +222,8 @@ static void controller_handle_action (GameAction action)
board_gtk_undo_move ();
break;
+ case GAME_ACTION_NEW:
+ case GAME_ACTION_CONTINUE:
default:
break;
}
@@ -374,7 +376,7 @@ static gboolean on_key_press_event (GObject *widget, GdkEventKey *event,
return FALSE;
}
-static void game_init ()
+static void game_init (void)
{
g_return_if_fail (app != NULL);
@@ -488,7 +490,7 @@ static void update_statistics (void)
typedef struct
{
- gchar *cmd;
+ const gchar *cmd;
gboolean enabled;
} CmdEnable;
@@ -583,7 +585,6 @@ void update_menu_item_state (void)
-------------------------------------------------------------- */
static AtomixApp *create_gui (GApplication *app_instance)
{
- AtomixApp *app;
gchar *ui_path;
GtkBuilder *builder;
GtkWidget *stats_grid;
diff --git a/src/playfield.c b/src/playfield.c
index 7942adf..90dc888 100644
--- a/src/playfield.c
+++ b/src/playfield.c
@@ -22,7 +22,7 @@
#include <string.h>
Tile *get_tile (PlayField *pf, gint row, gint col);
-void set_tile (PlayField *pf, gint row, gint col, Tile *tile);
+void set_tile (PlayField *pf, guint row, guint col, Tile *tile);
static GObjectClass *parent_class = NULL;
@@ -102,7 +102,7 @@ static void playfield_init (PlayField *pf)
static void playfield_finalize (GObject *object)
{
- gint row, col;
+ guint row, col;
PlayField *pf = PLAYFIELD (object);
#ifdef DEBUG
@@ -142,7 +142,7 @@ Tile *get_tile (PlayField *pf, gint row, gint col)
return priv->matrix[row * priv->n_cols + col];
}
-void set_tile (PlayField *pf, gint row, gint col, Tile *new_tile)
+void set_tile (PlayField *pf, guint row, guint col, Tile *new_tile)
{
Tile *tile;
PlayFieldPrivate *priv;
@@ -218,8 +218,8 @@ void playfield_add_column (PlayField *pf)
void playfield_set_matrix_size (PlayField *pf, guint n_rows, guint n_cols)
{
- gint row = 0;
- gint col = 0;
+ guint row = 0;
+ guint col = 0;
guint old_n_rows;
guint old_n_cols;
Tile **new_matrix;
@@ -264,7 +264,7 @@ void playfield_set_matrix_size (PlayField *pf, guint n_rows, guint n_cols)
PlayField *playfield_copy (PlayField *pf)
{
PlayField *pf_copy = NULL;
- gint row, col;
+ guint row, col;
gint matrix_size;
g_return_val_if_fail (IS_PLAYFIELD (pf), NULL);
@@ -289,7 +289,7 @@ void playfield_swap_tiles (PlayField *pf, guint src_row, guint src_col,
{
Tile *src_tile;
Tile *dest_tile;
- gint n_rows, n_cols;
+ guint n_rows, n_cols;
g_return_if_fail (IS_PLAYFIELD (pf));
@@ -336,7 +336,7 @@ Tile *playfield_clear_tile (PlayField *pf, guint row, guint col)
void playfield_clear (PlayField *pf)
{
- gint row, col;
+ guint row, col;
g_return_if_fail (IS_PLAYFIELD (pf));
@@ -348,12 +348,12 @@ void playfield_clear (PlayField *pf)
PlayField *playfield_strip (PlayField *pf)
{
PlayField *stripped_pf;
- gint row, col;
- gint n_rows, n_cols;
- gint max_row = 0;
- gint min_row = 10000;
- gint max_col = 0;
- gint min_col = 10000;
+ guint row, col;
+ guint n_rows, n_cols;
+ guint max_row = 0;
+ guint min_row = 10000;
+ guint max_col = 0;
+ guint min_col = 10000;
g_return_val_if_fail (IS_PLAYFIELD (pf), NULL);
@@ -424,7 +424,7 @@ void playfield_set_tile (PlayField *pf, guint row, guint col, Tile *tile)
void playfield_print (PlayField *pf)
{
PlayFieldPrivate *priv;
- int row, col;
+ guint row, col;
Tile *tile;
g_return_if_fail (IS_PLAYFIELD (pf));
@@ -458,7 +458,7 @@ void playfield_print (PlayField *pf)
typedef struct
{
GQuark id;
- gchar *string;
+ const gchar *string;
} TranslationItem;
static TranslationItem wall_map[] =
@@ -521,15 +521,11 @@ static const offset env_offset[8] =
{-1, -1} /* ENV_TOP_LEFT */
};
-static TileType get_env_tile_type (PlayField *pf, gint row, gint col)
+static TileType get_env_tile_type (PlayField *pf, guint row, guint col)
{
Tile *tile;
TileType type = TILE_TYPE_NONE;
- if (row < 0)
- return type;
- if (col < 0)
- return type;
if (row >= playfield_get_n_rows (pf))
return type;
if (col >= playfield_get_n_cols (pf))
@@ -591,14 +587,14 @@ PlayField *playfield_generate_environment (PlayField *pf, Theme *theme)
{
PlayField *env_pf;
PlayFieldPrivate *priv;
- gint row, col;
+ guint row, col;
gint tile_env[8];
Tile *env_tile;
Tile *tile = NULL;
gint n_decor_tiles;
gint max_try;
- gint min_wall[2];
- gint max_wall[2];
+ guint min_wall[2];
+ guint max_wall[2];
g_return_val_if_fail (IS_PLAYFIELD (pf), NULL);
@@ -720,7 +716,7 @@ PlayField *playfield_generate_shadow (PlayField *pf)
{
PlayField *env_pf;
PlayFieldPrivate *priv;
- gint row, col;
+ guint row, col;
gint tile_env[8];
Tile *env_tile;
Tile *tile;
diff --git a/src/tile.c b/src/tile.c
index 8cdad69..a090ff5 100644
--- a/src/tile.c
+++ b/src/tile.c
@@ -243,7 +243,7 @@ void tile_set_tile_type (Tile *tile, TileType type)
void tile_print (Tile *tile)
{
- gchar *type_str;
+ const gchar *type_str;
g_return_if_fail (IS_TILE (tile));
@@ -265,6 +265,9 @@ void tile_print (Tile *tile)
type_str = "FLOR";
break;
+ case TILE_TYPE_SHADOW:
+ case TILE_TYPE_UNKNOWN:
+ case TILE_TYPE_LAST:
default:
type_str = "UKWN";
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]