Re: [PATCH 0/3] Generic libcephfs Java wrappers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 03/08/2012 06:28 PM, Noah Watkins wrote:

On Mar 8, 2012, at 6:16 PM, Greg Farnum wrote:

/* Returns a configuration value as a string.
* If len is positive, that is the maximum number of bytes we'll write into the
* buffer. If len == -1, we'll call malloc() and set *buf.
* Returns 0 on success, error code otherwise. Returns ENAMETOOLONG if the
* buffer is too short. */

Ah. Two things from that:
1) "If len == -1". Which it isn't, here.
2) There is no voodoo, that just isn't going to work. Either it was created incorrectly in reference to md_config_t::get_val, or else code got moved around without updating that documentation. :/ Options including char ** (as you said), char *&  (ewww), or…not doing that?

Anybody have thoughts on the right solution?

I am partial to APIs that put the burden on the caller to free/expand the buffer in response to -ENAMETOOLONG. /2cents

That sounds good to me. That comment exactly describes the behavior of md_config_t::get_val(). It would also be cleaner if len didn't have a special meaning and md_config_t::get_val() used strings instead of char*. It already uses strings internally, and only the librados C++ api actually uses len=-1.
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux