Skip to content

Commit 4d5077f

Browse files
kvaneeshericvh
authored andcommitted
fs/9p: Cleanup option parsing in 9p
Instead of saying all integer argument option should be listed in the beginning move integer parsing to each option type. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
1 parent 5635fd0 commit 4d5077f

2 files changed

Lines changed: 31 additions & 14 deletions

File tree

‎fs/9p/v9fs.c‎

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,34 +132,53 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
132132
options = tmp_options;
133133

134134
while ((p = strsep(&options, ",")) != NULL) {
135-
int token;
135+
int token, r;
136136
if (!*p)
137137
continue;
138138
token = match_token(p, tokens, args);
139-
if (token < Opt_uname) {
140-
int r = match_int(&args[0], &option);
139+
switch (token) {
140+
case Opt_debug:
141+
r = match_int(&args[0], &option);
141142
if (r < 0) {
142143
P9_DPRINTK(P9_DEBUG_ERROR,
143-
"integer field, but no integer?\n");
144+
"integer field, but no integer?\n");
144145
ret = r;
145146
continue;
146147
}
147-
}
148-
switch (token) {
149-
case Opt_debug:
150148
v9ses->debug = option;
151149
#ifdef CONFIG_NET_9P_DEBUG
152150
p9_debug_level = option;
153151
#endif
154152
break;
155153

156154
case Opt_dfltuid:
155+
r = match_int(&args[0], &option);
156+
if (r < 0) {
157+
P9_DPRINTK(P9_DEBUG_ERROR,
158+
"integer field, but no integer?\n");
159+
ret = r;
160+
continue;
161+
}
157162
v9ses->dfltuid = option;
158163
break;
159164
case Opt_dfltgid:
165+
r = match_int(&args[0], &option);
166+
if (r < 0) {
167+
P9_DPRINTK(P9_DEBUG_ERROR,
168+
"integer field, but no integer?\n");
169+
ret = r;
170+
continue;
171+
}
160172
v9ses->dfltgid = option;
161173
break;
162174
case Opt_afid:
175+
r = match_int(&args[0], &option);
176+
if (r < 0) {
177+
P9_DPRINTK(P9_DEBUG_ERROR,
178+
"integer field, but no integer?\n");
179+
ret = r;
180+
continue;
181+
}
163182
v9ses->afid = option;
164183
break;
165184
case Opt_uname:

‎net/9p/client.c‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,21 +123,19 @@ static int parse_opts(char *opts, struct p9_client *clnt)
123123
options = tmp_options;
124124

125125
while ((p = strsep(&options, ",")) != NULL) {
126-
int token;
126+
int token, r;
127127
if (!*p)
128128
continue;
129129
token = match_token(p, tokens, args);
130-
if (token < Opt_trans) {
131-
int r = match_int(&args[0], &option);
130+
switch (token) {
131+
case Opt_msize:
132+
r = match_int(&args[0], &option);
132133
if (r < 0) {
133134
P9_DPRINTK(P9_DEBUG_ERROR,
134-
"integer field, but no integer?\n");
135+
"integer field, but no integer?\n");
135136
ret = r;
136137
continue;
137138
}
138-
}
139-
switch (token) {
140-
case Opt_msize:
141139
clnt->msize = option;
142140
break;
143141
case Opt_trans:

0 commit comments

Comments
 (0)