From 321aff454c80b141d1d85fc1e3ea0c4eb05ab437 Mon Sep 17 00:00:00 2001
From: Ben Pfaff <blp@gnu.org>
Date: Wed, 10 May 2006 04:11:07 +0000
Subject: [PATCH] Add WARN_UNUSED_RESULT to procedure function prototypes and
 fix up one user who needed it.

---
 src/data/ChangeLog   |  5 +++++
 src/data/procedure.h | 14 ++++++++++----
 src/math/ChangeLog   |  5 +++++
 src/math/sort.c      |  7 +++++--
 4 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/src/data/ChangeLog b/src/data/ChangeLog
index fa71f5981e..87fb23ee78 100644
--- a/src/data/ChangeLog
+++ b/src/data/ChangeLog
@@ -1,3 +1,8 @@
+Tue May  9 21:09:17 2006  Ben Pfaff  <blp@gnu.org>
+
+	* procedure.h: Add WARN_UNUSED_RESULT to procedure function
+	prototypes.
+
 Tue May  9 21:08:05 2006  Ben Pfaff  <blp@gnu.org>
 
 	* casefile.c: Convert many uses of `int' to `bool'.
diff --git a/src/data/procedure.h b/src/data/procedure.h
index 3c43e71217..35678ce604 100644
--- a/src/data/procedure.h
+++ b/src/data/procedure.h
@@ -22,7 +22,9 @@
 
 #include <time.h>
 #include <stdbool.h>
+
 #include <data/transformations.h>
+#include <libpspp/compiler.h>
 
 struct ccase;
 struct casefile;
@@ -63,17 +65,21 @@ void proc_set_sink (struct case_sink *);
 struct casefile *proc_capture_output (void);
 
 bool procedure (bool (*proc_func) (const struct ccase *, void *),
-                void *aux);
+                void *aux)
+     WARN_UNUSED_RESULT;
 bool procedure_with_splits (void (*begin_func) (const struct ccase *, void *),
                             bool (*proc_func) (const struct ccase *, void *),
                             void (*end_func) (void *),
-                            void *aux);
+                            void *aux)
+     WARN_UNUSED_RESULT;
 bool multipass_procedure (bool (*proc_func) (const struct casefile *, void *),
-                          void *aux);
+                          void *aux)
+     WARN_UNUSED_RESULT;
 bool multipass_procedure_with_splits (bool (*) (const struct ccase *,
                                                 const struct casefile *,
                                                 void *),
-                                      void *aux);
+                                      void *aux)
+     WARN_UNUSED_RESULT;
 time_t time_of_last_procedure (void);
 
 /* Number of cases to lag. */
diff --git a/src/math/ChangeLog b/src/math/ChangeLog
index c78f51a858..b36a84407f 100644
--- a/src/math/ChangeLog
+++ b/src/math/ChangeLog
@@ -1,3 +1,8 @@
+Tue May  9 21:09:37 2006  Ben Pfaff  <blp@gnu.org>
+
+	* sort.c (sort_active_file_to_casefile): Check return value of
+	multipass_procedure().
+
 Wed May  3 23:06:43 2006  Ben Pfaff  <blp@gnu.org>
 
 	Continue reforming procedure execution.  In this phase, get rid of
diff --git a/src/math/sort.c b/src/math/sort.c
index 310fae9c1b..01e955334c 100644
--- a/src/math/sort.c
+++ b/src/math/sort.c
@@ -112,8 +112,11 @@ sort_active_file_to_casefile (const struct sort_criteria *criteria)
 
   cb_data.criteria = criteria;
   cb_data.output = NULL;
-  multipass_procedure (sort_to_casefile_callback, &cb_data);
-
+  if (!multipass_procedure (sort_to_casefile_callback, &cb_data)) 
+    {
+      casefile_destroy (cb_data.output);
+      return NULL;
+    }
   return cb_data.output;
 }
 
-- 
2.30.2