You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficserver.apache.org by "Leif Hedstrom (JIRA)" <ji...@apache.org> on 2011/02/28 04:38:36 UTC

[jira] Created: (TS-680) Make SDK opaque types use opaque struct's instead of void* ?

Make SDK opaque types use opaque struct's instead of void* ?
------------------------------------------------------------

                 Key: TS-680
                 URL: https://issues.apache.org/jira/browse/TS-680
             Project: Traffic Server
          Issue Type: Improvement
          Components: TS API
            Reporter: Leif Hedstrom
             Fix For: 2.1.6


This could allow a compiler to warn on inappropriate parameters for example.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (TS-680) Make SDK opaque types use opaque struct's instead of void* ?

Posted by "Leif Hedstrom (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TS-680?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Leif Hedstrom updated TS-680:
-----------------------------

    Assignee: Leif Hedstrom

> Make SDK opaque types use opaque struct's instead of void* ?
> ------------------------------------------------------------
>
>                 Key: TS-680
>                 URL: https://issues.apache.org/jira/browse/TS-680
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: TS API
>            Reporter: Leif Hedstrom
>            Assignee: Leif Hedstrom
>             Fix For: 2.1.7
>
>         Attachments: prototypes.diff
>
>
> This could allow a compiler to warn on inappropriate parameters for example.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (TS-680) Make SDK opaque types use opaque struct's instead of void* ?

Posted by "Alan M. Carroll (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TS-680?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alan M. Carroll updated TS-680:
-------------------------------

    Description: 
This could allow a compiler to warn on inappropriate parameters for example.

The problem is that many API parameters are passed as (void*). This means that not only can they can unsafely interchanged (either passing the wrong parameter or passing them in the wrong order) but completely inappropriate (non-API) pointers can be passed as well, all without any warning from the compiler.

This could be improved by declaring parameter types to be pointers to in name only types. This would make them non-trivially interchangeable with each other and non-API pointers. Although passing inappropriate parameters would still be possible it would be *much* harder to do by accident, in contrast to the current API in which it is very easy to do.


  was:This could allow a compiler to warn on inappropriate parameters for example.


> Make SDK opaque types use opaque struct's instead of void* ?
> ------------------------------------------------------------
>
>                 Key: TS-680
>                 URL: https://issues.apache.org/jira/browse/TS-680
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: TS API
>            Reporter: Leif Hedstrom
>            Assignee: Leif Hedstrom
>             Fix For: 2.1.7
>
>         Attachments: prototypes.diff
>
>
> This could allow a compiler to warn on inappropriate parameters for example.
> The problem is that many API parameters are passed as (void*). This means that not only can they can unsafely interchanged (either passing the wrong parameter or passing them in the wrong order) but completely inappropriate (non-API) pointers can be passed as well, all without any warning from the compiler.
> This could be improved by declaring parameter types to be pointers to in name only types. This would make them non-trivially interchangeable with each other and non-API pointers. Although passing inappropriate parameters would still be possible it would be *much* harder to do by accident, in contrast to the current API in which it is very easy to do.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Resolved: (TS-680) Make SDK opaque types use opaque struct's instead of void* ?

Posted by "Leif Hedstrom (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TS-680?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Leif Hedstrom resolved TS-680.
------------------------------

    Resolution: Fixed

> Make SDK opaque types use opaque struct's instead of void* ?
> ------------------------------------------------------------
>
>                 Key: TS-680
>                 URL: https://issues.apache.org/jira/browse/TS-680
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: TS API
>            Reporter: Leif Hedstrom
>            Assignee: Leif Hedstrom
>             Fix For: 2.1.7
>
>         Attachments: prototypes.diff
>
>
> This could allow a compiler to warn on inappropriate parameters for example.
> The problem is that many API parameters are passed as (void*). This means that not only can they can unsafely interchanged (either passing the wrong parameter or passing them in the wrong order) but completely inappropriate (non-API) pointers can be passed as well, all without any warning from the compiler.
> This could be improved by declaring parameter types to be pointers to in name only types. This would make them non-trivially interchangeable with each other and non-API pointers. Although passing inappropriate parameters would still be possible it would be *much* harder to do by accident, in contrast to the current API in which it is very easy to do.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] Commented: (TS-680) Make SDK opaque types use opaque struct's instead of void* ?

Posted by "Alan M. Carroll (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TS-680?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13001799#comment-13001799 ] 

Alan M. Carroll commented on TS-680:
------------------------------------

To pick a personal nit, non-member names starting with underscore are reserved for the implementation, so 'struct _tsmloc' is illegal. Unfortunately, because the API must be C compatible we can't use a namespace.

Beyond being a lot of work for the TS team, it shouldn't have any negative impact on plugin developers as all of the API types affected are opaque. Overall it seems like a net positive.

> Make SDK opaque types use opaque struct's instead of void* ?
> ------------------------------------------------------------
>
>                 Key: TS-680
>                 URL: https://issues.apache.org/jira/browse/TS-680
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: TS API
>            Reporter: Leif Hedstrom
>            Assignee: Leif Hedstrom
>             Fix For: 2.1.7
>
>         Attachments: prototypes.diff
>
>
> This could allow a compiler to warn on inappropriate parameters for example.
> The problem is that many API parameters are passed as (void*). This means that not only can they can unsafely interchanged (either passing the wrong parameter or passing them in the wrong order) but completely inappropriate (non-API) pointers can be passed as well, all without any warning from the compiler.
> This could be improved by declaring parameter types to be pointers to in name only types. This would make them non-trivially interchangeable with each other and non-API pointers. Although passing inappropriate parameters would still be possible it would be *much* harder to do by accident, in contrast to the current API in which it is very easy to do.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (TS-680) Make SDK opaque types use opaque struct's instead of void* ?

Posted by "Leif Hedstrom (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TS-680?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Leif Hedstrom updated TS-680:
-----------------------------

    Attachment: prototypes.diff

Attached is an "example" of what it could take / look like if we did something simple like just an anonymous (opaque) struct pointer.

Not being a C++ expert, the only way I could get it to compile was using reinterpret_cast (well, other than using C casts, and amc would kill me if I tried to use them).

This is not a "patch" proposal, but to open up the discussion on some ideas around this.

> Make SDK opaque types use opaque struct's instead of void* ?
> ------------------------------------------------------------
>
>                 Key: TS-680
>                 URL: https://issues.apache.org/jira/browse/TS-680
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: TS API
>            Reporter: Leif Hedstrom
>             Fix For: 2.1.7
>
>         Attachments: prototypes.diff
>
>
> This could allow a compiler to warn on inappropriate parameters for example.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira