作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
当编译我的模块时,我收到这个警告:
# make modules
CC [M] /jriskhome/repos/module/my_module.o
/jriskhome/repos/module/my_module.c: In function ‘_pci_probe’:
/jriskhome/repos/module/my_module.c:882:3: warning: format ‘%p’ expects argument of type ‘void *’, but argument 7 has type ‘resource_size_t’ [-Wformat=]
pr_info("Mapped Bar %d: %p -> %pa (%pa)", bar_number, BAR, pci_resource_start(dev, bar_number), pci_resource_len(dev, bar_number));
^
/jriskhome/repos/module/my_module.c:882:3: warning: format ‘%p’ expects argument of type ‘void *’, but argument 8 has type ‘resource_size_t’ [-Wformat=]
我咨询了这个:http://lxr.free-electrons.com/source/Documentation/printk-formats.txt?v=3.10 它看起来很适合我。内核和编译器版本是:
# uname -r
3.10.0-123.8.1.el7.x86_64
# gcc --version
gcc (GCC) 4.8.2 20140120 (Red Hat 4.8.2-16)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
我可以转换它,但想知道为什么不接受格式说明符。
最佳答案
根据您指向的文档:
For printing a phys_addr_t type (and its derivatives, such as resource_size_t) which can vary based on build options, regardless of the width of the CPU data path. Passed by reference.
您需要传递一个指向您的值的指针,而不是值本身。我认为为了实现上述与当前构建选项的独立性,这种扭曲是必要的。
关于linux - 为什么 `%pa` printk 格式说明符不能被 `resource_size_t` 类型识别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26531316/
当编译我的模块时,我收到这个警告: # make modules CC [M] /jriskhome/repos/module/my_module.o /jriskhome/repos/modu
我是一名优秀的程序员,十分优秀!