Skip to content

Commit d6148e7

Browse files
committed
ecpg: Remove useless return values
Remove useless or inconsistently used return values from functions, matching backend changes 99bf328 and 791359f. Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
1 parent cb29ff8 commit d6148e7

File tree

4 files changed

+15
-30
lines changed

4 files changed

+15
-30
lines changed

src/interfaces/ecpg/pgtypeslib/dt.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,12 @@ do { \
313313

314314
int DecodeInterval(char **, int *, int, int *, struct tm *, fsec_t *);
315315
int DecodeTime(char *, int *, struct tm *, fsec_t *);
316-
int EncodeDateTime(struct tm *tm, fsec_t fsec, bool print_tz, int tz, const char *tzn, int style, char *str, bool EuroDates);
317-
int EncodeInterval(struct tm *tm, fsec_t fsec, int style, char *str);
316+
void EncodeDateTime(struct tm *tm, fsec_t fsec, bool print_tz, int tz, const char *tzn, int style, char *str, bool EuroDates);
317+
void EncodeInterval(struct tm *tm, fsec_t fsec, int style, char *str);
318318
int tm2timestamp(struct tm *, fsec_t, int *, timestamp *);
319319
int DecodeUnits(int field, char *lowtoken, int *val);
320320
bool CheckDateTokenTables(void);
321-
int EncodeDateOnly(struct tm *tm, int style, char *str, bool EuroDates);
321+
void EncodeDateOnly(struct tm *tm, int style, char *str, bool EuroDates);
322322
int GetEpochTime(struct tm *);
323323
int ParseDateTime(char *, char *, char **, int *, int *, char **);
324324
int DecodeDateTime(char **, int *, int, int *, struct tm *, fsec_t *, bool);

src/interfaces/ecpg/pgtypeslib/dt_common.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -671,11 +671,10 @@ DecodeSpecial(int field, char *lowtoken, int *val)
671671
/* EncodeDateOnly()
672672
* Encode date as local time.
673673
*/
674-
int
674+
void
675675
EncodeDateOnly(struct tm *tm, int style, char *str, bool EuroDates)
676676
{
677-
if (tm->tm_mon < 1 || tm->tm_mon > MONTHS_PER_YEAR)
678-
return -1;
677+
Assert(tm->tm_mon >= 1 && tm->tm_mon <= MONTHS_PER_YEAR);
679678

680679
switch (style)
681680
{
@@ -723,9 +722,7 @@ EncodeDateOnly(struct tm *tm, int style, char *str, bool EuroDates)
723722
sprintf(str + 5, "-%04d %s", -(tm->tm_year - 1), "BC");
724723
break;
725724
}
726-
727-
return TRUE;
728-
} /* EncodeDateOnly() */
725+
}
729726

730727
void
731728
TrimTrailingZeros(char *str)
@@ -758,7 +755,7 @@ TrimTrailingZeros(char *str)
758755
* US - mm/dd/yyyy
759756
* European - dd/mm/yyyy
760757
*/
761-
int
758+
void
762759
EncodeDateTime(struct tm *tm, fsec_t fsec, bool print_tz, int tz, const char *tzn, int style, char *str, bool EuroDates)
763760
{
764761
int day,
@@ -951,9 +948,7 @@ EncodeDateTime(struct tm *tm, fsec_t fsec, bool print_tz, int tz, const char *tz
951948
}
952949
break;
953950
}
954-
955-
return TRUE;
956-
} /* EncodeDateTime() */
951+
}
957952

958953
int
959954
GetEpochTime(struct tm *tm)

src/interfaces/ecpg/pgtypeslib/interval.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,6 @@ DecodeISO8601Interval(char *str,
331331
* * ECPG semes not to have a global IntervalStyle
332332
* so added
333333
* int IntervalStyle = INTSTYLE_POSTGRES;
334-
*
335-
* * Assert wasn't available so removed it.
336334
*/
337335
int
338336
DecodeInterval(char **field, int *ftype, int nf, /* int range, */
@@ -374,7 +372,7 @@ DecodeInterval(char **field, int *ftype, int nf, /* int range, */
374372
* least one digit; there could be ':', '.', '-' embedded in
375373
* it as well.
376374
*/
377-
/* Assert(*field[i] == '-' || *field[i] == '+'); */
375+
Assert(*field[i] == '-' || *field[i] == '+');
378376

379377
/*
380378
* 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)
771769
* Change pg_tm to tm
772770
*/
773771

774-
int
772+
void
775773
EncodeInterval(struct /* pg_ */ tm *tm, fsec_t fsec, int style, char *str)
776774
{
777775
char *cp = str;
@@ -947,9 +945,7 @@ EncodeInterval(struct /* pg_ */ tm *tm, fsec_t fsec, int style, char *str)
947945
strcat(cp, " ago");
948946
break;
949947
}
950-
951-
return 0;
952-
} /* EncodeInterval() */
948+
}
953949

954950

955951
/* interval2tm()
@@ -1091,11 +1087,7 @@ PGTYPESinterval_to_asc(interval * span)
10911087
return NULL;
10921088
}
10931089

1094-
if (EncodeInterval(tm, fsec, IntervalStyle, buf) != 0)
1095-
{
1096-
errno = PGTYPES_INTVL_BAD_INTERVAL;
1097-
return NULL;
1098-
}
1090+
EncodeInterval(tm, fsec, IntervalStyle, buf);
10991091

11001092
return pgtypes_strdup(buf);
11011093
}

src/interfaces/ecpg/pgtypeslib/timestamp.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,18 +192,16 @@ timestamp2tm(timestamp dt, int *tzp, struct tm *tm, fsec_t *fsec, const char **t
192192
/* EncodeSpecialTimestamp()
193193
* * Convert reserved timestamp data type to string.
194194
* */
195-
static int
195+
static void
196196
EncodeSpecialTimestamp(timestamp dt, char *str)
197197
{
198198
if (TIMESTAMP_IS_NOBEGIN(dt))
199199
strcpy(str, EARLY);
200200
else if (TIMESTAMP_IS_NOEND(dt))
201201
strcpy(str, LATE);
202202
else
203-
return FALSE;
204-
205-
return TRUE;
206-
} /* EncodeSpecialTimestamp() */
203+
abort(); /* shouldn't happen */
204+
}
207205

208206
timestamp
209207
PGTYPEStimestamp_from_asc(char *str, char **endptr)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy