* [alobakin:bitops 6/7] include/linux/bitops.h:52:11: warning: dereference of NULL 'page' [CWE-476]
@ 2022-06-18 8:16 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2022-06-18 8:16 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 34208 bytes --]
::::::
:::::: Manual check reason: "low confidence bisect report"
:::::: Manual check reason: "low confidence static check warning: include/linux/bitops.h:52:11: warning: dereference of NULL 'page' [CWE-476] [-Wanalyzer-null-dereference]"
::::::
CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
CC: linux-kernel(a)vger.kernel.org
TO: Alexander Lobakin <alexandr.lobakin@intel.com>
tree: https://github.com/alobakin/linux bitops
head: 9bd39b17ce49d350eed93a031e0da6389067013e
commit: a8846f7b2f123f210694db27803e17fae1c15cbe [6/7] bitops: let optimize out non-atomic bitops on compile-time constants
:::::: branch date: 18 hours ago
:::::: commit date: 20 hours ago
config: i386-randconfig-c001 (https://download.01.org/0day-ci/archive/20220618/202206181646.CiDIiBIc-lkp(a)intel.com/config)
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/alobakin/linux/commit/a8846f7b2f123f210694db27803e17fae1c15cbe
git remote add alobakin https://github.com/alobakin/linux
git fetch --no-tags alobakin bitops
git checkout a8846f7b2f123f210694db27803e17fae1c15cbe
# save the config file
ARCH=i386 KBUILD_USERCFLAGS='-fanalyzer -Wno-error'
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
gcc-analyzer warnings: (new ones prefixed by >>)
net/unix/af_unix.c: In function 'unix_dgram_disconnected':
>> net/unix/af_unix.c:208:35: warning: dereference of NULL 'other' [CWE-476] [-Wanalyzer-null-dereference]
208 | #define unix_peer(sk) (unix_sk(sk)->peer)
| ~~~~~~~~~~~~^~~~~~~
net/unix/af_unix.c:537:53: note: in expansion of macro 'unix_peer'
537 | if (!sock_flag(other, SOCK_DEAD) && unix_peer(other) == sk) {
| ^~~~~~~~~
'unix_seqpacket_sendmsg.part.0': events 1-2
|
| 2329 | static int unix_seqpacket_sendmsg(struct socket *sock, struct msghdr *msg,
| | ^~~~~~~~~~~~~~~~~~~~~~
| | |
| | (1) entry to 'unix_seqpacket_sendmsg.part.0'
|......
| 2345 | return unix_dgram_sendmsg(sock, msg, len);
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (2) calling 'unix_dgram_sendmsg' from 'unix_seqpacket_sendmsg.part.0'
|
+--> 'unix_dgram_sendmsg': events 3-4
|
| 1840 | static int unix_dgram_sendmsg(struct socket *sock, struct msghdr *msg,
| | ^~~~~~~~~~~~~~~~~~
| | |
| | (3) entry to 'unix_dgram_sendmsg'
|......
| 1856 | err = scm_send(sock, msg, &scm, false);
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (4) calling 'scm_send' from 'unix_dgram_sendmsg'
|
+--> 'scm_send': event 5
|
|include/net/scm.h:78:23:
| 78 | static __inline__ int scm_send(struct socket *sock, struct msghdr *msg,
| | ^~~~~~~~
| | |
| | (5) entry to 'scm_send'
|
'scm_send': event 6
|
|include/linux/fortify-string.h:274:12:
| 274 | if (p_size != (size_t)(-1) && p_size < size)
| | ^
| | |
| | (6) following 'false' branch...
|
'scm_send': event 7
|
| 47 | #define __underlying_memset __builtin_memset
| | ^
| | |
| | (7) ...to here
include/linux/fortify-string.h:281:9: note: in expansion of macro '__underlying_memset'
| 281 | __underlying_memset(p, c, __fortify_size); \
| | ^~~~~~~~~~~~~~~~~~~
include/linux/fortify-string.h:288:25: note: in expansion of macro '__fortify_memset_chk'
| 288 | #define memset(p, c, s) __fortify_memset_chk(p, c, s, \
| | ^~~~~~~~~~~~~~~~~~~~
include/net/scm.h:81:9: note: in expansion of macro 'memset'
| 81 | memset(scm, 0, sizeof(*scm));
| | ^~~~~~
|
'scm_send': events 8-9
|
| 84 | if (forcecreds)
| | ^
| | |
| | (8) following 'false' branch (when 'forcecreds == 0')...
| 85 | scm_set_cred(scm, task_tgid(current), current_uid(), current_gid());
| 86 | unix_get_peersec_dgram(sock, scm);
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (9) ...to here
|
<------+
|
'unix_dgram_sendmsg': events 10-11
|
|net/unix/af_unix.c:1856:15:
| 1856 | err = scm_send(sock, msg, &scm, false);
| | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (10) returning to 'unix_dgram_sendmsg' from 'scm_send'
| 1857 | if (err < 0)
| | ~
| | |
| | (11) following 'false' branch...
|
'unix_dgram_sendmsg': events 12-15
|
| 1860 | err = -EOPNOTSUPP;
| 1861 | if (msg->msg_flags&MSG_OOB)
| | ~
| | |
| | (13) following 'false' branch...
|......
| 1864 | if (msg->msg_namelen) {
| | ~~~~~~~~~~~~~~~~~
| | | |
| | | (14) ...to here
| | (15) following 'false' branch...
--
| | |
| | (12) returning to 'isolate_single_pageblock' from 'set_migratetype_isolate'
| 335 | isolate_pageblock, isolate_pageblock + pageblock_nr_pages);
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| 336 |
| 337 | if (ret)
| | ~
| | |
| | (13) following 'false' branch (when 'ret == 0')...
|......
| 353 | if (isolate_before) {
| | ~
| | |
| | (14) ...to here
| | (15) following 'false' branch (when 'isolate_before == 0')...
|
'isolate_single_pageblock': event 16
|
| 357 | if (!pfn_to_online_page(boundary_pfn - 1))
arch/x86/include/asm/page_32.h:19:35: note: in definition of macro 'pfn_valid'
| 19 | #define pfn_valid(pfn) ((pfn) < max_mapnr)
| | ^~~
mm/page_isolation.c:357:22: note: in expansion of macro 'pfn_to_online_page'
| 357 | if (!pfn_to_online_page(boundary_pfn - 1))
| | ^~~~~~~~~~~~~~~~~~
|
'isolate_single_pageblock': event 17
|
|include/linux/memory_hotplug.h:223:12:
| 223 | if (pfn_valid(pfn)) \
| | ^
| | |
| | (17) following 'true' branch...
mm/page_isolation.c:357:22: note: in expansion of macro 'pfn_to_online_page'
| 357 | if (!pfn_to_online_page(boundary_pfn - 1))
| | ^~~~~~~~~~~~~~~~~~
|
'isolate_single_pageblock': event 18
|
|include/asm-generic/memory_model.h:18:42:
| 18 | #define __pfn_to_page(pfn) (mem_map + ((pfn) - ARCH_PFN_OFFSET))
| | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (18) ...to here
include/asm-generic/memory_model.h:53:21: note: in expansion of macro '__pfn_to_page'
| 53 | #define pfn_to_page __pfn_to_page
| | ^~~~~~~~~~~~~
include/linux/memory_hotplug.h:224:27: note: in expansion of macro 'pfn_to_page'
| 224 | ___page = pfn_to_page(pfn); \
| | ^~~~~~~~~~~
mm/page_isolation.c:357:22: note: in expansion of macro 'pfn_to_online_page'
| 357 | if (!pfn_to_online_page(boundary_pfn - 1))
| | ^~~~~~~~~~~~~~~~~~
|
'isolate_single_pageblock': event 19
|
| 357 | if (!pfn_to_online_page(boundary_pfn - 1))
| | ^
| | |
| | (19) following 'false' branch (when '___page' is non-NULL)...
|
'isolate_single_pageblock': event 20
|
|cc1:
| (20): ...to here
|
'isolate_single_pageblock': events 21-22
|
| 361 | for (pfn = start_pfn; pfn < boundary_pfn;) {
| | ~~~~^~~~~~~~~~~~~~
| | |
| | (21) following 'true' branch (when 'pfn < boundary_pfn')...
| 362 | struct page *page = __first_valid_page(pfn, boundary_pfn - pfn);
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (22) ...to here
|
'isolate_single_pageblock': event 23
|
|include/linux/page-flags.h:316:48:
| 316 | return test_bit(PG_head, &page->flags) ||
|
'isolate_single_pageblock': events 24-25
|
|arch/x86/include/asm/bitops.h:207:22:
| 207 | (addr[nr >> _BITOPS_LONG_SHIFT])) != 0;
| | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (24) ...to here
| | (25) dereference of NULL 'page'
|
In file included from include/linux/kernel.h:22,
from arch/x86/include/asm/percpu.h:27,
from arch/x86/include/asm/preempt.h:6,
from include/linux/preempt.h:78,
from include/linux/spinlock.h:55,
from include/linux/mmzone.h:8,
from include/linux/gfp.h:6,
from include/linux/mm.h:7,
from mm/page_isolation.c:6:
>> include/linux/bitops.h:52:11: warning: dereference of NULL 'page' [CWE-476] [-Wanalyzer-null-dereference]
52 | __builtin_constant_p(*(const unsigned long *)(addr))) ? \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/bitops.h:61:41: note: in expansion of macro 'bitop'
61 | #define test_bit(nr, addr) bitop(_test_bit, nr, addr)
| ^~~~~
include/linux/page-flags.h:316:16: note: in expansion of macro 'test_bit'
316 | return test_bit(PG_head, &page->flags) ||
| ^~~~~~~~
'start_isolate_page_range': events 1-2
|
|mm/page_isolation.c:526:5:
| 526 | int start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn,
| | ^~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (1) entry to 'start_isolate_page_range'
|......
| 538 | ret = isolate_single_pageblock(isolate_start, flags, gfp_flags, false, skip_isolation);
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (2) calling 'isolate_single_pageblock' from 'start_isolate_page_range'
|
+--> 'isolate_single_pageblock': events 3-8
|
| 302 | static int isolate_single_pageblock(unsigned long boundary_pfn, int flags,
| | ^~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (3) entry to 'isolate_single_pageblock'
|......
| 314 | if (isolate_before)
| | ~
| | |
| | (4) following 'false' branch (when 'isolate_before == 0')...
|......
| 325 | zone = page_zone(pfn_to_page(isolate_pageblock));
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (5) ...to here
|......
| 331 | if (skip_isolation)
| | ~
| | |
| | (6) following 'false' branch (when 'skip_isolation == 0')...
|......
| 334 | ret = set_migratetype_isolate(pfn_to_page(isolate_pageblock), saved_mt, flags,
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (7) ...to here
| | (8) calling 'set_migratetype_isolate' from 'isolate_single_pageblock'
| 335 | isolate_pageblock, isolate_pageblock + pageblock_nr_pages);
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
+--> 'set_migratetype_isolate': events 9-10
|
| 147 | static int set_migratetype_isolate(struct page *page, int migratetype, int isol_flags,
| | ^~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (9) entry to 'set_migratetype_isolate'
|......
| 180 | if (!unmovable) {
| | ~
| | |
| | (10) following 'true' branch (when 'unmovable' is NULL)...
|
'set_migratetype_isolate': event 11
|
|include/asm-generic/memory_model.h:19:57:
| 19 | #define __page_to_pfn(page) ((unsigned long)((page) - mem_map) + \
| | ^
| | |
| | (11) ...to here
include/asm-generic/memory_model.h:52:21: note: in expansion of macro '__page_to_pfn'
| 52 | #define page_to_pfn __page_to_pfn
| | ^~~~~~~~~~~~~
include/linux/mmzone.h:103:39: note: in expansion of macro 'page_to_pfn'
| 103 | get_pfnblock_flags_mask(page, page_to_pfn(page), MIGRATETYPE_MASK)
| | ^~~~~~~~~~~
mm/page_isolation.c:182:26: note: in expansion of macro 'get_pageblock_migratetype'
| 182 | int mt = get_pageblock_migratetype(page);
| | ^~~~~~~~~~~~~~~~~~~~~~~~~
|
<------+
|
'isolate_single_pageblock': events 12-15
|
| 334 | ret = set_migratetype_isolate(pfn_to_page(isolate_pageblock), saved_mt, flags,
| | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (12) returning to 'isolate_single_pageblock' from 'set_migratetype_isolate'
| 335 | isolate_pageblock, isolate_pageblock + pageblock_nr_pages);
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| 336 |
| 337 | if (ret)
| | ~
| | |
| | (13) following 'false' branch (when 'ret == 0')...
|......
| 353 | if (isolate_before) {
| | ~
| | |
| | (14) ...to here
--
|
'get_parents': events 32-41
|
| 1216 | if ((ret = get_far_parent(tb, h + 1, &curf,
| | ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | | |
| | | (32) returning to 'get_parents' from 'get_far_parent'
| | (33) following 'false' branch (when 'ret == 0')...
| 1217 | &curcf,
| | ~~~~~~~
| 1218 | LEFT_PARENTS)) != CARRY_ON)
| | ~~~~~~~~~~~~~
|......
| 1222 | brelse(tb->FL[h]);
| | ~~~~~~~~~
| | |
| | (34) ...to here
| 1223 | tb->FL[h] = curf; /* New initialization of FL[h]. */
| | ~~~~~~~~~~~~~~~~
| | |
| | (35) 'curf' is NULL
| | (36) 'curf' is NULL
| 1224 | brelse(tb->CFL[h]);
| 1225 | tb->CFL[h] = curcf; /* New initialization of CFL[h]. */
| | ~~~~~~~~~~~~~~~~~~
| | |
| | (37) 'curf' is NULL
| | (38) 'curf' is NULL
|......
| 1234 | if (position == B_NR_ITEMS(PATH_H_PBUFFER(path, h + 1))) {
| | ~
| | |
| | (39) following 'true' branch...
|......
| 1242 | get_far_parent(tb, h + 1, &curf, &curcf,
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (40) ...to here
| | (41) calling 'get_far_parent' from 'get_parents'
| 1243 | RIGHT_PARENTS)) != CARRY_ON)
| | ~~~~~~~~~~~~~~
|
+--> 'get_far_parent': events 42-45
|
| 1023 | static int get_far_parent(struct tree_balance *tb,
| | ^~~~~~~~~~~~~~
| | |
| | (42) entry to 'get_far_parent'
|......
| 1086 | if (counter == FIRST_PATH_ELEMENT_OFFSET) {
| | ~
| | |
| | (43) following 'false' branch (when 'counter != 2')...
|......
| 1107 | if (buffer_locked(*pcom_father)) {
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (44) ...to here
| | (45) 'curf' is NULL
|
'get_far_parent': event 46
|
|include/linux/bitops.h:53:30:
| 49 | ((__builtin_constant_p(nr) && \
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| 50 | __builtin_constant_p((uintptr_t)(addr) != (uintptr_t)NULL) && \
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| 51 | (uintptr_t)(addr) != (uintptr_t)NULL && \
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| 52 | __builtin_constant_p(*(const unsigned long *)(addr))) ? \
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| 53 | const##op(nr, addr) : op(nr, addr))
| | ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
| | |
| | (46) following 'false' branch...
include/linux/bitops.h:61:41: note: in expansion of macro 'bitop'
| 61 | #define test_bit(nr, addr) bitop(_test_bit, nr, addr)
| | ^~~~~
include/linux/buffer_head.h:99:16: note: in expansion of macro 'test_bit'
| 99 | return test_bit(BH_##bit, &(bh)->b_state); \
| | ^~~~~~~~
include/linux/buffer_head.h:123:1: note: in expansion of macro 'BUFFER_FNS'
| 123 | BUFFER_FNS(Lock, locked)
| | ^~~~~~~~~~
|
'get_far_parent': events 47-48
|
|arch/x86/include/asm/bitops.h:207:22:
| 207 | (addr[nr >> _BITOPS_LONG_SHIFT])) != 0;
| | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (47) ...to here
| | (48) dereference of NULL '*pcom_father'
|
In file included from include/linux/log2.h:12,
from arch/x86/include/asm/div64.h:8,
from include/linux/math.h:6,
from include/linux/math64.h:6,
from include/linux/time.h:6,
from fs/reiserfs/fix_node.c:5:
>> include/linux/bitops.h:52:32: warning: dereference of NULL 'curf' [CWE-476] [-Wanalyzer-null-dereference]
52 | __builtin_constant_p(*(const unsigned long *)(addr))) ? \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/bitops.h:61:41: note: in expansion of macro 'bitop'
61 | #define test_bit(nr, addr) bitop(_test_bit, nr, addr)
| ^~~~~
include/linux/buffer_head.h:99:16: note: in expansion of macro 'test_bit'
99 | return test_bit(BH_##bit, &(bh)->b_state); \
| ^~~~~~~~
include/linux/buffer_head.h:123:1: note: in expansion of macro 'BUFFER_FNS'
123 | BUFFER_FNS(Lock, locked)
| ^~~~~~~~~~
'fix_nodes': events 1-2
|
|fs/reiserfs/fix_node.c:2545:5:
| 2545 | int fix_nodes(int op_mode, struct tree_balance *tb,
| | ^~~~~~~~~
| | |
| | (1) entry to 'fix_nodes'
|......
| 2574 | if (FILESYSTEM_CHANGED_TB(tb))
| | ~
| | |
| | (2) following 'false' branch...
|
'fix_nodes': event 3
|
|include/linux/buffer_head.h:99:35:
| 99 | return test_bit(BH_##bit, &(bh)->b_state); \
include/linux/bitops.h:50:44: note: in definition of macro 'bitop'
| 50 | __builtin_constant_p((uintptr_t)(addr) != (uintptr_t)NULL) && \
| | ^~~~
include/linux/buffer_head.h:99:16: note: in expansion of macro 'test_bit'
| 99 | return test_bit(BH_##bit, &(bh)->b_state); \
| | ^~~~~~~~
include/linux/buffer_head.h:123:1: note: in expansion of macro 'BUFFER_FNS'
| 123 | BUFFER_FNS(Lock, locked)
| | ^~~~~~~~~~
|
'fix_nodes': event 4
|
|fs/reiserfs/fix_node.c:2625:12:
| 2625 | if (get_mem_for_virtual_node(tb) == REPEAT_SEARCH)
| | ^
| | |
| | (4) following 'false' branch...
|
'fix_nodes': event 5
|
|cc1:
| (5): ...to here
|
'fix_nodes': events 6-10
|
| 2630 | for (h = 0; h < MAX_HEIGHT && tb->insert_size[h]; h++) {
| | ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
| | |
| | (6) following 'true' branch...
| 2631 | ret = get_direct_parent(tb, h);
| | ~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (7) ...to here
| 2632 | if (ret != CARRY_ON)
| | ~
| | |
| | (8) following 'false' branch (when 'ret == 0')...
|......
| 2635 | ret = check_balance(op_mode, tb, h, item_num,
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (9) ...to here
| | (10) calling 'check_balance' from 'fix_nodes'
| 2636 | pos_in_item, ins_ih, data);
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
+--> 'check_balance': events 11-14
|
| 2061 | static int check_balance(int mode,
| | ^~~~~~~~~~~~~
| | |
| | (11) entry to 'check_balance'
|......
| 2082 | if (tb->insert_size[h] > 0)
| | ~
| | |
| | (12) following 'true' branch...
| 2083 | return ip_check_balance(tb, h);
| | ~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (13) ...to here
| | (14) calling 'ip_check_balance' from 'check_balance'
|
+--> 'ip_check_balance': events 15-18
|
| 1324 | static int ip_check_balance(struct tree_balance *tb, int h)
| | ^~~~~~~~~~~~~~~~
| | |
| | (15) entry to 'ip_check_balance'
|......
| 1377 | if (!Sh) {
| | ~
vim +/page +52 include/linux/bitops.h
521611f961a7dd Alexander Lobakin 2022-05-09 35
a8846f7b2f123f Alexander Lobakin 2022-05-12 36 /*
a8846f7b2f123f Alexander Lobakin 2022-05-12 37 * Many architecture-specific non-atomic bitops contain inline asm code and due
a8846f7b2f123f Alexander Lobakin 2022-05-12 38 * to that the compiler can't optimize them to compile-time expressions or
a8846f7b2f123f Alexander Lobakin 2022-05-12 39 * constants. In contrary, gen_*() helpers are defined in pure C and compilers
a8846f7b2f123f Alexander Lobakin 2022-05-12 40 * optimize them just well.
a8846f7b2f123f Alexander Lobakin 2022-05-12 41 * Therefore, to make `unsigned long foo = 0; __set_bit(BAR, &foo)` effectively
a8846f7b2f123f Alexander Lobakin 2022-05-12 42 * equal to `unsigned long foo = BIT(BAR)`, pick the generic C alternative when
a8846f7b2f123f Alexander Lobakin 2022-05-12 43 * the arguments can be resolved at compile time. That expression itself is a
a8846f7b2f123f Alexander Lobakin 2022-05-12 44 * constant and doesn't bring any functional changes to the rest of cases.
a8846f7b2f123f Alexander Lobakin 2022-05-12 45 * The casts to `uintptr_t` are needed to mitigate `-Waddress` warnings when
a8846f7b2f123f Alexander Lobakin 2022-05-12 46 * passing a bitmap from .bss or .data (-> `!!addr` is always true).
a8846f7b2f123f Alexander Lobakin 2022-05-12 47 */
54dcb250626d4e Alexander Lobakin 2022-06-16 48 #define bitop(op, nr, addr) \
a8846f7b2f123f Alexander Lobakin 2022-05-12 49 ((__builtin_constant_p(nr) && \
a8846f7b2f123f Alexander Lobakin 2022-05-12 50 __builtin_constant_p((uintptr_t)(addr) != (uintptr_t)NULL) && \
a8846f7b2f123f Alexander Lobakin 2022-05-12 51 (uintptr_t)(addr) != (uintptr_t)NULL && \
a8846f7b2f123f Alexander Lobakin 2022-05-12 @52 __builtin_constant_p(*(const unsigned long *)(addr))) ? \
a8846f7b2f123f Alexander Lobakin 2022-05-12 53 const##op(nr, addr) : op(nr, addr))
54dcb250626d4e Alexander Lobakin 2022-06-16 54
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-18 8:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-18 8:16 [alobakin:bitops 6/7] include/linux/bitops.h:52:11: warning: dereference of NULL 'page' [CWE-476] kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.