OSSP CVS Repository

ossp - Check-in [4250]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 4250
Date: 2001-Aug-01 11:55:58 (local)
2001-Aug-01 09:55:58 (UTC)
User:simons
Branch:callback-semantic-rewrite
Comment: Added xds_check_parameter() macro to short-cut the assert() and if-statements at the begining of every routine. Also rewrote some modules to take advantage of that macro.
Tickets:
Inspections:
Files:
ossp-pkg/xds/find-engine.c      1.3 -> 1.3.2.1     3 inserted, 3 deleted
ossp-pkg/xds/getbuffer.c      1.2 -> 1.2.2.1     4 inserted, 6 deleted
ossp-pkg/xds/internal.h      1.7 -> 1.7.2.1     8 inserted, 0 deleted
ossp-pkg/xds/register.c      1.6 -> 1.6.2.1     3 inserted, 5 deleted
ossp-pkg/xds/set-capacity.c      1.3 -> 1.3.2.1     4 inserted, 4 deleted
ossp-pkg/xds/setbuffer.c      1.6 -> 1.6.2.1     3 inserted, 6 deleted
ossp-pkg/xds/unregister.c      1.4 -> 1.4.2.1     2 inserted, 4 deleted
ossp-pkg/xds/vdecode.c      1.4 -> 1.4.2.1     2 inserted, 4 deleted
ossp-pkg/xds/vencode.c      1.12 -> 1.12.2.1     3 inserted, 5 deleted

ossp-pkg/xds/find-engine.c 1.3 -> 1.3.2.1

--- find-engine.c        2001/07/18 17:49:51     1.3
+++ find-engine.c        2001/08/01 09:55:58     1.3.2.1
@@ -35,9 +35,9 @@
 
     /* Sanity checks. */
 
-    assert(engines != NULL || last == 0);
-    assert(name != NULL);
-    assert(pos != NULL);
+    xds_check_parameter(engines != NULL || last == 0);
+    xds_check_parameter(name != NULL);
+    xds_check_parameter(pos != NULL);
 
     /* Use binary search to find "name" in "engines". */
 


ossp-pkg/xds/getbuffer.c 1.2 -> 1.2.2.1

--- getbuffer.c  2001/07/09 17:22:03     1.2
+++ getbuffer.c  2001/08/01 09:55:58     1.2.2.1
@@ -32,12 +32,10 @@
     {
     /* Sanity checks. */
 
-    assert(xds != NULL);
-    assert(flag == XDS_GIFT || flag == XDS_LOAN);
-    assert(buffer != NULL);
-    assert(buffer_len != NULL);
-    if (xds == NULL || buffer == NULL || buffer_len == NULL || (flag != XDS_GIFT && flag != XDS_LOAN))
-        return XDS_ERR_INVALID_ARG;
+    xds_check_parameter(xds != NULL);
+    xds_check_parameter(flag == XDS_GIFT || flag == XDS_LOAN);
+    xds_check_parameter(buffer != NULL);
+    xds_check_parameter(buffer_len != NULL);
 
     /* Return the buffer to the caller. */
 


ossp-pkg/xds/internal.h 1.7 -> 1.7.2.1

--- internal.h   2001/07/31 15:27:45     1.7
+++ internal.h   2001/08/01 09:55:58     1.7.2.1
@@ -66,4 +66,12 @@
 extern const char xds_xml_begin_text[];
 extern const char xds_xml_end_text[];
 
+#define xds_check_parameter(condition)    \
+    do                                    \
+    {                                     \
+    assert(condition);                    \
+    if (!(condition))                     \
+        return XDS_ERR_INVALID_ARG;       \
+    } while(XDS_FALSE)
+
 #endif /* !defined(__INTERNAL_H__) */


ossp-pkg/xds/register.c 1.6 -> 1.6.2.1

--- register.c   2001/07/09 17:23:38     1.6
+++ register.c   2001/08/01 09:55:58     1.6.2.1
@@ -37,11 +37,9 @@
 
     /* Sanity checks. */
 
-    assert(xds != NULL);
-    assert(name != NULL);
-    assert(engine != NULL);
-    if (xds == NULL || name == NULL || engine == NULL)
-        return XDS_ERR_INVALID_ARG;
+    xds_check_parameter(xds != NULL);
+    xds_check_parameter(name != NULL);
+    xds_check_parameter(engine != NULL);
     for(pos = 0; name[pos] != '\0'; ++pos)
         {
         if (!isalnum(name[pos]) && name[pos] != '-' && name[pos] != '_')


ossp-pkg/xds/set-capacity.c 1.3 -> 1.3.2.1

--- set-capacity.c       2001/07/16 18:26:58     1.3
+++ set-capacity.c       2001/08/01 09:55:58     1.3.2.1
@@ -36,10 +36,10 @@
 
     /* Sanity checks. */
 
-    assert(array != NULL);
-    assert(array_capacity != NULL);
-    assert(elem_size != 0);
-    assert(initial_capacity != 0);
+    xds_check_parameter(array != NULL);
+    xds_check_parameter(array_capacity != NULL);
+    xds_check_parameter(elem_size != 0);
+    xds_check_parameter(initial_capacity != 0);
 
     /* Do we need to re-allocate? */
 


ossp-pkg/xds/setbuffer.c 1.6 -> 1.6.2.1

--- setbuffer.c  2001/07/31 06:33:55     1.6
+++ setbuffer.c  2001/08/01 09:55:58     1.6.2.1
@@ -32,12 +32,9 @@
     {
     /* Sanity checks. */
 
-    assert(xds != NULL);
-    assert(flag == XDS_GIFT || flag == XDS_LOAN);
-    assert((buffer != NULL && buffer_len != 0) || flag == XDS_GIFT);
-    if (xds == NULL || (flag != XDS_GIFT && flag != XDS_LOAN) ||
-        (flag == XDS_LOAN && (buffer == NULL || buffer_len == 0)))
-        return XDS_ERR_INVALID_ARG;
+    xds_check_parameter(xds != NULL);
+    xds_check_parameter(flag == XDS_GIFT || flag == XDS_LOAN);
+    xds_check_parameter((buffer != NULL && buffer_len != 0) || flag == XDS_GIFT);
 
     /* Free the old buffer if there is one. */
 


ossp-pkg/xds/unregister.c 1.4 -> 1.4.2.1

--- unregister.c 2001/07/09 17:23:38     1.4
+++ unregister.c 2001/08/01 09:55:58     1.4.2.1
@@ -38,10 +38,8 @@
 
     /* Sanity checks. */
 
-    assert(xds != NULL);
-    assert(name != NULL);
-    if (xds == NULL || name == NULL)
-        return XDS_ERR_INVALID_ARG;
+    xds_check_parameter(xds != NULL);
+    xds_check_parameter(name != NULL);
     for(pos = 0; name[pos] != '\0'; ++pos)
         {
         if (!isalnum(name[pos]) && name[pos] != '-' && name[pos] != '_')


ossp-pkg/xds/vdecode.c 1.4 -> 1.4.2.1

--- vdecode.c    2001/07/24 15:46:18     1.4
+++ vdecode.c    2001/08/01 09:55:58     1.4.2.1
@@ -40,11 +40,9 @@
 
     /* Sanity checks. */
 
-    assert(xds != NULL);
-    assert(fmt_arg != NULL);
+    xds_check_parameter(xds != NULL);
+    xds_check_parameter(fmt_arg != NULL);
     assert(xds->mode == XDS_DECODE);
-    if (xds == NULL || fmt_arg == NULL)
-        return XDS_ERR_INVALID_ARG;
     if (xds->mode != XDS_DECODE)
         return XDS_ERR_INVALID_MODE;
 


ossp-pkg/xds/vencode.c 1.12 -> 1.12.2.1

--- vencode.c    2001/07/31 06:33:55     1.12
+++ vencode.c    2001/08/01 09:55:58     1.12.2.1
@@ -41,11 +41,9 @@
 
     /* Sanity checks. */
 
-    assert(xds != NULL);
-    assert(fmt_arg != NULL);
-    assert(xds->mode == XDS_ENCODE);
-    if (xds == NULL || fmt_arg == NULL)
-        return XDS_ERR_INVALID_ARG;
+    xds_check_parameter(xds != NULL);
+    xds_check_parameter(fmt_arg != NULL);
+    xds_check_parameter(xds->mode == XDS_ENCODE);
     if (xds->mode != XDS_ENCODE)
         return XDS_ERR_INVALID_MODE;
 

CVSTrac 2.0.1