Re: [PATCH] block: cmdline-parser: add support for hidden disk space

From: kbuild test robot
Date: Mon Sep 28 2015 - 05:37:17 EST


Hi Shawn,

[auto build test results on v4.3-rc3 -- if it's inappropriate base, please ignore]

config: x86_64-randconfig-x005-201539 (attached as .config)
reproduce:
git checkout 937e3ebb4c7763e6120eda4a7e5b8c96bd710a9f
# save the attached .config to linux build tree
make ARCH=x86_64

All warnings (new ones prefixed by >>):

In file included from include/uapi/linux/stddef.h:1:0,
from include/linux/stddef.h:4,
from include/uapi/linux/posix_types.h:4,
from include/uapi/linux/types.h:13,
from include/linux/types.h:5,
from include/uapi/linux/capability.h:16,
from include/linux/capability.h:15,
from include/linux/sched.h:15,
from include/linux/blkdev.h:4,
from include/linux/cmdline-parser.h:10,
from block/cmdline-parser.c:8:
block/cmdline-parser.c: In function 'parse_parts':
block/cmdline-parser.c:136:9: error: 'subpart' undeclared (first use in this function)
if (!(subpart->flags & PF_HIDDEN))
^
include/linux/compiler.h:147:28: note: in definition of macro '__trace_if'
if (__builtin_constant_p((cond)) ? !!(cond) : \
^
>> block/cmdline-parser.c:136:3: note: in expansion of macro 'if'
if (!(subpart->flags & PF_HIDDEN))
^
block/cmdline-parser.c:136:9: note: each undeclared identifier is reported only once for each function it appears in
if (!(subpart->flags & PF_HIDDEN))
^
include/linux/compiler.h:147:28: note: in definition of macro '__trace_if'
if (__builtin_constant_p((cond)) ? !!(cond) : \
^
>> block/cmdline-parser.c:136:3: note: in expansion of macro 'if'
if (!(subpart->flags & PF_HIDDEN))
^

vim +/if +136 block/cmdline-parser.c

2 * Parse command line, get partition information
3 *
4 * Written by Cai Zhiyong <caizhiyong@xxxxxxxxxx>
5 *
6 */
7 #include <linux/export.h>
> 8 #include <linux/cmdline-parser.h>
9
10 static int parse_subpart(struct cmdline_subpart **subpart, char *partdef)
11 {
12 int ret = 0;
13 struct cmdline_subpart *new_subpart;
14
15 *subpart = NULL;
16
17 new_subpart = kzalloc(sizeof(struct cmdline_subpart), GFP_KERNEL);
18 if (!new_subpart)
19 return -ENOMEM;
20
21 if (*partdef == '-') {
22 new_subpart->size = (sector_t)(~0ULL);
23 partdef++;
24 } else {
25 new_subpart->size = (sector_t)memparse(partdef, &partdef);
26 if (new_subpart->size < (sector_t)PAGE_SIZE) {
27 pr_warn("cmdline partition size is invalid.");
28 ret = -EINVAL;
29 goto fail;
30 }
31 }
32
33 if (*partdef == '@') {
34 partdef++;
35 new_subpart->from = (sector_t)memparse(partdef, &partdef);
36 } else {
37 new_subpart->from = (sector_t)(~0ULL);
38 }
39
40 if (*partdef == '(') {
41 int length;
42 char *next = strchr(++partdef, ')');
43
44 if (!next) {
45 pr_warn("cmdline partition format is invalid.");
46 ret = -EINVAL;
47 goto fail;
48 }
49
50 length = min_t(int, next - partdef,
51 sizeof(new_subpart->name) - 1);
52 strncpy(new_subpart->name, partdef, length);
53 new_subpart->name[length] = '\0';
54
55 partdef = ++next;
56 } else
57 new_subpart->name[0] = '\0';
58
59 new_subpart->flags = 0;
60
61 if (!strncmp(partdef, "ro", 2)) {
62 new_subpart->flags |= PF_RDONLY;
63 partdef += 2;
64 }
65
66 if (!strncmp(partdef, "lk", 2)) {
67 new_subpart->flags |= PF_POWERUP_LOCK;
68 partdef += 2;
69 }
70
71 if (!strncmp(partdef, "hidden", 6)) {
72 new_subpart->flags |= PF_HIDDEN;
73 partdef += 6;
74 }
75
76 *subpart = new_subpart;
77 return 0;
78 fail:
79 kfree(new_subpart);
80 return ret;
81 }
82
83 static void free_subpart(struct cmdline_parts *parts)
84 {
85 struct cmdline_subpart *subpart;
86
87 while (parts->subpart) {
88 subpart = parts->subpart;
89 parts->subpart = subpart->next_subpart;
90 kfree(subpart);
91 }
92 }
93
94 static int parse_parts(struct cmdline_parts **parts, const char *bdevdef)
95 {
96 int ret = -EINVAL;
97 char *next;
98 int length;
99 struct cmdline_subpart **next_subpart;
100 struct cmdline_parts *newparts;
101 char buf[BDEVNAME_SIZE + 32 + 4];
102
103 *parts = NULL;
104
105 newparts = kzalloc(sizeof(struct cmdline_parts), GFP_KERNEL);
106 if (!newparts)
107 return -ENOMEM;
108
109 next = strchr(bdevdef, ':');
110 if (!next) {
111 pr_warn("cmdline partition has no block device.");
112 goto fail;
113 }
114
115 length = min_t(int, next - bdevdef, sizeof(newparts->name) - 1);
116 strncpy(newparts->name, bdevdef, length);
117 newparts->name[length] = '\0';
118 newparts->nr_subparts = 0;
119
120 next_subpart = &newparts->subpart;
121
122 while (next && *(++next)) {
123 bdevdef = next;
124 next = strchr(bdevdef, ',');
125
126 length = (!next) ? (sizeof(buf) - 1) :
127 min_t(int, next - bdevdef, sizeof(buf) - 1);
128
129 strncpy(buf, bdevdef, length);
130 buf[length] = '\0';
131
132 ret = parse_subpart(next_subpart, buf);
133 if (ret)
134 goto fail;
135
> 136 if (!(subpart->flags & PF_HIDDEN))
137 newparts->nr_subparts++;
138
139 next_subpart = &(*next_subpart)->next_subpart;

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

Attachment: .config.gz
Description: Binary data