[Top][All Lists]

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

Re: [Qemu-trivial] [PATCH] tcg: mark tcg_out* and tcg_patch* with attrib

From: Peter Maydell
Subject: Re: [Qemu-trivial] [PATCH] tcg: mark tcg_out* and tcg_patch* with attribute 'unused'
Date: Sun, 8 Jun 2014 13:33:40 +0100

On 8 June 2014 13:11, Michael Tokarev <address@hidden> wrote:
> 07.06.2014 21:08, Peter Maydell wrote:
>> The tcg_out* and tcg_patch* functions are utility routines that may or
>> may not be used by a particular backend; mark them with the 'unused'
>> attribute to suppress spurious warnings if they aren't used.
>> Signed-off-by: Peter Maydell <address@hidden>
>> ---
>> Do we want to define a QEMU_UNUSED macro in compiler.h? We don't
>> seem to have done for the existing uses of this attribute in tree.
>>  tcg/tcg.c | 20 ++++++++++++--------
>>  1 file changed, 12 insertions(+), 8 deletions(-)
>> diff --git a/tcg/tcg.c b/tcg/tcg.c
>> index 2c5732d..fe55d05 100644
>> --- a/tcg/tcg.c
>> +++ b/tcg/tcg.c
>> @@ -125,19 +125,20 @@ static TCGRegSet tcg_target_available_regs[2];
>>  static TCGRegSet tcg_target_call_clobber_regs;
>> -static inline void tcg_out8(TCGContext *s, uint8_t v)
> Hm. Those are already #ifdef'ed, is it not enough?  Which architectures
> do not use functions which _are_ declared/defined?

The tcg x86 backend doesn't use all the tcg_patch* functions.
These ifdefs merely restrict the functions to only be provided
for the backends which conceivably could use them; there is
no requirement that the backend actually does use them.

> But I wonder, why to bother at all?  This "static inline foo() {..}" idiom
> is very common in header files, to define a function which may or may not
> be used, and no compiler warns about these.

clang 3.4 complains, which is why I'm fixing these. (It also found about
half a dozen genuine bugs and quite a bit of legitimately dead code,
which is why I think it's worth dealing with the handful of false positives
like this rather than removing the warning flag.)

-- PMM

reply via email to

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