[Openais] new gcc warning uncovers nasty bug

Steven Dake sdake at redhat.com
Tue Jun 2 10:41:14 PDT 2009


good for merge


On Tue, 2009-06-02 at 18:04 +0200, Jim Meyering wrote:
> Building with this bleeding edge gcc,
> 
>   gcc version 4.5.0 20090601 (experimental) (GCC)
> 
> I saw this new warning:
> 
>   totempg.c: In function 'totempg_groups_join':
>   totempg.c:1038:23: warning: operation on 'instance->groups_cnt' may be undefined
> 
> Looking at that code, I see why.
> FYI, this was introduced 11 months ago, with this change:
> svn+ssh://svn.fedorahosted.org/svn/corosync/trunk@1582
> 
> Here's the fix:
> 
> From fcbd110557905142b87a5e47bdd8c140441aa848 Mon Sep 17 00:00:00 2001
> From: Jim Meyering <meyering at redhat.com>
> Date: Tue, 2 Jun 2009 17:58:22 +0200
> Subject: [PATCH] totempg.c: don't truncate group list
> 
> * exec/totempg.c (totempg_groups_join): Fix typo s/=/+/ that
> would mistakenly truncate totempg group list.
> ---
>  exec/totempg.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/exec/totempg.c b/exec/totempg.c
> index 7be9943..2ea45ff 100644
> --- a/exec/totempg.c
> +++ b/exec/totempg.c
> @@ -1035,7 +1035,7 @@ int totempg_groups_join (
>  	memcpy (&new_groups[instance->groups_cnt],
>  		groups, group_cnt * sizeof (struct totempg_group));
>  	instance->groups = new_groups;
> -	instance->groups_cnt = instance->groups_cnt = group_cnt;
> +	instance->groups_cnt += group_cnt;
> 
>  	hdb_handle_put (&totempg_groups_instance_database, handle);
> 
> --
> 1.6.3.1.308.g426b5
> _______________________________________________
> Openais mailing list
> Openais at lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/openais



More information about the Openais mailing list