mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
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.
This commit is contained in:
@ -435,6 +435,7 @@ LaunchParallelWorkers(ParallelContext *pcxt)
|
||||
oldcontext = MemoryContextSwitchTo(TopTransactionContext);
|
||||
|
||||
/* Configure a worker. */
|
||||
memset(&worker, 0, sizeof(worker));
|
||||
snprintf(worker.bgw_name, BGW_MAXLEN, "parallel worker for PID %d",
|
||||
MyProcPid);
|
||||
worker.bgw_flags =
|
||||
@ -446,7 +447,6 @@ LaunchParallelWorkers(ParallelContext *pcxt)
|
||||
sprintf(worker.bgw_function_name, "ParallelWorkerMain");
|
||||
worker.bgw_main_arg = UInt32GetDatum(dsm_segment_handle(pcxt->seg));
|
||||
worker.bgw_notify_pid = MyProcPid;
|
||||
memset(&worker.bgw_extra, 0, BGW_EXTRALEN);
|
||||
|
||||
/*
|
||||
* Start workers.
|
||||
|
Reference in New Issue
Block a user