Mailing List Archive

Re: [PATCH] of: Mark property::value as const
Hi Stephen,

[auto build test WARNING on linus/master]
[also build test WARNING on v4.11-rc2 next-20170310]
[cannot apply to glikely/devicetree/next]
[.if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Stephen-Boyd/of-Mark-property-value-as-const/20170317-143414
config: sparc64-allmodconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=sparc64

All warnings (new ones prefixed by >>):

fs/openpromfs/inode.c: In function 'property_show':
>> fs/openpromfs/inode.c:74:16: warning: passing argument 1 of 'is_string' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
if (is_string(pval, len)) {
^~~~
fs/openpromfs/inode.c:48:12: note: expected 'unsigned char *' but argument is of type 'const void *'
static int is_string(unsigned char *p, int len)
^~~~~~~~~

vim +74 fs/openpromfs/inode.c

^1da177e Linus Torvalds 2005-04-16 58
3d824a46 David S. Miller 2006-06-25 59 return 0;
^1da177e Linus Torvalds 2005-04-16 60 }
^1da177e Linus Torvalds 2005-04-16 61
3d824a46 David S. Miller 2006-06-25 62 return 1;
3d824a46 David S. Miller 2006-06-25 63 }
^1da177e Linus Torvalds 2005-04-16 64
3d824a46 David S. Miller 2006-06-25 65 static int property_show(struct seq_file *f, void *v)
3d824a46 David S. Miller 2006-06-25 66 {
3d824a46 David S. Miller 2006-06-25 67 struct property *prop = f->private;
755d4871 Stephen Boyd 2017-03-14 68 const void *pval;
3d824a46 David S. Miller 2006-06-25 69 int len;
^1da177e Linus Torvalds 2005-04-16 70
3d824a46 David S. Miller 2006-06-25 71 len = prop->length;
3d824a46 David S. Miller 2006-06-25 72 pval = prop->value;
^1da177e Linus Torvalds 2005-04-16 73
3d824a46 David S. Miller 2006-06-25 @74 if (is_string(pval, len)) {
3d824a46 David S. Miller 2006-06-25 75 while (len > 0) {
3d824a46 David S. Miller 2006-06-25 76 int n = strlen(pval);
^1da177e Linus Torvalds 2005-04-16 77
3d824a46 David S. Miller 2006-06-25 78 seq_printf(f, "%s", (char *) pval);
^1da177e Linus Torvalds 2005-04-16 79
3d824a46 David S. Miller 2006-06-25 80 /* Skip over the NULL byte too. */
3d824a46 David S. Miller 2006-06-25 81 pval += n + 1;
3d824a46 David S. Miller 2006-06-25 82 len -= n + 1;

:::::: The code at line 74 was first introduced by commit
:::::: 3d824a46b7210ea3b0a13ab0d0fbd7f6e2e91ddf [OPENPROMFS]: Rewrite using in-kernel device tree and seq_file.

:::::: TO: David S. Miller <davem@davemloft.net>
:::::: CC: David S. Miller <davem@davemloft.net>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Re: [PATCH] of: Mark property::value as const [ In reply to ]
Hi Stephen,

[auto build test ERROR on linus/master]
[also build test ERROR on v4.11-rc2 next-20170310]
[cannot apply to glikely/devicetree/next]
[.if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Stephen-Boyd/of-Mark-property-value-as-const/20170317-143414
config: powerpc-allnoconfig (attached as .config)
compiler: powerpc-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=powerpc

All errors (new ones prefixed by >>):

arch/powerpc/kernel/pci_32.c: In function 'pcibios_make_OF_bus_map':
>> arch/powerpc/kernel/pci_32.c:141:10: error: passing argument 1 of 'memcpy' discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
memcpy(map_prop->value, pci_to_OF_bus_map, pci_bus_count);
^~~~~~~~
In file included from include/linux/string.h:18:0,
from include/uapi/linux/uuid.h:21,
from include/linux/uuid.h:19,
from include/linux/mod_devicetable.h:12,
from include/linux/pci.h:20,
from arch/powerpc/kernel/pci_32.c:6:
arch/powerpc/include/asm/string.h:21:15: note: expected 'void *' but argument is of type 'const void *'
extern void * memcpy(void *,const void *,__kernel_size_t);
^~~~~~
cc1: all warnings being treated as errors

vim +141 arch/powerpc/kernel/pci_32.c

e05b3b4a Paul Mackerras 2006-01-15 125 */
e05b3b4a Paul Mackerras 2006-01-15 126 for (i=0; i<pci_bus_count; i++)
e05b3b4a Paul Mackerras 2006-01-15 127 pci_to_OF_bus_map[i] = 0xff;
e05b3b4a Paul Mackerras 2006-01-15 128
e05b3b4a Paul Mackerras 2006-01-15 129 /* For each hose, we begin searching bridges */
a4c9e328 Kumar Gala 2007-06-27 130 list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
44ef3390 Stephen Rothwell 2007-12-10 131 struct device_node* node = hose->dn;
44ef3390 Stephen Rothwell 2007-12-10 132
e05b3b4a Paul Mackerras 2006-01-15 133 if (!node)
e05b3b4a Paul Mackerras 2006-01-15 134 continue;
e05b3b4a Paul Mackerras 2006-01-15 135 make_one_node_map(node, hose->first_busno);
e05b3b4a Paul Mackerras 2006-01-15 136 }
8c8dc322 Stephen Rothwell 2007-04-24 137 dn = of_find_node_by_path("/");
8c8dc322 Stephen Rothwell 2007-04-24 138 map_prop = of_find_property(dn, "pci-OF-bus-map", NULL);
a7f67bdf Jeremy Kerr 2006-07-12 139 if (map_prop) {
a7f67bdf Jeremy Kerr 2006-07-12 140 BUG_ON(pci_bus_count > map_prop->length);
a7f67bdf Jeremy Kerr 2006-07-12 @141 memcpy(map_prop->value, pci_to_OF_bus_map, pci_bus_count);
a7f67bdf Jeremy Kerr 2006-07-12 142 }
8c8dc322 Stephen Rothwell 2007-04-24 143 of_node_put(dn);
e05b3b4a Paul Mackerras 2006-01-15 144 #ifdef DEBUG
e05b3b4a Paul Mackerras 2006-01-15 145 printk("PCI->OF bus map:\n");
e05b3b4a Paul Mackerras 2006-01-15 146 for (i=0; i<pci_bus_count; i++) {
e05b3b4a Paul Mackerras 2006-01-15 147 if (pci_to_OF_bus_map[i] == 0xff)
e05b3b4a Paul Mackerras 2006-01-15 148 continue;
e05b3b4a Paul Mackerras 2006-01-15 149 printk("%d -> %d\n", i, pci_to_OF_bus_map[i]);

:::::: The code at line 141 was first introduced by commit
:::::: a7f67bdf2c9f24509b8e81e0f35573b611987c80 [POWERPC] Constify & voidify get_property()

:::::: TO: Jeremy Kerr <jk@ozlabs.org>
:::::: CC: Paul Mackerras <paulus@samba.org>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation