From 371d4c3202de9fa52ab0ffd0a5726a18e0479a12 Mon Sep 17 00:00:00 2001
From: Bradley Smith
Date: Fri, 7 Mar 2008 18:46:31 +0000
Subject: Add -pedantic-errors and -Werror flags to compile, and fix code to
 comply.

Signed-off-by: Bradley Smith <brad@brad-smith.co.uk>
---
 configure.ac       |  2 ++
 lib/cursesplugin.c | 10 +++++-----
 lib/textplugin.c   |  5 +++--
 lib/x11plugin.c    | 16 ++++++++++------
 src/Makefile.am    |  1 -
 src/main.c         |  4 ++--
 6 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/configure.ac b/configure.ac
index 95835bb..9addd68 100644
--- a/configure.ac
+++ b/configure.ac
@@ -129,6 +129,8 @@ AC_CHECK_HEADERS(unistd.h)
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
 
+CFLAGS="-pedantic-errors -Werror"
+
 dnl Done.
 AC_CONFIG_FILES([Makefile
  contrib/Makefile
diff --git a/lib/cursesplugin.c b/lib/cursesplugin.c
index a3f08ad..872ad15 100644
--- a/lib/cursesplugin.c
+++ b/lib/cursesplugin.c
@@ -130,6 +130,7 @@ curses_plugin_constructor (GType type,
 {
   GObject *object;
   CursesPlugin *curses;
+  gint color_pair;
 
   /* Chain up to the parent first */
   object = parent_class->constructor (type, n_construct_properties, construct_properties);
@@ -137,8 +138,6 @@ curses_plugin_constructor (GType type,
   curses = CURSES_PLUGIN (object);
 
   /* Initialize curses mode */
-  gint color_pair;
-
   curses->win = initscr ();
 
   cbreak ();
@@ -147,7 +146,7 @@ curses_plugin_constructor (GType type,
   scrollok (curses->win, TRUE); 	/* Put scrolling on */
   setscrreg (LINES - 2, LINES - 1);	/* Where to scroll  */
 
-  //clearok (stdscr, TRUE);
+  /* clearok (stdscr, TRUE); */
   nonl ();
   intrflush (stdscr, FALSE);
   keypad (stdscr, TRUE);
@@ -262,6 +261,8 @@ curses_plugin_get_property (GObject * object, guint prop_id,
 UserInterface *
 user_interface_new (Map *map, GType parent_type)
 {
+  CursesPlugin *curses;
+
   g_return_val_if_fail (map != NULL, NULL);
   g_return_val_if_fail (_parent_type != 0 || parent_type != 0, NULL);
 
@@ -269,8 +270,7 @@ user_interface_new (Map *map, GType parent_type)
      _parent_type = parent_type;
   }
 
-  CursesPlugin *curses =
-  	CURSES_PLUGIN (g_object_new (curses_plugin_get_type (),
+  curses = CURSES_PLUGIN (g_object_new (curses_plugin_get_type (),
 				  "map", map,
 				  NULL));
   if (curses->errors) {
diff --git a/lib/textplugin.c b/lib/textplugin.c
index 32a5a56..da08710 100644
--- a/lib/textplugin.c
+++ b/lib/textplugin.c
@@ -227,6 +227,8 @@ text_plugin_get_property (GObject * object, guint prop_id,
 UserInterface *
 user_interface_new (Map *map, GType parent_type)
 {
+  TextPlugin *text;
+
   g_return_val_if_fail (map != NULL, NULL);
   g_return_val_if_fail (_parent_type != 0 || parent_type != 0, NULL);
 
@@ -234,8 +236,7 @@ user_interface_new (Map *map, GType parent_type)
      _parent_type = parent_type;
   }
 
-  TextPlugin *text =
-  	TEXT_PLUGIN (g_object_new (text_plugin_get_type (),
+  text = TEXT_PLUGIN (g_object_new (text_plugin_get_type (),
 				  "map", map,
 				  NULL));
   if (text->errors) {
diff --git a/lib/x11plugin.c b/lib/x11plugin.c
index d40efd9..4585be5 100644
--- a/lib/x11plugin.c
+++ b/lib/x11plugin.c
@@ -22,6 +22,8 @@
 
 #include <glib.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include "configs.h"
 #include "x11plugin.h"
 
@@ -210,17 +212,18 @@ x11_plugin_constructor (GType type,
 
   setup_winbuf (x11);
 
-  //update_status ("Welcome to GNU Robots");
+  /* update_status ("Welcome to GNU Robots"); */
   x11->errors = 0;
 
   return object;
 }
 
-static void 
+static void
 x11_plugin_dispose (GObject * object)
 {
-  X11Plugin *x11 = X11_PLUGIN (object);
- 
+  X11Plugin *x11;
+  x11 = X11_PLUGIN (object);
+
   if (x11->map != NULL) {
     g_object_unref (G_OBJECT (x11->map));
 
@@ -315,6 +318,8 @@ x11_plugin_get_property (GObject * object, guint prop_id,
 UserInterface *
 user_interface_new (Map *map, GType parent_type)
 {
+  X11Plugin *x11;
+
   g_return_val_if_fail (map != NULL, NULL);
   g_return_val_if_fail (_parent_type != 0 || parent_type != 0, NULL);
 
@@ -322,8 +327,7 @@ user_interface_new (Map *map, GType parent_type)
      _parent_type = parent_type;
   }
 
-  X11Plugin *x11 =
-  	X11_PLUGIN (g_object_new (x11_plugin_get_type (),
+  x11 = X11_PLUGIN (g_object_new (x11_plugin_get_type (),
 				  "map", map,
 				  NULL));
   if (x11->errors) {
diff --git a/src/Makefile.am b/src/Makefile.am
index 47d7f3b..cab2e16 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,4 +9,3 @@ INCLUDES = $(GLIB2_CFLAGS) $(GUILE_CFLAGS) -I$(top_builddir)/include \
 
 grobots_SOURCES = main.c api.c sign.c map.c grobot.c userinterface.c
 grobots_LDFLAGS = $(GLIB2_LIBS) $(GUILE_LDFLAGS) -lltdl
-
diff --git a/src/main.c b/src/main.c
index 8c2d683..0359ba3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -54,7 +54,7 @@
 
 /* Globals (share with api.c) */
 GList *robots = NULL;
-GRobot *robot = NULL;       // The current robot
+GRobot *robot = NULL;       /* The current robot */
 UserInterface *ui;
 Map *map;
 GModule *plugin;
@@ -500,7 +500,7 @@ exit_nicely ()
         "energy", &energy,
         "units", &units, "shots", &shots, "score", &score, NULL);
 
-  g_list_foreach (robots, g_object_unref, NULL);
+  g_list_foreach (robots, (GFunc)g_object_unref, NULL);
   g_list_free (robots);
 
   /* unload the plugin */
-- 
cgit v1.1