On 01/29/2014 09:18 PM, Christian Kruse wrote:
> Hi,
>
> On 29/01/14 10:11, Jeff Janes wrote:
>> I'm getting this warning now with gcc (GCC) 4.4.7:
>
> Interesting. I don't get that warning. But the compiler is (formally)
> right.
>
>> pg_shmem.c: In function 'PGSharedMemoryCreate':
>> pg_shmem.c:332: warning: 'allocsize' may be used uninitialized in this
>> function
>> pg_shmem.c:332: note: 'allocsize' was declared here
Hmm, I didn't get that warning either.
> Attached patch should fix that.
That's not quite right. If the first mmap() fails, allocsize is set to
the rounded-up size, but the second mmap() uses the original size for
the allocation. So it returns a too high value to the caller.
Ugh, it's actually broken anyway :-(. The first allocation also passes
*size to mmap(), so the calculated rounded-up allocsize value is not
used for anything.
Fix pushed.
- Heikki