List Info

Thread: Re: russell: branch 1.4 r83432 - in /branches/1.4: channels/ include/asterisk/ ma...




Re: russell: branch 1.4 r83432 - in /branches/1.4: channels/ include/asterisk/ ma...
country flaguser name
United Kingdom
2007-09-21 11:33:12
In article <20070921143722.B2D13A93B82lists.digium.internal>,
SVN commits to the Digium repositories <svn-commitslists.digium.com> wrote:
> Author: russell
> Date: Fri Sep 21 09:37:20 2007
> New Revision: 83432
> 
> URL: http://svn.digium.com/view/asterisk?view=rev&rev=8
3432
> Log:
> gcc 4.2 has a new set of warnings dealing with cosnt
pointers.  This set of
> changes gets all of Asterisk (minus chan_alsa for now)
to compile with gcc 4.2.
> (closes issue #10774, patch from qwell)

To take just one example from many, if the compiler is
noticing const-ness
of some args and insisting the prototype honours that,
shouldn't the const
be preserved, within the function too, so the compiler can
flag up attempts
to write via the pointer? e.g.

> Modified: branches/1.4/channels/chan_h323.c
> URL:
> http://svn.digium.com/view/asterisk/branches/1.4/chan
nels/chan_h323.c?view=diff&rev=83432&r1=83431&r2
=83432
>
============================================================
==================
> --- branches/1.4/channels/chan_h323.c (original)
> +++ branches/1.4/channels/chan_h323.c Fri Sep 21
09:37:20 2007
>  -303,9 +303,9 
>  	free(peer);
>  }
>  
> -static int oh323_simulate_dtmf_end(void *data)
> -{
> -	struct oh323_pvt *pvt = data;
> +static int oh323_simulate_dtmf_end(const void *data)
> +{
> +	struct oh323_pvt *pvt = (struct oh323_pvt *)data;

    const struct oh323_pvt *pvt = (const struct oh323_pvt
*)data;

And so on, with many other instances. An arduous task, I
know (is that
what you call a janitor project?), but I'm initially just
asking what
would be pedantically correct.

Cheers
Tony
-- 
Tony Mountifield
Work: tonysoftins.co.uk - http://www.softins.co.uk

Play: tonymountifield.org - http://tony.mountifield.o
rg

_______________________________________________

Sign up now for AstriCon 2007!  September 25-28th.  http://www.astricon.net/


--Bandwidth and Colocation Provided by http://www.api-digital.c
om--

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev

Re: russell: branch 1.4 r83432 - in /branches/1.4: channels/ include/asterisk/ ma...
country flaguser name
United States
2007-09-21 13:23:41
Tony Mountifield wrote:
>> Modified: branches/1.4/channels/chan_h323.c
>> URL:
>> http://svn.digium.com/view/asterisk/branches/1.4/chan
nels/chan_h323.c?view=diff&rev=83432&r1=83431&r2
=83432
>>
============================================================
==================
>> --- branches/1.4/channels/chan_h323.c (original)
>> +++ branches/1.4/channels/chan_h323.c Fri Sep 21
09:37:20 2007
>>  -303,9 +303,9 
>>  	free(peer);
>>  }
>>  
>> -static int oh323_simulate_dtmf_end(void *data)
>> -{
>> -	struct oh323_pvt *pvt = data;
>> +static int oh323_simulate_dtmf_end(const void
*data)
>> +{
>> +	struct oh323_pvt *pvt = (struct oh323_pvt
*)data;
> 
>     const struct oh323_pvt *pvt = (const struct
oh323_pvt *)data;
> 
> And so on, with many other instances. An arduous task,
I know (is that
> what you call a janitor project?), but I'm initially
just asking what
> would be pedantically correct.

The issue that gcc 4.2 is complaining about is demonstrated
here:

  const char *str = "hi";
  void *ptr = str;

Previously, it did not complaining about taking a pointer
that was defined as
const, and assigning it to a void pointer.  Now it does.

Back to your question - yes, it would be pedantically
correct to do what you
said.  However, if someone were to try to do it, it's going
to cause trouble.
The example you provided is a scheduler callback, and I know
those will modify
the object that gets passed in.

This patch got it to compile with the least amount of
effort.  However, it may
be more appropriate to go about fixing it up in a different
way.  I don't have
time to look at it in any more depth right now ...

-- 
Russell Bryant
Software Engineer
Digium, Inc.

_______________________________________________

Sign up now for AstriCon 2007!  September 25-28th.  http://www.astricon.net/


--Bandwidth and Colocation Provided by http://www.api-digital.c
om--

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )