improve astreamer_gzip.c comments

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: improve astreamer_gzip.c comments
Date: 2024-08-13 13:39:53
Message-ID: CA+TgmoYTFAD0YTh4HC1Nuhn0YEyoQi0_CENFgVzAY_YReiSksQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Over on the security mailing list, Tom Lane expressed discontent about
a few things related to astreamer_gzip.c. Here's a patch to improve
the comments to try to address those concerns.

This ended up being discussed on -security because
f80b09bac87d6b49f5dbb6131da5fbd9b9773c5c moved the code, leading
Coverity to issue a new round of warnings about everything it doesn't
like about these files. Scrutinizing those warnings, Tom believed that
there might be a bug in astreamer_gzip_writer_new, because it's not
too obvious who is supposed to close which file descriptor. There's an
existing comment about the issue in astreamer_gzip_writer_finalize(),
but it was too far away from the code he was looking at for him to see
it right away, so add another comment pointing to it, using wording
suggested by Tom.

Tom also heavily criticized the header comment for
astreamer_gzip_writer_new(). I don't really think there's any big
problem, but I'm OK with his suggestion that we should instead
duplicate the comment from astreamer_plain_writer_new(), so this patch
does that. In response to further comments from Tom, I have also added
a further paragraph to try to make it clear that callers need to be
careful about how they use any FILE that they pass to this function.
It doesn't matter for current usage, because it's only used by
pg_basebackup when it's writing to stdout, and I don't anticipate that
it will matter for future usage either, but it doesn't hurt to mention
it, so here we go.

I'm posting this here rather than on the -security thread so that
others may comment if they wish.

--
Robert Haas
EDB: http://www.enterprisedb.com

Attachment Content-Type Size
astreamer-gzip-comments.patch application/octet-stream 1.5 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Jelte Fennema-Nio 2024-08-13 14:12:57 Create syscaches for pg_extension
Previous Message Ilia Evdokimov 2024-08-13 13:37:41 Re: Vacuum statistics