Small patch for snapmgr.c
От | Aleksander Alekseev |
---|---|
Тема | Small patch for snapmgr.c |
Дата | |
Msg-id | 20160408153217.379a0b7e@fujitsu обсуждение исходный текст |
Ответы |
Re: Small patch for snapmgr.c
|
Список | pgsql-hackers |
Hello Currently there is a following piece of code in snapmgr.c: ``` /* Copy all required fields */ snapshot = (Snapshot) MemoryContextAlloc(TopTransactionContext, size); snapshot->satisfies = HeapTupleSatisfiesMVCC; snapshot->xmin = serialized_snapshot->xmin; snapshot->xmax = serialized_snapshot->xmax; snapshot->xip = NULL; snapshot->xcnt = serialized_snapshot->xcnt; snapshot->subxip = NULL; /* ... */ /* Copy XIDs, if present. */ if (serialized_snapshot->xcnt > 0) { snapshot->xip = (TransactionId *) (snapshot + 1); memcpy(snapshot->xip, serialized_xids, serialized_snapshot->xcnt * sizeof(TransactionId)); } /* Copy SubXIDs, if present. */ if (serialized_snapshot->subxcnt > 0) { snapshot->subxip = snapshot->xip + serialized_snapshot->xcnt; memcpy(snapshot->subxip, ... ``` It assumes that subxcnt > 0 iff xcnt > 0. As I understand this is true. At least I hope so, otherwise this code can call memcpy passing NULL as a first argument. But Clang Static Analyzer is not aware of all this: http://afiskon.ru/s/db/5c956077e9_snapmgr.png I propose a patch that makes static analyzers happy and makes intention of this code a little more obvious. -- Best regards, Aleksander Alekseev http://eax.me/
Вложения
В списке pgsql-hackers по дате отправления: