[Ocfs2-tools-devel] [PATCH 01/25] o2cb_config: Add support for the heartbeat stanza
Joel Becker
Joel.Becker at oracle.com
Wed Jun 23 18:53:06 PDT 2010
On Wed, Jun 23, 2010 at 11:44:11AM -0700, Sunil Mushran wrote:
> +gint o2cb_cluster_set_heartbeat_mode(O2CBCluster *cluster, const gchar *hb_mode)
> +{
> + gchar *new_hb_mode;
> + gchar *p;
> +
> + if (cluster->c_hb_mode && !strcmp(cluster->c_hb_mode, hb_mode))
> + return 0;
> +
Instead of:
> + new_hb_mode = g_strdup(hb_mode);
> + if (!new_hb_mode)
> + return -ENOMEM;
> +
> + p = new_hb_mode;
> + do {
> + *p = g_ascii_tolower(*p);
> + } while (*++p);
Just use new_hb_mode = g_ascii_strdown(hb_mode); It allocates a copy
and does the work.
> + g_free(cluster->c_hb_mode);
> + cluster->c_hb_mode = new_hb_mode;
Shouldn't you be checking valid_hb_modes here?
Joel
--
"The doctrine of human equality reposes on this: that there is no
man really clever who has not found that he is stupid."
- Gilbert K. Chesterson
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