Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+17 -13
+4 -2
drivers/block/rbd.c
··· 371 371 372 372 rbd_opts->notify_timeout = RBD_NOTIFY_TIMEOUT_DEFAULT; 373 373 374 - ret = ceph_parse_options(&opt, options, mon_addr, 374 + opt = ceph_parse_options(options, mon_addr, 375 375 mon_addr + strlen(mon_addr), 376 376 parse_rbd_opts_token, rbd_opts); 377 - if (ret < 0) 377 + if (IS_ERR(opt)) { 378 + ret = PTR_ERR(opt); 378 379 goto done_err; 380 + } 379 381 380 382 spin_lock(&node_lock); 381 383 rbdc = __rbd_client_find(opt);
+4 -2
fs/ceph/super.c
··· 334 334 *path += 2; 335 335 dout("server path '%s'\n", *path); 336 336 337 - err = ceph_parse_options(popt, options, dev_name, dev_name_end, 337 + *popt = ceph_parse_options(options, dev_name, dev_name_end, 338 338 parse_fsopt_token, (void *)fsopt); 339 - if (err) 339 + if (IS_ERR(*popt)) { 340 + err = PTR_ERR(*popt); 340 341 goto out; 342 + } 341 343 342 344 /* success */ 343 345 *pfsopt = fsopt;
+1 -1
include/linux/ceph/libceph.h
··· 207 207 extern struct kmem_cache *ceph_dentry_cachep; 208 208 extern struct kmem_cache *ceph_file_cachep; 209 209 210 - extern int ceph_parse_options(struct ceph_options **popt, char *options, 210 + extern struct ceph_options *ceph_parse_options(char *options, 211 211 const char *dev_name, const char *dev_name_end, 212 212 int (*parse_extra_token)(char *c, void *private), 213 213 void *private);
+8 -8
net/ceph/ceph_common.c
··· 277 277 return err; 278 278 } 279 279 280 - int ceph_parse_options(struct ceph_options **popt, char *options, 281 - const char *dev_name, const char *dev_name_end, 282 - int (*parse_extra_token)(char *c, void *private), 283 - void *private) 280 + struct ceph_options * 281 + ceph_parse_options(char *options, const char *dev_name, 282 + const char *dev_name_end, 283 + int (*parse_extra_token)(char *c, void *private), 284 + void *private) 284 285 { 285 286 struct ceph_options *opt; 286 287 const char *c; ··· 290 289 291 290 opt = kzalloc(sizeof(*opt), GFP_KERNEL); 292 291 if (!opt) 293 - return err; 292 + return ERR_PTR(-ENOMEM); 294 293 opt->mon_addr = kcalloc(CEPH_MAX_MON, sizeof(*opt->mon_addr), 295 294 GFP_KERNEL); 296 295 if (!opt->mon_addr) ··· 413 412 } 414 413 415 414 /* success */ 416 - *popt = opt; 417 - return 0; 415 + return opt; 418 416 419 417 out: 420 418 ceph_destroy_options(opt); 421 - return err; 419 + return ERR_PTR(err); 422 420 } 423 421 EXPORT_SYMBOL(ceph_parse_options); 424 422