This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Home Products Support Community News


Re: [Xen-API] [PATCH] imported patch removing-warnings

To: Rok Strnisa <rok.strnisa@xxxxxxxxxx>
Subject: Re: [Xen-API] [PATCH] imported patch removing-warnings
From: Jonathan Knowles <jonathan.knowles@xxxxxxxxxxxxx>
Date: Wed, 10 Nov 2010 09:12:07 +0000
Cc: "xen-api@xxxxxxxxxxxxxxxxxxx" <xen-api@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Wed, 10 Nov 2010 01:12:47 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <403764544b97988f2e3d.1289323667@rok-desktop>
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
References: <403764544b97988f2e3d.1289323667@rok-desktop>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv: Gecko/20100915 Lightning/1.0b2 Thunderbird/3.1.4
Hi Rok

Thanks for looking into this area. It's good to see someone tackle
our accumulated backlog of compiler warnings. :)

I have some reservations about this patch, as it stands:

In the case where you get an "unused identifier" warning, or an
"unused variable" warning, then it's often better to remove the
assignment /entirely/. For example:

On 09/11/10 17:27, Rok Strnisa wrote:
- let record_name = OU.ocaml_of_record_name obj.DT.name in
+ let _ (* record_name *) = OU.ocaml_of_record_name obj.DT.name in

If you can be sure that evaluation of the expression on the
right-hand-side of the assignment creates no side-effects,
then it should be safe to completely remove the assignment.

For example, we can replace the above change with the following

- let record_name = OU.ocaml_of_record_name obj.DT.name in

Using the "_" identifier has a tendency, unfortunately, to mask
the problem, because we no longer have an easy way to identify
wasted assignments (which the compiler warnings previously told
us about).

Rok, would you be able to revise this patch a little, so that
it completely removes all the non-side-effecting assignments to
unused identifiers?


xen-api mailing list