diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2017-04-16 23:23:44 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2017-04-16 23:23:44 -0400 |
commit | b6dd1271281ce856ab774fc0b491a92878e3b501 (patch) | |
tree | b18a6815271b38f83defd55390a30653697ed4bd /src/test | |
parent | c7d225e227aa481c30532b2954055afd1705af31 (diff) | |
download | postgresql-b6dd1271281ce856ab774fc0b491a92878e3b501.tar.gz postgresql-b6dd1271281ce856ab774fc0b491a92878e3b501.zip |
Ensure BackgroundWorker struct contents are well-defined.
Coverity complained because bgw.bgw_extra wasn't being filled in by
ApplyLauncherRegister(). The most future-proof fix is to memset the
whole BackgroundWorker struct to zeroes. While at it, let's apply the
same coding rule to other places that set up BackgroundWorker structs;
four out of five had the same or related issues.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/modules/test_shm_mq/setup.c | 1 | ||||
-rw-r--r-- | src/test/modules/worker_spi/worker_spi.c | 2 |
2 files changed, 3 insertions, 0 deletions
diff --git a/src/test/modules/test_shm_mq/setup.c b/src/test/modules/test_shm_mq/setup.c index 319a67f49aa..06c49bdb405 100644 --- a/src/test/modules/test_shm_mq/setup.c +++ b/src/test/modules/test_shm_mq/setup.c @@ -213,6 +213,7 @@ setup_background_workers(int nworkers, dsm_segment *seg) PointerGetDatum(wstate)); /* Configure a worker. */ + memset(&worker, 0, sizeof(worker)); worker.bgw_flags = BGWORKER_SHMEM_ACCESS; worker.bgw_start_time = BgWorkerStart_ConsistentState; worker.bgw_restart_time = BGW_NEVER_RESTART; diff --git a/src/test/modules/worker_spi/worker_spi.c b/src/test/modules/worker_spi/worker_spi.c index 421ec76ba36..9abfc714a99 100644 --- a/src/test/modules/worker_spi/worker_spi.c +++ b/src/test/modules/worker_spi/worker_spi.c @@ -343,6 +343,7 @@ _PG_init(void) NULL); /* set up common data for all our workers */ + memset(&worker, 0, sizeof(worker)); worker.bgw_flags = BGWORKER_SHMEM_ACCESS | BGWORKER_BACKEND_DATABASE_CONNECTION; worker.bgw_start_time = BgWorkerStart_RecoveryFinished; @@ -375,6 +376,7 @@ worker_spi_launch(PG_FUNCTION_ARGS) BgwHandleStatus status; pid_t pid; + memset(&worker, 0, sizeof(worker)); worker.bgw_flags = BGWORKER_SHMEM_ACCESS | BGWORKER_BACKEND_DATABASE_CONNECTION; worker.bgw_start_time = BgWorkerStart_RecoveryFinished; |