Changeset: 5773c902b4bb for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5773c902b4bb
Modified Files:
        gdk/gdk_aggr.c
        gdk/gdk_analytic_func.c
Branch: Jun2020
Log Message:

Removed some calls of GDKerror.
GDKmalloc and friends already call GDKerror, there is no need to call
it again with essentially the same message if GDKmalloc fails.


diffs (233 lines):

diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -724,7 +724,6 @@ dosum(const void *restrict values, bool 
        /* allocate bitmap for seen group ids */
        seen = GDKzalloc(((ngrp + 31) / 32) * sizeof(int));
        if (seen == NULL) {
-               GDKerror("%s: cannot allocate enough memory\n", func);
                return BUN_NONE;
        }
 
@@ -1252,7 +1251,6 @@ doprod(const void *restrict values, oid 
        /* allocate bitmap for seen group ids */
        seen = GDKzalloc(((ngrp + 31) / 32) * sizeof(int));
        if (seen == NULL) {
-               GDKerror("%s: cannot allocate enough memory\n", func);
                return BUN_NONE;
        }
 
@@ -1683,14 +1681,11 @@ BATgroupavg(BAT **bnp, BAT **cntsp, BAT 
                 * with nil in the tail */
                bn = BATconstant(ngrp == 0 ? 0 : min, TYPE_dbl, &dbl_nil, ngrp, 
TRANSIENT);
                if (bn == NULL) {
-                       GDKerror("%s: failed to create BAT\n", __func__);
                        return GDK_FAIL;
                }
                if (cntsp) {
                        lng zero = 0;
                        if ((cn = BATconstant(ngrp == 0 ? 0 : min, TYPE_lng, 
&zero, ngrp, TRANSIENT)) == NULL) {
-                               GDKerror("%s: failed to create BAT\n",
-                                        __func__);
                                BBPreclaim(bn);
                                return GDK_FAIL;
                        }
@@ -1830,7 +1825,6 @@ BATgroupavg(BAT **bnp, BAT **cntsp, BAT 
        } else if (cnts) {
                GDKfree(cnts);
        }
-       GDKerror("%s: cannot allocate enough memory.\n", __func__);
        return GDK_FAIL;
 }
 
@@ -3474,7 +3468,6 @@ dogroupstdev(BAT **avgb, BAT *b, BAT *g,
        GDKfree(delta);
        GDKfree(m2);
        GDKfree(cnts);
-       GDKerror("%s: cannot allocate enough memory.\n", func);
        return NULL;
 }
 
@@ -3676,7 +3669,6 @@ dogroupcovariance(BAT *b1, BAT *b2, BAT 
        GDKfree(delta2);
        GDKfree(m2);
        GDKfree(cnts);
-       GDKerror("%s: cannot allocate enough memory.\n", func);
        return NULL;
 }
 
@@ -3864,6 +3856,5 @@ BATgroupcorrelation(BAT *b1, BAT *b2, BA
        GDKfree(down1);
        GDKfree(down2);
        GDKfree(cnts);
-       GDKerror("%s: cannot allocate enough memory.\n", __func__);
        return NULL;
 }
diff --git a/gdk/gdk_analytic_func.c b/gdk/gdk_analytic_func.c
--- a/gdk/gdk_analytic_func.c
+++ b/gdk/gdk_analytic_func.c
@@ -335,7 +335,7 @@ GDKanalyticalfirst(BAT *r, BAT *b, BAT *
                for (; i < cnt; i++) {
                        curval = (end[i] > start[i]) ? BUNtail(bpi, (BUN) 
start[i]) : (void *) nil;
                        if (BUNappend(r, curval, false) != GDK_SUCCEED)
-                               goto allocation_error;
+                               return GDK_FAIL;
                        has_nils |= atomcmp(curval, nil) == 0;
                }
        }
@@ -344,9 +344,6 @@ GDKanalyticalfirst(BAT *r, BAT *b, BAT *
        r->tnonil = !has_nils;
        r->tnil = has_nils;
        return GDK_SUCCEED;
-      allocation_error:
-       GDKerror("GDKanalyticalfirst: malloc failure\n");
-       return GDK_FAIL;
 }
 
 #define ANALYTICAL_LAST_IMP(TPE)                                       \
@@ -410,7 +407,7 @@ GDKanalyticallast(BAT *r, BAT *b, BAT *s
                for (; i < cnt; i++) {
                        curval = (end[i] > start[i]) ? BUNtail(bpi, (BUN) 
(end[i] - 1)) : (void *) nil;
                        if (BUNappend(r, curval, false) != GDK_SUCCEED)
-                               goto allocation_error;
+                               return GDK_FAIL;
                        has_nils |= atomcmp(curval, nil) == 0;
                }
        }
@@ -419,9 +416,6 @@ GDKanalyticallast(BAT *r, BAT *b, BAT *s
        r->tnonil = !has_nils;
        r->tnil = has_nils;
        return GDK_SUCCEED;
-      allocation_error:
-       GDKerror("GDKanalyticallast: malloc failure\n");
-       return GDK_FAIL;
 }
 
 #define ANALYTICAL_NTHVALUE_IMP_SINGLE_FIXED(TPE1)                     \
@@ -505,7 +499,7 @@ GDKanalyticallast(BAT *r, BAT *b, BAT *s
                                has_nils |= atomcmp(curval, nil) == 0;  \
                        }       \
                        if (BUNappend(r, curval, false) != GDK_SUCCEED) \
-                               goto allocation_error;                  \
+                               return GDK_FAIL;                        \
                }                                                       \
        } while (0)
 
@@ -582,13 +576,13 @@ GDKanalyticalnthvalue(BAT *r, BAT *b, BA
                                has_nils = true;
                                for (; i < cnt; i++)
                                        if (BUNappend(r, nil, false) != 
GDK_SUCCEED)
-                                               goto allocation_error;
+                                               return GDK_FAIL;
                        } else {
                                nth--;
                                for (; i < cnt; i++) {
                                        curval = (end[i] > start[i] && nth < 
(end[i] - start[i])) ? BUNtail(bpi, (BUN) (start[i] + nth)) : (void *) nil;
                                        if (BUNappend(r, curval, false) != 
GDK_SUCCEED)
-                                               goto allocation_error;
+                                               return GDK_FAIL;
                                        has_nils |= atomcmp(curval, nil) == 0;
                                }
                        }
@@ -652,9 +646,6 @@ GDKanalyticalnthvalue(BAT *r, BAT *b, BA
        r->tnonil = !has_nils;
        r->tnil = has_nils;
        return GDK_SUCCEED;
-      allocation_error:
-       GDKerror("GDKanalyticalnthvalue: malloc failure\n");
-       return GDK_FAIL;
       nosupport:
        GDKerror("GDKanalyticalnthvalue: type %s not supported for the 
nth_value.\n", ATOMname(tp2));
        return GDK_FAIL;
@@ -708,13 +699,13 @@ GDKanalyticalnthvalue(BAT *r, BAT *b, BA
        do {                                                            \
                for (i = 0; i < lag && k < j; i++, k++) {               \
                        if (BUNappend(r, default_value, false) != GDK_SUCCEED) \
-                               goto allocation_error;                  \
+                               return GDK_FAIL;                        \
                }                                                       \
                has_nils |= (lag > 0 && atomcmp(default_value, nil) == 0);      
\
                for (l = k - lag; k < j; k++, l++) {                    \
                        curval = BUNtail(bpi, l);                       \
                        if (BUNappend(r, curval, false) != GDK_SUCCEED) \
-                               goto allocation_error;                  \
+                               return GDK_FAIL;                        \
                        has_nils |= atomcmp(curval, nil) == 0;                  
\
                }       \
        } while (0)
@@ -766,7 +757,7 @@ GDKanalyticallag(BAT *r, BAT *b, BAT *p,
                        has_nils = true;
                        for (j = 0; j < cnt; j++) {
                                if (BUNappend(r, nil, false) != GDK_SUCCEED)
-                                       goto allocation_error;
+                                       return GDK_FAIL;
                        }
                } else if (p) {
                        pnp = np = (bit *) Tloc(p, 0);
@@ -790,9 +781,6 @@ GDKanalyticallag(BAT *r, BAT *b, BAT *p,
        r->tnonil = !has_nils;
        r->tnil = has_nils;
        return GDK_SUCCEED;
-      allocation_error:
-       GDKerror("GDKanalyticallag: malloc failure\n");
-       return GDK_FAIL;
 }
 
 #define LEAD_CALC(TPE)                                         \
@@ -853,14 +841,14 @@ GDKanalyticallag(BAT *r, BAT *b, BAT *p,
                        for (i = 0,n = k + lead; i < m; i++, n++) {     \
                                curval = BUNtail(bpi, n);               \
                                if (BUNappend(r, curval, false) != GDK_SUCCEED) 
\
-                                       goto allocation_error;          \
+                                       return GDK_FAIL;                \
                                has_nils |= atomcmp(curval, nil) == 0;          
\
                        }                                               \
                        k += i;                                         \
                }                                                       \
                for (; k < j; k++) {                                    \
                        if (BUNappend(r, default_value, false) != GDK_SUCCEED) \
-                               goto allocation_error;                  \
+                               return GDK_FAIL;                        \
                }                                                       \
                has_nils |= (lead > 0 && atomcmp(default_value, nil) == 0);     
\
        } while (0)
@@ -913,7 +901,7 @@ GDKanalyticallead(BAT *r, BAT *b, BAT *p
                        has_nils = true;
                        for (j = 0; j < cnt; j++) {
                                if (BUNappend(r, nil, false) != GDK_SUCCEED)
-                                       goto allocation_error;
+                                       return GDK_FAIL;
                        }
                } else if (p) {
                        pnp = np = (bit *) Tloc(p, 0);
@@ -937,9 +925,6 @@ GDKanalyticallead(BAT *r, BAT *b, BAT *p
        r->tnonil = !has_nils;
        r->tnil = has_nils;
        return GDK_SUCCEED;
-      allocation_error:
-       GDKerror("GDKanalyticallead: malloc failure\n");
-       return GDK_FAIL;
 }
 
 #define ANALYTICAL_MIN_MAX_CALC(TPE, OP)                               \
@@ -1029,8 +1014,8 @@ GDKanalytical##OP(BAT *r, BAT *b, BAT *s
                                }                                       \
                        }                                               \
                        if (BUNappend(r, curval, false) != GDK_SUCCEED) \
-                               goto allocation_error;                  \
-                       has_nils |= atomcmp(curval, nil) == 0;  \
+                               return GDK_FAIL;                        \
+                       has_nils |= atomcmp(curval, nil) == 0;          \
                }                                                       \
        }                                                               \
        }                                                               \
@@ -1038,9 +1023,6 @@ GDKanalytical##OP(BAT *r, BAT *b, BAT *s
        r->tnonil = !has_nils;                                          \
        r->tnil = has_nils;                                             \
        return GDK_SUCCEED;                                             \
-  allocation_error:                                                    \
-       GDKerror("GDKanalytical""OP"": malloc failure\n");              \
-       return GDK_FAIL;                                                \
 }
 
 ANALYTICAL_MIN_MAX(min, MIN, >)
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to