[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 03/25] syntax-check: fix violations and re-enable sc_cast_of_

From: Eric Blake
Subject: Re: [PATCH 03/25] syntax-check: fix violations and re-enable sc_cast_of_argument_to_free.
Date: Tue, 15 Nov 2011 08:07:07 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110930 Thunderbird/7.0.1

On 11/15/2011 05:53 AM, Gary V. Vaughan wrote:
> * (local-checks-to-fix): Remove
> sc_cast_of_argument_to_free from list of disabled checks.
> * libltdl/config/ltmain.m4sh, libltdl/libltdl/lt__alloc.h,
> libltdl/lt__dirent.c: Casting argument to free is never
> necessary.

Not true; sometimes it is necessary to cast away const.  That is:

const char *str = malloc(n);

will cause a noisy compile, where the cast solves things.  However, it
is arguable that anyone assigning malloc() results to a const pointer is
not following const-correctness rules in the first place.  So if things
still compile with warnings, meaning we weren't ever passing a const
pointer to free in the first place within libtool, _and_ we are sure no
one else was using our [X]FREE macros as a way to cast away the const in
their code, then I'm okay with this patch.  (The alternative is to add a
syntax-check exception in for the particular files where we
define the macros that cast away const).

Eric Blake   address@hidden    +1-919-301-3266
Libvirt virtualization library

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]