You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by "Dinesh Premalal (JIRA)" <ji...@apache.org> on 2007/04/02 17:04:32 UTC

[jira] Commented: (AXIS2C-252) Use __attribute__ ((warn_unused_result)) to detect failure to check function return values

    [ https://issues.apache.org/jira/browse/AXIS2C-252?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12486037 ] 

Dinesh Premalal commented on AXIS2C-252:
----------------------------------------

Do we want to add this attribute to the functions, that we expose to outside world. I think, it is enough to add it for internal functions.

> Use __attribute__ ((warn_unused_result)) to detect failure to check function return values
> ------------------------------------------------------------------------------------------
>
>                 Key: AXIS2C-252
>                 URL: https://issues.apache.org/jira/browse/AXIS2C-252
>             Project: Axis2-C
>          Issue Type: Bug
>    Affects Versions: Current (Nightly)
>            Reporter: James Clark
>             Fix For: 1.0.0
>
>
> I've noticed several cases where the return values of functions which should be checked aren't being checked.  Things should be set up so that these cases can be detected automatically.  I think the way to do this is to leverage gcc's warn_unused_result attribute. Here's the relevant excerpt from the gcc manual:
> `warn_unused_result'
>      The `warn_unused_result' attribute causes a warning to be emitted
>      if a caller of the function with this attribute does not use its
>      return value.  This is useful for functions where not checking the
>      result is either a security problem or always a bug, such as
>      `realloc'.
>           int fn () __attribute__ ((warn_unused_result));
>           int foo ()
>           {
>             if (fn () < 0) return -1;
>             fn ();
>             return 0;
>           }
>      results in warning on line 5.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-dev-help@ws.apache.org