aboutsummaryrefslogtreecommitdiff
path: root/src/option.c
diff options
context:
space:
mode:
authorEliseo Martínez <eliseomarmol@gmail.com>2014-04-22 11:07:35 +0200
committerThiago de Arruda <tpadilha84@gmail.com>2014-04-22 16:03:21 -0300
commit5f60bf4eb2ba16e012bb938a2e2b4885445afebc (patch)
tree862c2e23185d39264d9506ba0587b1f78c809c64 /src/option.c
parent320fade35058202cd094a32612457ba76b524451 (diff)
downloadrneovim-5f60bf4eb2ba16e012bb938a2e2b4885445afebc.tar.gz
rneovim-5f60bf4eb2ba16e012bb938a2e2b4885445afebc.tar.bz2
rneovim-5f60bf4eb2ba16e012bb938a2e2b4885445afebc.zip
Broken build on 32 bit: Fix -Wshorten-64-to-32.
Problem: [ 48%] Building C object src/CMakeFiles/nvim.dir/os/mem.c.o /Users/eliseo/projects/os/neovim/src/os/mem.c:9:32: error: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'long_u' (aka 'unsigned long') [-Werror,-Wshorten-64-to-32] return uv_get_total_memory() >> 10; ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~^~~~~ Solution: Avoid conversion. Make function return proper uint64_t. Make users of the function accomodate the value if too big for them.
Diffstat (limited to 'src/option.c')
-rw-r--r--src/option.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/option.c b/src/option.c
index 17428ac697..4e40440386 100644
--- a/src/option.c
+++ b/src/option.c
@@ -2011,8 +2011,11 @@ void set_init_1(void)
#endif
{
#ifdef HAVE_TOTAL_MEM
- /* Use amount of memory available to Vim. */
- n = (os_get_total_mem_kib() >> 1);
+ /* Use half of amount of memory available to Vim. */
+ /* If too much to fit in long_u, get long_u max */
+ uint64_t available_kib = os_get_total_mem_kib();
+ n = available_kib / 2 > ULONG_MAX ? ULONG_MAX
+ : (long_u)(available_kib /2);
#else
n = (0x7fffffff >> 11);
#endif