ecpg: Remove useless return values
authorPeter Eisentraut <peter_e@gmx.net>
Tue, 12 Sep 2017 00:43:05 +0000 (20:43 -0400)
committerPeter Eisentraut <peter_e@gmx.net>
Sat, 4 Nov 2017 16:01:05 +0000 (12:01 -0400)
Remove useless or inconsistently used return values from functions,
matching backend changes 99bf328237d89e0fd22821a940d4af0506353218 and
791359fe0eae83641f0929159d5861359d395e97.

Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
src/interfaces/ecpg/pgtypeslib/dt.h
src/interfaces/ecpg/pgtypeslib/dt_common.c
src/interfaces/ecpg/pgtypeslib/interval.c
src/interfaces/ecpg/pgtypeslib/timestamp.c

index 5a192ddc4533900dd0b997fd694a6b76b997fecc..8cf03bfedfbd789b04e1af1d7a62127483bb4aa5 100644 (file)
@@ -313,12 +313,12 @@ do { \
 
 int            DecodeInterval(char **, int *, int, int *, struct tm *, fsec_t *);
 int            DecodeTime(char *, int *, struct tm *, fsec_t *);
-int            EncodeDateTime(struct tm *tm, fsec_t fsec, bool print_tz, int tz, const char *tzn, int style, char *str, bool EuroDates);
-int            EncodeInterval(struct tm *tm, fsec_t fsec, int style, char *str);
+void       EncodeDateTime(struct tm *tm, fsec_t fsec, bool print_tz, int tz, const char *tzn, int style, char *str, bool EuroDates);
+void       EncodeInterval(struct tm *tm, fsec_t fsec, int style, char *str);
 int            tm2timestamp(struct tm *, fsec_t, int *, timestamp *);
 int            DecodeUnits(int field, char *lowtoken, int *val);
 bool       CheckDateTokenTables(void);
-int            EncodeDateOnly(struct tm *tm, int style, char *str, bool EuroDates);
+void       EncodeDateOnly(struct tm *tm, int style, char *str, bool EuroDates);
 int            GetEpochTime(struct tm *);
 int            ParseDateTime(char *, char *, char **, int *, int *, char **);
 int            DecodeDateTime(char **, int *, int, int *, struct tm *, fsec_t *, bool);
index a26d61b32cd30c6db16ce13f94c379eb7d8d6e14..59b69d917bccd45baaf291d39735ad6780185931 100644 (file)
@@ -671,11 +671,10 @@ DecodeSpecial(int field, char *lowtoken, int *val)
 /* EncodeDateOnly()
  * Encode date as local time.
  */
-int
+void
 EncodeDateOnly(struct tm *tm, int style, char *str, bool EuroDates)
 {
-   if (tm->tm_mon < 1 || tm->tm_mon > MONTHS_PER_YEAR)
-       return -1;
+   Assert(tm->tm_mon >= 1 && tm->tm_mon <= MONTHS_PER_YEAR);
 
    switch (style)
    {
@@ -723,9 +722,7 @@ EncodeDateOnly(struct tm *tm, int style, char *str, bool EuroDates)
                sprintf(str + 5, "-%04d %s", -(tm->tm_year - 1), "BC");
            break;
    }
-
-   return TRUE;
-}                              /* EncodeDateOnly() */
+}
 
 void
 TrimTrailingZeros(char *str)
@@ -758,7 +755,7 @@ TrimTrailingZeros(char *str)
  * US - mm/dd/yyyy
  * European - dd/mm/yyyy
  */
-int
+void
 EncodeDateTime(struct tm *tm, fsec_t fsec, bool print_tz, int tz, const char *tzn, int style, char *str, bool EuroDates)
 {
    int         day,
@@ -951,9 +948,7 @@ EncodeDateTime(struct tm *tm, fsec_t fsec, bool print_tz, int tz, const char *tz
            }
            break;
    }
-
-   return TRUE;
-}                              /* EncodeDateTime() */
+}
 
 int
 GetEpochTime(struct tm *tm)
index 30f2ccbcb7776e2d69b4121ead8a9edcf08c6fa7..4a7227e926c11fd8448b3001563f5537d1dcec50 100644 (file)
@@ -331,8 +331,6 @@ DecodeISO8601Interval(char *str,
  * * ECPG semes not to have a global IntervalStyle
  *   so added
  *     int IntervalStyle = INTSTYLE_POSTGRES;
- *
- * * Assert wasn't available so removed it.
  */
 int
 DecodeInterval(char **field, int *ftype, int nf,   /* int range, */
@@ -374,7 +372,7 @@ DecodeInterval(char **field, int *ftype, int nf,    /* int range, */
                 * least one digit; there could be ':', '.', '-' embedded in
                 * it as well.
                 */
-               /* Assert(*field[i] == '-' || *field[i] == '+'); */
+               Assert(*field[i] == '-' || *field[i] == '+');
 
                /*
                 * Try for hh:mm or hh:mm:ss.  If not, fall through to
@@ -771,7 +769,7 @@ AppendSeconds(char *cp, int sec, fsec_t fsec, int precision, bool fillzeros)
  * Change pg_tm to tm
  */
 
-int
+void
 EncodeInterval(struct /* pg_ */ tm *tm, fsec_t fsec, int style, char *str)
 {
    char       *cp = str;
@@ -947,9 +945,7 @@ EncodeInterval(struct /* pg_ */ tm *tm, fsec_t fsec, int style, char *str)
                strcat(cp, " ago");
            break;
    }
-
-   return 0;
-}                              /* EncodeInterval() */
+}
 
 
 /* interval2tm()
@@ -1091,11 +1087,7 @@ PGTYPESinterval_to_asc(interval * span)
        return NULL;
    }
 
-   if (EncodeInterval(tm, fsec, IntervalStyle, buf) != 0)
-   {
-       errno = PGTYPES_INTVL_BAD_INTERVAL;
-       return NULL;
-   }
+   EncodeInterval(tm, fsec, IntervalStyle, buf);
 
    return pgtypes_strdup(buf);
 }
index fa5b32ed9da401ccf5f85ef318ef9ebd306ef557..b63880dc55d5e1e9f808f2e6b9bd8276e5d221f8 100644 (file)
@@ -192,7 +192,7 @@ timestamp2tm(timestamp dt, int *tzp, struct tm *tm, fsec_t *fsec, const char **t
 /* EncodeSpecialTimestamp()
  * * Convert reserved timestamp data type to string.
  *  */
-static int
+static void
 EncodeSpecialTimestamp(timestamp dt, char *str)
 {
    if (TIMESTAMP_IS_NOBEGIN(dt))
@@ -200,10 +200,8 @@ EncodeSpecialTimestamp(timestamp dt, char *str)
    else if (TIMESTAMP_IS_NOEND(dt))
        strcpy(str, LATE);
    else
-       return FALSE;
-
-   return TRUE;
-}                              /* EncodeSpecialTimestamp() */
+       abort();                /* shouldn't happen */
+}
 
 timestamp
 PGTYPEStimestamp_from_asc(char *str, char **endptr)