antiright-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Antiright-devel] antiright/gtkshell Makefile callbacks.c dialog_...


From: Jeffrey Bedard
Subject: [Antiright-devel] antiright/gtkshell Makefile callbacks.c dialog_...
Date: Thu, 22 Feb 2007 22:13:03 +0000

CVSROOT:        /sources/antiright
Module name:    antiright
Changes by:     Jeffrey Bedard <jefbed> 07/02/22 22:13:02

Modified files:
        gtkshell       : Makefile callbacks.c dialog_options.c 
                         gtkshell.c gtkshell.h options.c updated.c 
                         updated.h 

Log message:
        Added lint target to gtkshell Makefile.  This requires 'splint'.
        Began resolution of problems reported.  Began change from
        assertion checks to warnings and function cancelation on test
        failure.  Use stronger typing for updater structure.  

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/Makefile?cvsroot=antiright&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/callbacks.c?cvsroot=antiright&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/dialog_options.c?cvsroot=antiright&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/gtkshell.c?cvsroot=antiright&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/gtkshell.h?cvsroot=antiright&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/options.c?cvsroot=antiright&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/updated.c?cvsroot=antiright&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/updated.h?cvsroot=antiright&r1=1.3&r2=1.4

Patches:
Index: Makefile
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/Makefile,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- Makefile    11 Feb 2007 04:23:30 -0000      1.5
+++ Makefile    22 Feb 2007 22:13:02 -0000      1.6
@@ -1,18 +1,29 @@
 include ../config.mk
 
 #CFLAGS+=`pkg-config --cflags gtk+-2.0` -g3 -Wall -W -Werror
-CFLAGS+=`pkg-config --cflags gtk+-2.0` $(DEFS)
+GTKFLAGS=`pkg-config --cflags gtk+-2.0` 
+CFLAGS+=$(GTKFLAGS) $(DEFS)
 LDFLAGS+=-L../libantiright -lantiright
 LDFLAGS+=`pkg-config --libs gtk+-2.0`
+#LDFLAGS+=-lefence
 
 objects=gtkshell.o arguments.o options.o callbacks.o updated.o\
        label.o button.o text.o updated_label.o updated_progress.o\
        updated_options.o add_options.o option_options.o dialog_options.o\
        file_dialog.o row.o containers.o geometry.o
+
+sources=gtkshell.c arguments.c options.c callbacks.c updated.c\
+                               label.c button.c text.c updated_label.c 
updated_progress.c\
+                               updated_options.c add_options.c 
option_options.c dialog_options.c\
+                               file_dialog.c row.c containers.c geometry.c
+
 all: $(objects) main.o
        $(CC) -o gtkshell $(objects) main.o $(LDFLAGS)
        ar rcs libgtkshell.a $(objects)
 
+lint: $(sources)
+                               splint `pkg-config --cflags-only-I gtk+-2.0` 
$(sources) > lint.out
+
 clean:
        rm -f gtkshell *.o libgtkshell.a
 install:

Index: callbacks.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/callbacks.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- callbacks.c 21 Feb 2007 21:39:50 -0000      1.8
+++ callbacks.c 22 Feb 2007 22:13:02 -0000      1.9
@@ -30,9 +30,10 @@
   ARBUG("gsh_test_exit()");
 #endif /* DEBUG */
 
-  g_assert(gsh);
-  if (gsh->flags.button_exits)
-    exit (0);
+       /* Seemingly redundant check is performed 
+        * as gboolean is not native type.  */
+  if ((gsh != NULL) && (gsh->flags.button_exits == TRUE))
+    exit (EXIT_SUCCESS);
 
 #ifdef DEBUG
   ARBUG("==>made it past exit");
@@ -52,9 +53,15 @@
   UNUSED (widget);
 
   g_assert(cb);
-
-  antiright_system (cb->data);
+       if(cb != NULL)
+               {
+               (void)antiright_system (cb->data);
   gsh_test_exit (cb->gsh);
+               }
+       else
+               {
+                       ARWARN("callback NULL");
+               }
 }
 
 void
@@ -65,19 +72,24 @@
 
   cb = (struct GSH_CBData *) data;
 
-  g_assert(widget);
-
+       if(widget != NULL)
+               {
   input = gtk_entry_get_text (GTK_ENTRY (widget));
 
-  g_assert(cb);
-
-  if (cb->gsh->flags.prompt_echoes)
+                       if(cb != NULL)
+                               {
+                                       if (cb->gsh->flags.prompt_echoes == 
TRUE)
     g_print ("%s\n", input);
   else
     sysprintf ("%s %s", (char *) cb->data, (char *) input);
 
-  if (cb->gsh->flags.button_exits)
-    exit (0);
+                                       gsh_test_exit(cb->gsh);
+                               }
+                       else
+                               ARWARN("callback data is NULL, no action 
taken");
 
   gtk_entry_set_text (GTK_ENTRY (widget), ""); /* Clear.  */
+               }
+       else
+               ARWARN("widget is NULL, no action taken");
 }

Index: dialog_options.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/dialog_options.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- dialog_options.c    20 Feb 2007 04:29:43 -0000      1.6
+++ dialog_options.c    22 Feb 2007 22:13:02 -0000      1.7
@@ -60,7 +60,7 @@
 
   exit (0);
 }
-
+#define ARNOP(x)
 void
 gsh_color_dialog ()
 {
@@ -70,15 +70,16 @@
 
   if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
   {
-    GdkColor *color;
+    GdkColor color;
 
     gtk_color_selection_get_current_color (
                                           GTK_COLOR_SELECTION (
                                         GTK_COLOR_SELECTION_DIALOG (dialog)
                                                                ->colorsel),
-                                          color);
+                                          &color);
+
+    g_print ("#%x%x%x\n", color.red, color.green, color.blue);
 
-    g_print ("#%x%x%x\n", color->red, color->green, color->blue);
   }
 
   exit (0);

Index: gtkshell.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/gtkshell.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- gtkshell.c  21 Feb 2007 21:39:50 -0000      1.12
+++ gtkshell.c  22 Feb 2007 22:13:02 -0000      1.13
@@ -29,9 +29,11 @@
 
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 
-  g_signal_connect (window, "delete-event",
+       /address@hidden@*/
+  (void)g_signal_connect (window, "delete-event",
                    G_CALLBACK (gtk_main_quit), NULL);
-  g_signal_connect (window, "destroy",
+       /address@hidden@*/
+  (void)g_signal_connect (window, "destroy",
                    G_CALLBACK (gtk_main_quit), NULL);
 
   return (window);
@@ -55,12 +57,16 @@
 gsh_GSH_Updater (struct GSH_Updater * update)
 {
   update->period = 1000;
-  update->list = NULL;
+
+       /* Pointer must have not previously been used.  */
+       /address@hidden@*/
+  update->list = (GSList *)NULL;
 }
 void
 gsh_GSH (struct GSH * gsh)
 {
-  gsh->geometry = NULL;
+       /address@hidden/
+  gsh->geometry = (gchar *)NULL;
   gsh_GSH_Flags (&gsh->flags);
   gsh_GSH_Rows (&gsh->rows);
   gsh_GSH_Updater (&gsh->update);

Index: gtkshell.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/gtkshell.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- gtkshell.h  20 Feb 2007 04:29:43 -0000      1.13
+++ gtkshell.h  22 Feb 2007 22:13:02 -0000      1.14
@@ -25,6 +25,8 @@
 
 #include <gtk/gtk.h>
 #include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
 #include "../libantiright/library.h"
 
 struct GSH_Flags

Index: options.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/options.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- options.c   20 Feb 2007 04:29:43 -0000      1.5
+++ options.c   22 Feb 2007 22:13:02 -0000      1.6
@@ -1,6 +1,6 @@
 /*
   AntiRight
-  (c) 2002-2006 Jeffrey Bedard
+  (c) 2002-2007 Jeffrey Bedard
   address@hidden
 
   This file is part of AntiRight.
@@ -49,8 +49,8 @@
     break;
   case 'h':
     g_printerr ("Read the source code.\n");
-    exit (1);
-    break;
+    exit (EXIT_FAILURE);
+               /* Following is unreachable if EXIT.  */
   case 'o':
     gsh_handle_option_arguments (gsh,
                                 argc,

Index: updated.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/updated.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- updated.c   21 Feb 2007 21:39:50 -0000      1.6
+++ updated.c   22 Feb 2007 22:13:02 -0000      1.7
@@ -31,15 +31,8 @@
   ARBUG ("gsh_append_updater()");
 #endif                         /* DEBUG */
 
-  g_assert(gsh);
-  /* g_assert(gsh->update.list); */
-  g_assert(item);
-
-#ifdef DEBUG
-  ARBUG("assertions passed");
-#endif /* DEBUG */
-
-  gsh->update.list = g_slist_append (gsh->update.list, item);
+       if ((gsh != NULL) && (item != NULL))
+       gsh->update.list = g_slist_prepend (gsh->update.list, item);
 
 #ifdef DEBUG
   ARBUG ("end gsh_append_updater()");
@@ -49,8 +42,8 @@
 void
 gsh_assign_updater (
                    gsh_updater_data * item,
-                   void (*function) (char *, void *),
-                   char *command, void *widget)
+                   void (*function) (gchar *, gpointer),
+                   gchar *command, GtkWidget *widget)
 {
   /* Assign the values to ITEM's members.  */
 
@@ -65,8 +58,8 @@
 void
 gsh_add_updater (
                 struct GSH * gsh,
-                void (*function) (char *, void *),
-                char *command, void *widget)
+                void (*function) (gchar *, gpointer),
+                gchar *command, GtkWidget *widget)
 {
   gsh_updater_data *item;
 
@@ -88,12 +81,17 @@
 
   /* Ensure that the argument containing the structure is not empty.  */
 
-  assert (data);
-
-  /* Assign data to structure and call function pointer with parameters.  */
-
+       if(data != NULL)
+               {
+               /* Assign data to structure and call 
+                        * function pointer with parameters.  */
   item = (gsh_updater_data *) data;
   item->function (item->command, item->widget);
+               }
+       else
+               {
+                       ARWARN("data is NULL, operation not performed");
+               }
 }
 
 gint
@@ -105,16 +103,16 @@
   ARBUG ("gsh_perform_updates()");
 #endif                         /* DEBUG */
 
-  g_assert(data);
-
   gsh = (struct GSH *) data;
 
 
-#ifdef DEBUG
-  g_assert (gsh->update.list);
-#endif                         /* DEBUG */
-
+       if((gsh != NULL) && (gsh->update.list != NULL))
   g_slist_foreach (gsh->update.list, gsh_update_each, gsh);
+       else
+               {
+                       ARWARN("data invalid, operation not performed.");
+                       return FALSE;
+               }
 
   return (TRUE);
 }
@@ -126,7 +124,13 @@
 #ifdef DEBUG
   ARBUG ("gsh_start_updates()");
 #endif                         /* DEBUG */
-
-  gsh_perform_updates (gsh);
-  g_timeout_add (gsh->update.period, gsh_perform_updates, gsh);
+       if(gsh != NULL)
+               {
+               (void)gsh_perform_updates (gsh);
+               (void)g_timeout_add (gsh->update.period, gsh_perform_updates, 
gsh);
+               }
+       else
+               {
+                       ARWARN("application structure invalid, operation not 
performed");
+               }
 }

Index: updated.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/updated.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- updated.h   20 Feb 2007 04:29:43 -0000      1.3
+++ updated.h   22 Feb 2007 22:13:02 -0000      1.4
@@ -25,15 +25,15 @@
 
 typedef struct
 {
-  void (*function) (char *, void *);
-  char *command;
-  void *widget;
+  void (*function) (gchar *, gpointer);
+  gchar *command;
+  GtkWidget *widget;
 } gsh_updater_data;
 
 void
 gsh_add_updater (struct GSH * gsh,
-                void (*function) (char *, void *),
-                char *command, void *widget);
+                void (*function) (char *, gpointer),
+                gchar *command, GtkWidget *widget);
 
   void
     gsh_start_updates (struct GSH * gsh);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]