[Ocfs2-tools-devel] [PATCH 06/25] libo2cb: Extend libo2cb api to learn ip address/port of a registered node
Joel Becker
Joel.Becker at oracle.com
Wed Jun 23 19:17:53 PDT 2010
On Wed, Jun 23, 2010 at 11:44:16AM -0700, Sunil Mushran wrote:
> +errcode_t o2cb_get_node_ip_string(const char *cluster_name,
> + const char *node_name,
> + char *ip_address, int count)
size_t len
> +{
> + char *p;
> + errcode_t ret;
> +
> + ret = o2cb_get_node_attribute(cluster_name, node_name, "ipv4_address",
> + ip_address, count - 1);
> + if (ret)
> + return ret;
> +
> + /* wipeout the last newline character */
> + if (strlen(ip_address)) {
> + p = ip_address + strlen(ip_address) - 1;
> + if (*p == '\n')
> + *p = '\0';
> + }
Why not write a strchomp() once instead of open-coding the
newline stripping everywhere?
Joel
--
Life's Little Instruction Book #182
"Be romantic."
Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
More information about the Ocfs2-tools-devel
mailing list