Make static analysis happier (#4008)

Some small non-functional changes to make static analysis happy.
pull/4000/head
Jelte Fennema 2020-07-09 16:04:27 +02:00 committed by GitHub
parent 759e628dd5
commit 4c68ed4c33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 4 deletions

View File

@ -532,8 +532,9 @@ pg_get_tablecolumnoptionsdef_string(Oid tableRelationId)
ereport(ERROR, (errmsg("bad number of tuple descriptor attributes"))); ereport(ERROR, (errmsg("bad number of tuple descriptor attributes")));
} }
AttrNumber natts = tupleDescriptor->natts;
for (AttrNumber attributeIndex = 0; for (AttrNumber attributeIndex = 0;
attributeIndex < (AttrNumber) tupleDescriptor->natts; attributeIndex < natts;
attributeIndex++) attributeIndex++)
{ {
Form_pg_attribute attributeForm = TupleDescAttr(tupleDescriptor, attributeIndex); Form_pg_attribute attributeForm = TupleDescAttr(tupleDescriptor, attributeIndex);

View File

@ -1440,7 +1440,8 @@ TransformFunctionRTE(RangeTblEntry *rangeTblEntry)
{ {
ereport(ERROR, (errmsg("bad number of tuple descriptor attributes"))); ereport(ERROR, (errmsg("bad number of tuple descriptor attributes")));
} }
for (targetColumnIndex = 0; targetColumnIndex < (AttrNumber) tupleDesc->natts; AttrNumber natts = tupleDesc->natts;
for (targetColumnIndex = 0; targetColumnIndex < natts;
targetColumnIndex++) targetColumnIndex++)
{ {
FormData_pg_attribute *attribute = TupleDescAttr(tupleDesc, FormData_pg_attribute *attribute = TupleDescAttr(tupleDesc,

View File

@ -780,7 +780,12 @@ CitusRemoveDirectory(const char *filename)
/* we now have an empty directory or a regular file, remove it */ /* we now have an empty directory or a regular file, remove it */
if (S_ISDIR(fileStat.st_mode)) if (S_ISDIR(fileStat.st_mode))
{ {
removed = rmdir(filename); /*
* We ignore the TOCTUO race condition static analysis warning
* here, since we don't actually read the files or directories. We
* simply want to remove them.
*/
removed = rmdir(filename); /* lgtm[cpp/toctou-race-condition] */
if (errno == ENOTEMPTY || errno == EEXIST) if (errno == ENOTEMPTY || errno == EEXIST)
{ {
@ -789,7 +794,12 @@ CitusRemoveDirectory(const char *filename)
} }
else else
{ {
removed = unlink(filename); /*
* We ignore the TOCTUO race condition static analysis warning
* here, since we don't actually read the files or directories. We
* simply want to remove them.
*/
removed = unlink(filename); /* lgtm[cpp/toctou-race-condition] */
} }
if (removed != 0 && errno != ENOENT) if (removed != 0 && errno != ENOENT)