In file included from ../../common/vm/vm_pagelist.c:59:0:
../../common/vm/vm_pagelist.c: In function 'page_ctr_sub_internal':
../../i86pc/vm/vm_dep.h:70:36: error: left shift of negative value [-Werror=shift-negative-value]
plcnt_inc_dec(pp, mtype, szc, -1l << PAGE_BSZS_SHIFT(szc), flags)
^
../../common/vm/vm_pagelist.c:879:2: note: in expansion of macro 'PLCNT_DECR'
PLCNT_DECR(pp, mnode, mtype, pp->p_szc, flags);
^~~~~~~~~~
cc1: all warnings being treated as errors
Loading file attachments...
0
0
1
0
1
Description
From
Last Updated
So the function takes a long as an argument. I suspect that the reason we're here is that the compiler ...
So the function takes a long as an argument. I suspect that the reason we're here is that the compiler doesn't want to shift the negative number and assume the two's complement layout necessarily or something similar.
Should we be casting the result of the ULONG_MAX << ... to a long explicitly?
I do not see why we should - the -1 is used just because it is giving us 0xffffffff and ULONG_MAX does the same except we are not depending on how the negative numbers are represented. And the point there is not about using the negative number, but about getting value with all bits set. And as constant -1UL does not really make any sense IMO:)
Right, I agree. We do not want to use values that are outside of the defined range of the type.
I just wanted to propose the most short form. For your purpose can be used ~0UL as well. It looks short and easy.
yes, the ~0UL would give us the same value, nevertheless, I think the named constant would be a bit more clear. As in general we rather use named constants anyhow. The value of using ~ is about that this operator is giving us ones complement of integer, but here we do specify the type explicitly anyhow. So as an author of this update, I would rather go with the named constant:)