diff options
author | Tom Lane | 2005-09-24 22:54:44 +0000 |
---|---|---|
committer | Tom Lane | 2005-09-24 22:54:44 +0000 |
commit | 727b0f6c3b5a162f6c8b34e10582b4d9007b4ad5 (patch) | |
tree | 3791fa63566f25a7a7f85ce706f8b9d4a3e570fe | |
parent | 16a2bd4dfcb7d9dc3fff29a0169749ea333142ab (diff) |
Clean up possibly-uninitialized-variable warnings reported by gcc 4.x.
-rw-r--r-- | src/backend/access/nbtree/nbtinsert.c | 36 | ||||
-rw-r--r-- | src/backend/catalog/pg_proc.c | 14 | ||||
-rw-r--r-- | src/backend/commands/copy.c | 6 | ||||
-rw-r--r-- | src/backend/commands/functioncmds.c | 9 | ||||
-rw-r--r-- | src/backend/commands/tablecmds.c | 5 | ||||
-rw-r--r-- | src/backend/optimizer/path/indxpath.c | 42 | ||||
-rw-r--r-- | src/backend/optimizer/plan/createplan.c | 3 | ||||
-rw-r--r-- | src/backend/optimizer/plan/planner.c | 4 | ||||
-rw-r--r-- | src/backend/regex/rege_dfa.c | 3 | ||||
-rw-r--r-- | src/backend/regex/regexec.c | 1 | ||||
-rw-r--r-- | src/backend/utils/adt/inet_net_ntop.c | 2 | ||||
-rw-r--r-- | src/backend/utils/adt/nabstime.c | 91 | ||||
-rw-r--r-- | src/backend/utils/adt/selfuncs.c | 1 | ||||
-rw-r--r-- | src/backend/utils/cache/catcache.c | 2 | ||||
-rw-r--r-- | src/backend/utils/misc/guc.c | 12 | ||||
-rw-r--r-- | src/interfaces/ecpg/pgtypeslib/datetime.c | 2 | ||||
-rw-r--r-- | src/pl/plpgsql/src/pl_comp.c | 28 |
17 files changed, 151 insertions, 110 deletions
diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c index 7f9a215b25..1f6b829c8b 100644 --- a/src/backend/access/nbtree/nbtinsert.c +++ b/src/backend/access/nbtree/nbtinsert.c @@ -49,8 +49,7 @@ static void _bt_insertonpg(Relation rel, Buffer buf, bool split_only_page); static Buffer _bt_split(Relation rel, Buffer buf, OffsetNumber firstright, OffsetNumber newitemoff, Size newitemsz, - BTItem newitem, bool newitemonleft, - OffsetNumber *itup_off, BlockNumber *itup_blkno); + BTItem newitem, bool newitemonleft); static OffsetNumber _bt_findsplitloc(Relation rel, Page page, OffsetNumber newitemoff, Size newitemsz, @@ -365,8 +364,6 @@ _bt_insertonpg(Relation rel, { Page page; BTPageOpaque lpageop; - OffsetNumber itup_off; - BlockNumber itup_blkno; OffsetNumber newitemoff; OffsetNumber firstright = InvalidOffsetNumber; Size itemsz; @@ -490,8 +487,7 @@ _bt_insertonpg(Relation rel, /* split the buffer into left and right halves */ rbuf = _bt_split(rel, buf, firstright, - newitemoff, itemsz, btitem, newitemonleft, - &itup_off, &itup_blkno); + newitemoff, itemsz, btitem, newitemonleft); /*---------- * By here, @@ -516,6 +512,8 @@ _bt_insertonpg(Relation rel, Buffer metabuf = InvalidBuffer; Page metapg = NULL; BTMetaPageData *metad = NULL; + OffsetNumber itup_off; + BlockNumber itup_blkno; itup_off = newitemoff; itup_blkno = BufferGetBlockNumber(buf); @@ -640,14 +638,12 @@ _bt_insertonpg(Relation rel, * must be inserted along with the data from the old page. * * Returns the new right sibling of buf, pinned and write-locked. - * The pin and lock on buf are maintained. *itup_off and *itup_blkno - * are set to the exact location where newitem was inserted. + * The pin and lock on buf are maintained. */ static Buffer _bt_split(Relation rel, Buffer buf, OffsetNumber firstright, OffsetNumber newitemoff, Size newitemsz, BTItem newitem, - bool newitemonleft, - OffsetNumber *itup_off, BlockNumber *itup_blkno) + bool newitemonleft) { Buffer rbuf; Page origpage; @@ -659,6 +655,8 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright, Buffer sbuf = InvalidBuffer; Page spage = NULL; BTPageOpaque sopaque = NULL; + OffsetNumber itup_off = 0; + BlockNumber itup_blkno = 0; Size itemsz; ItemId itemid; BTItem item; @@ -752,16 +750,16 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright, { _bt_pgaddtup(rel, leftpage, newitemsz, newitem, leftoff, "left sibling"); - *itup_off = leftoff; - *itup_blkno = BufferGetBlockNumber(buf); + itup_off = leftoff; + itup_blkno = BufferGetBlockNumber(buf); leftoff = OffsetNumberNext(leftoff); } else { _bt_pgaddtup(rel, rightpage, newitemsz, newitem, rightoff, "right sibling"); - *itup_off = rightoff; - *itup_blkno = BufferGetBlockNumber(rbuf); + itup_off = rightoff; + itup_blkno = BufferGetBlockNumber(rbuf); rightoff = OffsetNumberNext(rightoff); } } @@ -788,16 +786,16 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright, { _bt_pgaddtup(rel, leftpage, newitemsz, newitem, leftoff, "left sibling"); - *itup_off = leftoff; - *itup_blkno = BufferGetBlockNumber(buf); + itup_off = leftoff; + itup_blkno = BufferGetBlockNumber(buf); leftoff = OffsetNumberNext(leftoff); } else { _bt_pgaddtup(rel, rightpage, newitemsz, newitem, rightoff, "right sibling"); - *itup_off = rightoff; - *itup_blkno = BufferGetBlockNumber(rbuf); + itup_off = rightoff; + itup_blkno = BufferGetBlockNumber(rbuf); rightoff = OffsetNumberNext(rightoff); } } @@ -839,7 +837,7 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright, XLogRecData rdata[4]; xlrec.target.node = rel->rd_node; - ItemPointerSet(&(xlrec.target.tid), *itup_blkno, *itup_off); + ItemPointerSet(&(xlrec.target.tid), itup_blkno, itup_off); if (newitemonleft) xlrec.otherblk = BufferGetBlockNumber(rbuf); else diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c index 0d815a311a..8d91a0fd12 100644 --- a/src/backend/catalog/pg_proc.c +++ b/src/backend/catalog/pg_proc.c @@ -789,21 +789,27 @@ match_prosrc_to_literal(const char *prosrc, const char *literal, else if (*literal == '\'') { if (literal[1] != '\'') - return false; + goto fail; literal++; if (cursorpos > 0) newcp++; } chlen = pg_mblen(prosrc); if (strncmp(prosrc, literal, chlen) != 0) - return false; + goto fail; prosrc += chlen; literal += chlen; } - *newcursorpos = newcp; - if (*literal == '\'' && literal[1] != '\'') + { + /* success */ + *newcursorpos = newcp; return true; + } + +fail: + /* Must set *newcursorpos to suppress compiler warning */ + *newcursorpos = newcp; return false; } diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index 2b13464353..3ed2898e0f 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -542,7 +542,10 @@ CopyGetInt32(CopyState cstate, int32 *val) uint32 buf; if (CopyGetData(cstate, &buf, sizeof(buf), sizeof(buf)) != sizeof(buf)) + { + *val = 0; /* suppress compiler warning */ return false; + } *val = (int32) ntohl(buf); return true; } @@ -568,7 +571,10 @@ CopyGetInt16(CopyState cstate, int16 *val) uint16 buf; if (CopyGetData(cstate, &buf, sizeof(buf), sizeof(buf)) != sizeof(buf)) + { + *val = 0; /* suppress compiler warning */ return false; + } *val = (int16) ntohs(buf); return true; } diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c index 1cffc9a417..957faf9686 100644 --- a/src/backend/commands/functioncmds.c +++ b/src/backend/commands/functioncmds.c @@ -158,6 +158,8 @@ examine_parameter_list(List *parameters, Oid languageOid, ListCell *x; int i; + *requiredResultType = InvalidOid; /* default result */ + inTypes = (Oid *) palloc(parameterCount * sizeof(Oid)); allTypes = (Datum *) palloc(parameterCount * sizeof(Datum)); paramModes = (Datum *) palloc(parameterCount * sizeof(Datum)); @@ -243,7 +245,6 @@ examine_parameter_list(List *parameters, Oid languageOid, { *allParameterTypes = NULL; *parameterModes = NULL; - *requiredResultType = InvalidOid; } if (have_names) @@ -383,16 +384,22 @@ compute_attributes_sql_style(List *options, if (as_item) *as = (List *) as_item->arg; else + { ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), errmsg("no function body specified"))); + *as = NIL; /* keep compiler quiet */ + } if (language_item) *language = strVal(language_item->arg); else + { ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), errmsg("no language specified"))); + *language = NULL; /* keep compiler quiet */ + } /* process optional items */ if (volatility_item) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 469240ad55..00f61d2976 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -4109,6 +4109,8 @@ transformFkeyGetPrimaryKey(Relation pkrel, Oid *indexOid, * look up each one in the pg_index syscache until we find one marked * primary key (hopefully there isn't more than one such). */ + *indexOid = InvalidOid; + indexoidlist = RelationGetIndexList(pkrel); foreach(indexoidscan, indexoidlist) @@ -4127,7 +4129,6 @@ transformFkeyGetPrimaryKey(Relation pkrel, Oid *indexOid, break; } ReleaseSysCache(indexTuple); - indexStruct = NULL; } list_free(indexoidlist); @@ -4135,7 +4136,7 @@ transformFkeyGetPrimaryKey(Relation pkrel, Oid *indexOid, /* * Check that we found it */ - if (indexStruct == NULL) + if (!OidIsValid(*indexOid)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("there is no primary key for referenced table \"%s\"", diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c index 65eff98d0a..a7ba648bf2 100644 --- a/src/backend/optimizer/path/indxpath.c +++ b/src/backend/optimizer/path/indxpath.c @@ -65,10 +65,9 @@ static bool matches_any_index(RestrictInfo *rinfo, RelOptInfo *rel, Relids outer_relids); static List *find_clauses_for_join(PlannerInfo *root, RelOptInfo *rel, Relids outer_relids, bool isouterjoin); -static bool match_variant_ordering(PlannerInfo *root, - IndexOptInfo *index, - List *restrictclauses, - ScanDirection *indexscandir); +static ScanDirection match_variant_ordering(PlannerInfo *root, + IndexOptInfo *index, + List *restrictclauses); static List *identify_ignorable_ordering_cols(PlannerInfo *root, IndexOptInfo *index, List *restrictclauses); @@ -362,15 +361,15 @@ find_usable_indexes(PlannerInfo *root, RelOptInfo *rel, root->query_pathkeys != NIL && pathkeys_useful_for_ordering(root, useful_pathkeys) == 0) { - ScanDirection indexscandir; + ScanDirection scandir; - if (match_variant_ordering(root, index, restrictclauses, - &indexscandir)) + scandir = match_variant_ordering(root, index, restrictclauses); + if (!ScanDirectionIsNoMovement(scandir)) { ipath = create_index_path(root, index, restrictclauses, root->query_pathkeys, - indexscandir, + scandir, false); result = lappend(result, ipath); } @@ -1304,15 +1303,14 @@ find_clauses_for_join(PlannerInfo *root, RelOptInfo *rel, * 'restrictclauses' is the list of sublists of restriction clauses * matching the columns of the index (NIL if none) * - * Returns TRUE if able to match the requested query pathkeys, FALSE if not. - * In the TRUE case, sets '*indexscandir' to either ForwardScanDirection or - * BackwardScanDirection to indicate the proper scan direction. + * If able to match the requested query pathkeys, returns either + * ForwardScanDirection or BackwardScanDirection to indicate the proper index + * scan direction. If no match, returns NoMovementScanDirection. */ -static bool +static ScanDirection match_variant_ordering(PlannerInfo *root, IndexOptInfo *index, - List *restrictclauses, - ScanDirection *indexscandir) + List *restrictclauses) { List *ignorables; @@ -1328,7 +1326,7 @@ match_variant_ordering(PlannerInfo *root, * won't cope. */ if (index->relam != BTREE_AM_OID) - return false; + return NoMovementScanDirection; /* * Figure out which index columns can be optionally ignored because * they have an equality constraint. This is the same set for either @@ -1344,17 +1342,13 @@ match_variant_ordering(PlannerInfo *root, if (ignorables && match_index_to_query_keys(root, index, ForwardScanDirection, ignorables)) - { - *indexscandir = ForwardScanDirection; - return true; - } + return ForwardScanDirection; + if (match_index_to_query_keys(root, index, BackwardScanDirection, ignorables)) - { - *indexscandir = BackwardScanDirection; - return true; - } - return false; + return BackwardScanDirection; + + return NoMovementScanDirection; } /* diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index 5f3300b157..2ec87ec5e9 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -1634,7 +1634,8 @@ fix_indexqual_operand(Node *node, IndexOptInfo *index, Oid *opclass) /* Ooops... */ elog(ERROR, "node is not an index attribute"); - return NULL; /* keep compiler quiet */ + *opclass = InvalidOid; /* keep compiler quiet */ + return NULL; } /* diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index f9d7721ed9..ffb7658c23 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -649,8 +649,8 @@ grouping_planner(PlannerInfo *root, double tuple_fraction) { Query *parse = root->parse; List *tlist = parse->targetList; - int offset_est; - int count_est; + int offset_est = 0; + int count_est = 0; Plan *result_plan; List *current_pathkeys; List *sort_pathkeys; diff --git a/src/backend/regex/rege_dfa.c b/src/backend/regex/rege_dfa.c index bfab113f27..281111c540 100644 --- a/src/backend/regex/rege_dfa.c +++ b/src/backend/regex/rege_dfa.c @@ -578,7 +578,6 @@ getvacant(struct vars * v, /* used only for debug flags */ struct sset *ss; struct sset *p; struct arcp ap; - struct arcp lastap; color co; ss = pickss(v, d, cp, start); @@ -608,6 +607,8 @@ getvacant(struct vars * v, /* used only for debug flags */ p->ins = ss->inchain[i]; else { + struct arcp lastap = {NULL, 0}; + assert(p->ins.ss != NULL); for (ap = p->ins; ap.ss != NULL && !(ap.ss == ss && ap.co == i); diff --git a/src/backend/regex/regexec.c b/src/backend/regex/regexec.c index eb5807545e..b76fde42e4 100644 --- a/src/backend/regex/regexec.c +++ b/src/backend/regex/regexec.c @@ -464,6 +464,7 @@ cfindloop(struct vars * v, if (er != REG_NOMATCH) { ERR(er); + *coldp = cold; return er; } if ((shorter) ? end == estop : end == begin) diff --git a/src/backend/utils/adt/inet_net_ntop.c b/src/backend/utils/adt/inet_net_ntop.c index 5fe0b24bcc..3d3c068865 100644 --- a/src/backend/utils/adt/inet_net_ntop.c +++ b/src/backend/utils/adt/inet_net_ntop.c @@ -443,6 +443,8 @@ inet_net_ntop_ipv6(const u_char *src, int bits, char *dst, size_t size) words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3)); best.base = -1; cur.base = -1; + best.len = 0; + cur.len = 0; for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) { if (words[i] == 0) diff --git a/src/backend/utils/adt/nabstime.c b/src/backend/utils/adt/nabstime.c index d50316e1db..7050083a52 100644 --- a/src/backend/utils/adt/nabstime.c +++ b/src/backend/utils/adt/nabstime.c @@ -79,9 +79,9 @@ static AbsoluteTime tm2abstime(struct pg_tm *tm, int tz); static void reltime2tm(RelativeTime time, struct pg_tm *tm); -static int istinterval(char *i_string, - AbsoluteTime *i_start, - AbsoluteTime *i_end); +static void parsetinterval(char *i_string, + AbsoluteTime *i_start, + AbsoluteTime *i_end); /* @@ -727,24 +727,19 @@ tintervalin(PG_FUNCTION_ARGS) t1, t2; - tinterval = (TimeInterval) palloc(sizeof(TimeIntervalData)); + parsetinterval(tintervalstr, &t1, &t2); - if (istinterval(tintervalstr, &t1, &t2) == 0) - ereport(ERROR, - (errcode(ERRCODE_INVALID_DATETIME_FORMAT), - errmsg("invalid input syntax for type tinterval: \"%s\"", - tintervalstr))); + tinterval = (TimeInterval) palloc(sizeof(TimeIntervalData)); if (t1 == INVALID_ABSTIME || t2 == INVALID_ABSTIME) - tinterval ->status = T_INTERVAL_INVAL; /* undefined */ - + tinterval->status = T_INTERVAL_INVAL; /* undefined */ else - tinterval ->status = T_INTERVAL_VALID; + tinterval->status = T_INTERVAL_VALID; i_start = ABSTIMEMIN(t1, t2); i_end = ABSTIMEMAX(t1, t2); - tinterval ->data[0] = i_start; - tinterval ->data[1] = i_end; + tinterval->data[0] = i_start; + tinterval->data[1] = i_end; PG_RETURN_TIMEINTERVAL(tinterval); } @@ -1444,11 +1439,9 @@ tintervalend(PG_FUNCTION_ARGS) *****************************************************************************/ /* - * istinterval - returns 1, iff i_string is a valid tinterval descr. - * 0, iff i_string is NOT a valid tinterval desc. - * 2, iff any time is INVALID_ABSTIME + * parsetinterval -- parse a tinterval string * - * output parameter: + * output parameters: * i_start, i_end: tinterval margins * * Time interval: @@ -1460,10 +1453,10 @@ tintervalend(PG_FUNCTION_ARGS) * * e.g. [ ' Jan 18 1902' 'Jan 1 00:00:00 1970'] */ -static int -istinterval(char *i_string, - AbsoluteTime *i_start, - AbsoluteTime *i_end) +static void +parsetinterval(char *i_string, + AbsoluteTime *i_start, + AbsoluteTime *i_end) { char *p, *p1; @@ -1476,10 +1469,12 @@ istinterval(char *i_string, if (IsSpace(c)) p++; else if (c != '[') - return 0; /* syntax error */ + goto bogus; /* syntax error */ else break; } + if (c == '\0') + goto bogus; /* syntax error */ p++; /* skip leading blanks up to '"' */ while ((c = *p) != '\0') @@ -1487,30 +1482,32 @@ istinterval(char *i_string, if (IsSpace(c)) p++; else if (c != '"') - return 0; /* syntax error */ + goto bogus; /* syntax error */ else break; } + if (c == '\0') + goto bogus; /* syntax error */ p++; if (strncmp(INVALID_INTERVAL_STR, p, strlen(INVALID_INTERVAL_STR)) == 0) - return 0; /* undefined range, handled like a syntax + goto bogus; /* undefined range, handled like a syntax * err. */ - /* search for the end of the first date and change it to a NULL */ + /* search for the end of the first date and change it to a \0 */ p1 = p; while ((c = *p1) != '\0') { if (c == '"') - { - *p1 = '\0'; break; - } p1++; } + if (c == '\0') + goto bogus; /* syntax error */ + *p1 = '\0'; /* get the first date */ *i_start = DatumGetAbsoluteTime(DirectFunctionCall1(abstimein, CStringGetDatum(p))); - /* rechange NULL at the end of the first date to a '"' */ - *p1 = '"'; + /* undo change to \0 */ + *p1 = c; p = ++p1; /* skip blanks up to '"', beginning of second date */ while ((c = *p) != '\0') @@ -1518,27 +1515,29 @@ istinterval(char *i_string, if (IsSpace(c)) p++; else if (c != '"') - return 0; /* syntax error */ + goto bogus; /* syntax error */ else break; } + if (c == '\0') + goto bogus; /* syntax error */ p++; - /* search for the end of the second date and change it to a NULL */ + /* search for the end of the second date and change it to a \0 */ p1 = p; while ((c = *p1) != '\0') { if (c == '"') - { - *p1 = '\0'; break; - } p1++; } + if (c == '\0') + goto bogus; /* syntax error */ + *p1 = '\0'; /* get the second date */ *i_end = DatumGetAbsoluteTime(DirectFunctionCall1(abstimein, CStringGetDatum(p))); - /* rechange NULL at the end of the first date to a '"' */ - *p1 = '"'; + /* undo change to \0 */ + *p1 = c; p = ++p1; /* skip blanks up to ']' */ while ((c = *p) != '\0') @@ -1546,16 +1545,26 @@ istinterval(char *i_string, if (IsSpace(c)) p++; else if (c != ']') - return 0; /* syntax error */ + goto bogus; /* syntax error */ else break; } + if (c == '\0') + goto bogus; /* syntax error */ p++; c = *p; if (c != '\0') - return 0; /* syntax error */ + goto bogus; /* syntax error */ + /* it seems to be a valid tinterval */ - return 1; + return; + +bogus: + ereport(ERROR, + (errcode(ERRCODE_INVALID_DATETIME_FORMAT), + errmsg("invalid input syntax for type tinterval: \"%s\"", + i_string))); + *i_start = *i_end = INVALID_ABSTIME; /* keep compiler quiet */ } diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index 40d7eb16bf..391f91d66c 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -2403,6 +2403,7 @@ convert_to_scalar(Datum value, Oid valuetypid, double *scaledvalue, return true; } /* Don't know how to convert */ + *scaledvalue = *scaledlobound = *scaledhibound = 0; return false; } diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c index 4339a44b16..6832a452d7 100644 --- a/src/backend/utils/cache/catcache.c +++ b/src/backend/utils/cache/catcache.c @@ -161,6 +161,8 @@ GetCCHashEqFuncs(Oid keytype, PGFunction *hashfunc, RegProcedure *eqfunc) break; default: elog(FATAL, "type %u not supported as catcache key", keytype); + *hashfunc = NULL; /* keep compiler quiet */ + *eqfunc = InvalidOid; break; } } diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index ed1d17e5be..9d3d7a200c 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -3401,7 +3401,11 @@ parse_bool(const char *value, bool *result) } else + { + if (result) + *result = false; /* suppress compiler warning */ return false; + } return true; } @@ -3427,7 +3431,11 @@ parse_int(const char *value, int *result) || val != (long) ((int32) val) #endif ) + { + if (result) + *result = 0; /* suppress compiler warning */ return false; + } if (result) *result = (int) val; return true; @@ -3449,7 +3457,11 @@ parse_real(const char *value, double *result) errno = 0; val = strtod(value, &endptr); if (endptr == value || *endptr != '\0' || errno == ERANGE) + { + if (result) + *result = 0; /* suppress compiler warning */ return false; + } if (result) *result = val; return true; diff --git a/src/interfaces/ecpg/pgtypeslib/datetime.c b/src/interfaces/ecpg/pgtypeslib/datetime.c index 0a480b658a..1d8a85d7a8 100644 --- a/src/interfaces/ecpg/pgtypeslib/datetime.c +++ b/src/interfaces/ecpg/pgtypeslib/datetime.c @@ -334,6 +334,8 @@ PGTYPESdate_defmt_asc(date *d, char *fmt, char *str) char *str_copy; struct tm tm; + tm.tm_year = tm.tm_mon = tm.tm_mday = 0; /* keep compiler quiet */ + if (!d || !str || !fmt) { errno = PGTYPES_DATE_ERR_EARGS; diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c index 3a18b8da5d..ac9eeea525 100644 --- a/src/pl/plpgsql/src/pl_comp.c +++ b/src/pl/plpgsql/src/pl_comp.c @@ -1395,24 +1395,22 @@ plpgsql_parse_tripwordtype(char *word) for (i = 0; i < qualified_att_len; i++) { if (word[i] == '.' && ++numdots == 2) - { - cp[0] = (char *) palloc((i + 1) * sizeof(char)); - memset(cp[0], 0, (i + 1) * sizeof(char)); - memcpy(cp[0], word, i * sizeof(char)); - - /* - * qualified_att_len - one based position + 1 (null - * terminator) - */ - cp[1] = (char *) palloc((qualified_att_len - i) * sizeof(char)); - memset(cp[1], 0, (qualified_att_len - i) * sizeof(char)); - memcpy(cp[1], &word[i + 1], (qualified_att_len - i - 1) * sizeof(char)); - break; - } } - relvar = makeRangeVarFromNameList(stringToQualifiedNameList(cp[0], "plpgsql_parse_tripwordtype")); + cp[0] = (char *) palloc((i + 1) * sizeof(char)); + memcpy(cp[0], word, i * sizeof(char)); + cp[0][i] = '\0'; + + /* + * qualified_att_len - one based position + 1 (null terminator) + */ + cp[1] = (char *) palloc((qualified_att_len - i) * sizeof(char)); + memcpy(cp[1], &word[i + 1], (qualified_att_len - i - 1) * sizeof(char)); + cp[1][qualified_att_len - i - 1] = '\0'; + + relvar = makeRangeVarFromNameList(stringToQualifiedNameList(cp[0], + "plpgsql_parse_tripwordtype")); classOid = RangeVarGetRelid(relvar, true); if (!OidIsValid(classOid)) goto done; |