Concerning commit 04783dc7025 fix 'ignoring return value' compiler warnings

I'm curious as to why you didn't use the GCC_DIAG_IGNORE() mechanism 
that you introduced a few commits later.  Does it not work for this?  or 
perhaps you hadn't come up with the scheme yet at the time this commit 
was made?  I think the GCC_DIAG_IGNORE is slightly preferable, if it 
works, as it doesn't involve having to introduce a variable that gets 
thrown away, and which the compiler may or may not be smart enough to 
optimize out.

commit 04783dc7025287c5d75ab531602c7ec786a1e787
*Author: David Mitchell <davem@iabyn.com>
  Date:   Sun Nov 24 19:44:41 2013 +0000

      fix 'ignoring return value' compiler warnings

      Various system functions like write() are marked with the
      __warn_unused_result__ attribute, which causes an 'ignoring return 
value'
      warning to be emitted, even if the function call result is cast to 
(void).

      The generic solution seems to be

          int rc = write(...);
          PERL_UNUSED_VAR(rc);
0
public
2/6/2014 7:19:23 PM
perl.perl5.porters 48287 articles. 1 followers. Follow

3 Replies
402 Views

Similar Articles

[PageSpeed] 27

On Thu, Feb 06, 2014 at 12:19:23PM -0700, Karl Williamson wrote:
> I'm curious as to why you didn't use the GCC_DIAG_IGNORE() mechanism
> that you introduced a few commits later.  Does it not work for this?
> or perhaps you hadn't come up with the scheme yet at the time this
> commit was made?  I think the GCC_DIAG_IGNORE is slightly
> preferable, if it works, as it doesn't involve having to introduce a
> variable that gets thrown away, and which the compiler may or may
> not be smart enough to optimize out.
> 
> commit 04783dc7025287c5d75ab531602c7ec786a1e787
> *Author: David Mitchell <davem@iabyn.com>
>  Date:   Sun Nov 24 19:44:41 2013 +0000
> 
>      fix 'ignoring return value' compiler warnings
> 
>      Various system functions like write() are marked with the
>      __warn_unused_result__ attribute, which causes an 'ignoring
> return value'
>      warning to be emitted, even if the function call result is cast
> to (void).
> 
>      The generic solution seems to be
> 
>          int rc = write(...);
>          PERL_UNUSED_VAR(rc);

I think it was before I invented GCC_DIAG_IGNORE. But anyway, I
think GCC_DIAG_IGNORE is a desperate measure of last resort. It's big
and clunky, and only works for gcc (and possibly clang)

-- 
Music lesson: a symbiotic relationship whereby a pupil's embellishments
concerning the amount of practice performed since the last lesson are
rewarded with embellishments from the teacher concerning the pupil's
progress over the corresponding period.
0
davem
2/6/2014 8:28:55 PM
On 02/06/2014 01:28 PM, Dave Mitchell wrote:
> On Thu, Feb 06, 2014 at 12:19:23PM -0700, Karl Williamson wrote:
>> I'm curious as to why you didn't use the GCC_DIAG_IGNORE() mechanism
>> that you introduced a few commits later.  Does it not work for this?
>> or perhaps you hadn't come up with the scheme yet at the time this
>> commit was made?  I think the GCC_DIAG_IGNORE is slightly
>> preferable, if it works, as it doesn't involve having to introduce a
>> variable that gets thrown away, and which the compiler may or may
>> not be smart enough to optimize out.
>>
>> commit 04783dc7025287c5d75ab531602c7ec786a1e787
>> *Author: David Mitchell <davem@iabyn.com>
>>   Date:   Sun Nov 24 19:44:41 2013 +0000
>>
>>       fix 'ignoring return value' compiler warnings
>>
>>       Various system functions like write() are marked with the
>>       __warn_unused_result__ attribute, which causes an 'ignoring
>> return value'
>>       warning to be emitted, even if the function call result is cast
>> to (void).
>>
>>       The generic solution seems to be
>>
>>           int rc = write(...);
>>           PERL_UNUSED_VAR(rc);
>
> I think it was before I invented GCC_DIAG_IGNORE. But anyway, I
> think GCC_DIAG_IGNORE is a desperate measure of last resort. It's big
> and clunky, and only works for gcc (and possibly clang)
>

I don't understand this.  There's no code generated, and it only does 
anything at all for the compiler which causes the problem, so I don't 
see how it is "big and clunky"
0
public
3/10/2014 8:14:32 PM
On Mon, Mar 10, 2014 at 02:14:32PM -0600, Karl Williamson wrote:
> On 02/06/2014 01:28 PM, Dave Mitchell wrote:
> >I think it was before I invented GCC_DIAG_IGNORE. But anyway, I
> >think GCC_DIAG_IGNORE is a desperate measure of last resort. It's big
> >and clunky, and only works for gcc (and possibly clang)
> >
> 
> I don't understand this.  There's no code generated, and it only
> does anything at all for the compiler which causes the problem, so I
> don't see how it is "big and clunky"

I meant it's big and clunky in terms of messing up the source code: you
have a line wrapped in two extra lines of extraneous gumpf just to shut up
a warning for one specific compiler.

    GCC_DIAG_IGNORE(-Wformat-nonliteral);
    Perl_warner(aTHX_ packWARN(WARN_RESERVED), PL_warn_reserved, PL_tokenbuf);
    GCC_DIAG_RESTORE;

So I see it as method of last resort.



-- 
My Dad used to say 'always fight fire with fire', which is probably why
he got thrown out of the fire brigade.
0
davem
3/10/2014 10:11:30 PM
Reply:

Similar Artilces:

''''''''''''''''''''
Name: haznen Email: haznenatyahoodotcom Product: Gran Paradiso Alpha 8 Summary: '''''''''''''''''''' Comments: '''''''''''''''''''''''''''''''''''' Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20061204 UGES/1.7.2.0 GranParadiso/3.0a1 From URL: http://www.mozilla.org/projects/granparadiso/ Note to readers: Hendrix gives...

Warning: element 'compilation' has invalid child element 'compilers'
All-- Please help. I am getting a strange warning in my Web.config file. This is the warning... Warning 1 The element 'compilation' has invalid child element 'compilers'. List of possible elements expected: 'assemblies, buildProviders, codeSubDirectories, expressionBuilders'. C:\hosting\webhost4life\member\mkamoski\S07\web.config 25 5 C:\...\S07\ This is the element... <compilation defaultLanguage="c#" debug="true">   <compilers>     <compiler language="c#" type="Microsoft.CSharp.CSharpCodeProvider, System, Version...

table_info('','','','%') cannot return any types
I was recently confirming table_info special cases and discovered the case for getting table_types cannot work. table_info('','','','%') should return a list of table types but it returns a list of empty strings instead: my @types = $h->tables('', '', '', '%'); print "all types:\n", join("xxx\n", @types), "\n"; # should output something like: # "dbo" # "INFORMATION_SCHEMA" # "sys" # and actually outputs: xxx xxx It seems to be down to the following ...

'''''
Name: mario Email: ramar17atfastwebnetdotit Product: Gran Paradiso Alpha 2 Summary: ''''' Comments: K: Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a2) Gecko/20070206 GranParadiso/3.0a2 ...

Web.config warning: The element 'compilation' has invalid child element 'compilers'.
After migrating my ASP.NET 1.1 project to 2.0, I have the following warning:         The element 'compilation' has invalid child element 'compilers'. List of possible elements expected: 'assemblies, buildProviders, codeSubDirectories, expressionBuilders'. I read in another post that it is not necessary.  Is this correct?  Should I remove it?  I ask because in that post, the poster made it sound as though they already had that section in their web.config.  I did not, the wizard added it to my web.config.  So I don't understand why ...

'Value' should be between 'minimum' and 'maximum'.
I'm attempting to invoke with parameters:  Dim thing2 As New mydelsubPBStep(AddressOf pbStep) Me.Invoke(thing2, "setMax", dt.Rows.Count)      <---- this is where the error occurs   the delegate looks like this: Private Delegate Sub mydelsubPBStep(ByVal mode As String, ByVal value As Integer)   the function it's calling looks like this:Private Sub pbStep(ByVal mode As String, ByVal value As Integer) Select Case mode.ToLower Case "clear" ProgressBar1.Value = 0 Case "step" ProgressBar1.PerformStep() L...

Compile time error: "[value] is not a valid value for the 'color' (or 'background-color') property
Greetings:  Have tried searching for anything to do with this error message and I either get far too many results to search or nothing at all. So here's the problem. In a CSS style sheet I have built various styles selecting colours from the IDE's color picker/web colors tab. Two of the colors for example are 'named' "cornflower blue" and "crimson". If I preview a page in the browser with styles containing these 'values' (which are written into the style sheet as their names not Hex or RGB values), everything is fine. But if I run the app in debug...the compiler with throw these error...

value of variable switches from ' ' to 'value'
--------------000108090907030800060105 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit I'm trying to figure out what exactly a script I wrote (see the attachment) is doing by stepping through it in the debugger. I have an array of dates in %Y-%m-%d format for each of the last 7 days. So, for instance, the range of dates for today (June 17, 2007) is from the 10th to the 16th. I then take these dates and use them to find work tickets in our ticketing system which were last updated on the day currently being checked. So, the first date would be 200...

how to specify 'near to' value and 'from-to' value
Hi, I have a property search  with a ability to enter minimum and maximum price and also a sq. m. area size. How do I implement this in my sql query  - 'from-to' value and 'near to' value ThanksAndy Current project: Cycle round the world  Hi,you could use the BETWEEN statement. SELECT PropertyName, Price WHERE Price BETWEEN 100 AND 500  for your "NEAR TO" search you also could use the BETWEEN statement. SELECT PropertyName, Price WHERE Price BETWEEN @SearchValue - 100 AND @SearchValue + 100 Hope this helps :-) ...

superreview requested: [Bug 228510] Warning ``function getContentTypeFromHeaders does not always return a value'' [xs] in file ``chrome://navigator/content/pageInfo.js'', line 951, character 0. : [A #2
Serge GAUTHERIE <gautheri@noos.fr> has asked Boris Zbarsky (not in town, no tree) <bz-vacation@mit.edu> for superreview: Bug 228510: Warning ``function getContentTypeFromHeaders does not always return a value'' [xs] in file ``chrome://navigator/content/pageInfo.js'', line 951, character 0. http://bugzilla.mozilla.org/show_bug.cgi?id=228510 Attachment 137793: (Bv1) |return null|, and localization http://bugzilla.mozilla.org/attachment.cgi?id=137793&action=edit ...

superreview cancelled: [Bug 228510] Warning ``function getContentTypeFromHeaders does not always return a value'' [xs] in file ``chrome://navigator/content/pageInfo.js'', line 951, character 0. : [A #2
Serge GAUTHERIE <gautheri@noos.fr> has cancelled Serge GAUTHERIE <gautheri@noos.fr>'s request for superreview: Bug 228510: Warning ``function getContentTypeFromHeaders does not always return a value'' [xs] in file ``chrome://navigator/content/pageInfo.js'', line 951, character 0. http://bugzilla.mozilla.org/show_bug.cgi?id=228510 Attachment 137793: (Bv1) |return null|, and localization http://bugzilla.mozilla.org/attachment.cgi?id=137793&action=edit ...

superreview cancelled: [Bug 228510] Warning ``function getContentTypeFromHeaders does not always return a value'' [xs] in file ``chrome://navigator/content/pageInfo.js'', line 951, character 0. : [A #3
Serge GAUTHERIE <gautheri@noos.fr> has cancelled Serge GAUTHERIE <gautheri@noos.fr>'s request for superreview: Bug 228510: Warning ``function getContentTypeFromHeaders does not always return a value'' [xs] in file ``chrome://navigator/content/pageInfo.js'', line 951, character 0. http://bugzilla.mozilla.org/show_bug.cgi?id=228510 Attachment 137924: (Bv1b) |return null|, and var removals [== Bv1 :-(] http://bugzilla.mozilla.org/attachment.cgi?id=137924&action=edit ...

superreview requested: [Bug 228510] Warning ``function getContentTypeFromHeaders does not always return a value'' [xs] in file ``chrome://navigator/content/pageInfo.js'', line 951, character 0. : [A #3
Serge GAUTHERIE <gautheri@noos.fr> has asked Boris Zbarsky (not in town, no tree) <bz-vacation@mit.edu> for superreview: Bug 228510: Warning ``function getContentTypeFromHeaders does not always return a value'' [xs] in file ``chrome://navigator/content/pageInfo.js'', line 951, character 0. http://bugzilla.mozilla.org/show_bug.cgi?id=228510 Attachment 137924: (Bv1b) |return null|, and var removals http://bugzilla.mozilla.org/attachment.cgi?id=137924&action=edit ...

superreview requested: [Bug 228510] Warning ``function getContentTypeFromHeaders does not always return a value'' [xs] in file ``chrome://navigator/content/pageInfo.js'', line 951, character 0. : [A #4
Serge GAUTHERIE <gautheri@noos.fr> has asked Boris Zbarsky (not in town, no tree) <bz-vacation@mit.edu> for superreview: Bug 228510: Warning ``function getContentTypeFromHeaders does not always return a value'' [xs] in file ``chrome://navigator/content/pageInfo.js'', line 951, character 0. http://bugzilla.mozilla.org/show_bug.cgi?id=228510 Attachment 137926: (Bv2) |return null|, and var removals http://bugzilla.mozilla.org/attachment.cgi?id=137926&action=edit ...

Web resources about - Concerning commit 04783dc7025 fix 'ignoring return value' compiler warnings - perl.perl5.porters

Resources last updated: 12/27/2015 3:26:30 AM