Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ jobs:
uses: hendrikmuhs/ccache-action@v1
with:
key: pg-${{ matrix.pg_version }}
append-timestamp: false

- name: Create PostgreSQL directory
run: sudo mkdir -p $PGHOME && sudo chown $USER $PGHOME
Expand Down Expand Up @@ -244,6 +245,7 @@ jobs:
uses: hendrikmuhs/ccache-action@v1
with:
key: pg-${{ matrix.pg_version }}
append-timestamp: false

- name: Create PostgreSQL directory
run: sudo mkdir -p $PGHOME && sudo chown $USER $PGHOME
Expand Down
49 changes: 1 addition & 48 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,53 +36,6 @@ jobs:
cppcheck \
--error-exitcode=1 \
--suppress=missingIncludeSystem \
--suppress=unknownMacro \
--quiet \
src/

clang-analyzer:
name: Clang Static Analyzer
runs-on: ubuntu-24.04
env:
PGHOME: /pg
steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
clang clang-tools \
build-essential \
libreadline-dev \
zlib1g-dev \
libzstd-dev \
liblz4-dev \
libssl-dev \
bison flex

- name: Clone PostgreSQL
run: |
git clone https://github.com/postgres/postgres.git \
-b REL_17_STABLE --depth=1

- name: Build PostgreSQL
run: |
sudo mkdir -p $PGHOME && sudo chown $USER $PGHOME
cd postgres
./configure --prefix=$PGHOME --without-icu
make -s -j$(nproc) install

- name: Run Clang Static Analyzer
run: |
export PATH=$PGHOME/bin:$PATH
export PG_CONFIG=$(which pg_config)
scan-build --status-bugs -o scan-results \
make USE_PGXS=1 top_srcdir=$GITHUB_WORKSPACE/postgres clean all

- name: Upload analysis results
if: failure()
uses: actions/upload-artifact@v4
with:
name: clang-analyzer-results
path: scan-results/
retention-days: 7
6 changes: 6 additions & 0 deletions src/archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,12 @@ push_file(WALSegno *xlogfile, const char *archive_status_dir,
rc = push_file_internal_gz(xlogfile, pg_xlog_dir, archive_dir,
overwrite, no_sync, compress_level,
archive_timeout);
#else
else
{
elog(ERROR, "Compression requested but pg_probackup was built without zlib support");
rc = 1; /* Not reached, but keeps compiler happy */
}
#endif

pg_atomic_write_u32(&xlogfile->done, 1);
Expand Down
4 changes: 4 additions & 0 deletions src/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -1651,6 +1651,7 @@ validate_file_pages(pgFile *file, const char *fullpath, XLogRecPtr stop_lsn,
if (!headers && file->n_headers > 0)
{
elog(WARNING, "Cannot get page headers for file \"%s\"", fullpath);
fclose(in);
return false;
}

Expand Down Expand Up @@ -1736,6 +1737,7 @@ validate_file_pages(pgFile *file, const char *fullpath, XLogRecPtr stop_lsn,
{
elog(WARNING, "Cannot read block %u file \"%s\": %s",
blknum, fullpath, strerror(errno));
fclose(in);
return false;
}

Expand Down Expand Up @@ -1763,6 +1765,7 @@ validate_file_pages(pgFile *file, const char *fullpath, XLogRecPtr stop_lsn,
{
elog(WARNING, "An error occured during decompressing block %u of file \"%s\": %s",
blknum, fullpath, errormsg);
fclose(in);
return false;
}

Expand All @@ -1775,6 +1778,7 @@ validate_file_pages(pgFile *file, const char *fullpath, XLogRecPtr stop_lsn,
}
elog(WARNING, "Page %u of file \"%s\" uncompressed to %d bytes. != BLCKSZ",
blknum, fullpath, uncompressed_size);
fclose(in);
return false;
}

Expand Down
6 changes: 3 additions & 3 deletions src/utils/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -3808,7 +3808,7 @@ fio_communicate(int in, int out)
if (hdr.size > buf_size) {
/* Extend buffer on demand */
buf_size = hdr.size;
buf = (char*)realloc(buf, buf_size);
buf = (char*)pgut_realloc(buf, buf_size);
}
IO_CHECK(fio_read_all(in, buf, hdr.size), hdr.size);
}
Expand Down Expand Up @@ -3863,7 +3863,7 @@ fio_communicate(int in, int out)
case FIO_READ: /* Read from the current position in file */
if ((size_t)hdr.arg > buf_size) {
buf_size = hdr.arg;
buf = (char*)realloc(buf, buf_size);
buf = (char*)pgut_realloc(buf, buf_size);
}
rc = read(fd[hdr.handle], buf, hdr.arg);
hdr.cop = FIO_SEND;
Expand Down Expand Up @@ -3999,7 +3999,7 @@ fio_communicate(int in, int out)
size_t filename_size = (size_t)hdr.size;
if (filename_size + hdr.arg > buf_size) {
buf_size = hdr.arg;
buf = (char*)realloc(buf, buf_size);
buf = (char*)pgut_realloc(buf, buf_size);
}
rc = readlink(buf, buf + filename_size, hdr.arg);
hdr.cop = FIO_READLINK;
Expand Down
6 changes: 1 addition & 5 deletions src/validate.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ do_validate_instance(InstanceState *instanceState)
/* Examine backups one by one and validate them */
for (i = 0; i < parray_num(backups); i++)
{
pgBackup *base_full_backup;
pgBackup *base_full_backup = NULL;

current_backup = (pgBackup *) parray_get(backups, i);

Expand Down Expand Up @@ -559,11 +559,7 @@ do_validate_instance(InstanceState *instanceState)
/* chain is whole, all parents are valid at first glance,
* current backup validation can proceed
*/
else
base_full_backup = tmp_backup;
}
else
base_full_backup = current_backup;

/* Do not interrupt, validate the next backup */
if (!lock_backup(current_backup, true, false))
Expand Down