memfd: Avoid Coverity warning about integer overflow
commit4f938cbd90e7cf3004a6877ce579a11a87a4aa33
authorPeter Maydell <peter.maydell@linaro.org>
Tue, 15 May 2018 17:27:29 +0000 (15 18:27 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 1 Jun 2018 13:13:46 +0000 (1 15:13 +0200)
tree672697abcc0d4dd6bb3a1d289951061f3dfe6ca6
parenteeaa6715050ed3f9cbedd322220f31570a503217
memfd: Avoid Coverity warning about integer overflow

Coverity complains about qemu_memfd_create() (CID 1385858) because
we calculate a bit position htsize which could be up to 63, but
then use it in "1 << htsize" which is a 32-bit integer calculation
and could push the 1 off the top of the value.

Silence the complaint bu using "1ULL"; this isn't a bug in
practice since a hugetlbsize of 4GB is not very plausible.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20180515172729.24564-1-peter.maydell@linaro.org>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
util/memfd.c