diff options
author | Alex Elder <elder@dreamhost.com> | 2012-01-24 11:08:36 -0500 |
---|---|---|
committer | Alex Elder <elder@dreamhost.com> | 2012-03-22 11:47:47 -0400 |
commit | ee57741c5209154b8ef124bcaa2496da1b69a988 (patch) | |
tree | 248a6e7bf259bb849f885f1ff4a82be74ab4913b /net/ceph/ceph_common.c | |
parent | 2107978668de13da484f7abc3f03516494c7fca9 (diff) |
rbd: make ceph_parse_options() return a pointer
ceph_parse_options() takes the address of a pointer as an argument
and uses it to return the address of an allocated structure if
successful. With this interface is not evident at call sites that
the pointer is always initialized. Change the interface to return
the address instead (or a pointer-coded error code) to make the
validity of the returned pointer obvious.
Signed-off-by: Alex Elder <elder@dreamhost.com>
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'net/ceph/ceph_common.c')
-rw-r--r-- | net/ceph/ceph_common.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c index 761ad9d6cc3b..621c3221b393 100644 --- a/net/ceph/ceph_common.c +++ b/net/ceph/ceph_common.c | |||
@@ -277,10 +277,11 @@ out: | |||
277 | return err; | 277 | return err; |
278 | } | 278 | } |
279 | 279 | ||
280 | int ceph_parse_options(struct ceph_options **popt, char *options, | 280 | struct ceph_options * |
281 | const char *dev_name, const char *dev_name_end, | 281 | ceph_parse_options(char *options, const char *dev_name, |
282 | int (*parse_extra_token)(char *c, void *private), | 282 | const char *dev_name_end, |
283 | void *private) | 283 | int (*parse_extra_token)(char *c, void *private), |
284 | void *private) | ||
284 | { | 285 | { |
285 | struct ceph_options *opt; | 286 | struct ceph_options *opt; |
286 | const char *c; | 287 | const char *c; |
@@ -289,7 +290,7 @@ int ceph_parse_options(struct ceph_options **popt, char *options, | |||
289 | 290 | ||
290 | opt = kzalloc(sizeof(*opt), GFP_KERNEL); | 291 | opt = kzalloc(sizeof(*opt), GFP_KERNEL); |
291 | if (!opt) | 292 | if (!opt) |
292 | return err; | 293 | return ERR_PTR(-ENOMEM); |
293 | opt->mon_addr = kcalloc(CEPH_MAX_MON, sizeof(*opt->mon_addr), | 294 | opt->mon_addr = kcalloc(CEPH_MAX_MON, sizeof(*opt->mon_addr), |
294 | GFP_KERNEL); | 295 | GFP_KERNEL); |
295 | if (!opt->mon_addr) | 296 | if (!opt->mon_addr) |
@@ -412,12 +413,11 @@ int ceph_parse_options(struct ceph_options **popt, char *options, | |||
412 | } | 413 | } |
413 | 414 | ||
414 | /* success */ | 415 | /* success */ |
415 | *popt = opt; | 416 | return opt; |
416 | return 0; | ||
417 | 417 | ||
418 | out: | 418 | out: |
419 | ceph_destroy_options(opt); | 419 | ceph_destroy_options(opt); |
420 | return err; | 420 | return ERR_PTR(err); |
421 | } | 421 | } |
422 | EXPORT_SYMBOL(ceph_parse_options); | 422 | EXPORT_SYMBOL(ceph_parse_options); |
423 | 423 | ||