[Ocfs2-tools-devel] [PATCH 01/25] o2cb_config: Add support for the heartbeat stanza

Sunil Mushran sunil.mushran at oracle.com
Fri Jun 25 14:30:00 PDT 2010


On 06/23/2010 06:53 PM, Joel Becker wrote:
> 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?
>
>    

Good catch.



More information about the Ocfs2-tools-devel mailing list