Michael Park created MESOS-3246:
-----------------------------------

             Summary: Replace C-style variadic arguments with C++11 variadic 
templates.
                 Key: MESOS-3246
                 URL: https://issues.apache.org/jira/browse/MESOS-3246
             Project: Mesos
          Issue Type: Task
            Reporter: Michael Park


With the introduction of variadic templates, it's possible to write type-safe 
n-ary functions. Aside from the lack of type-safety, varargs also come with 
subtle pitfalls. For example, as pointed out in 
[r25735|https://reviews.apache.org/r/25735/],

{quote}
N3797: 18.10 Other runtime support \[support.runtime\]

The restrictions that ISO C places on the second parameter to the va_start() 
macro in header <stdarg.h>
are different in this International Standard. The parameter parmN is the 
identifier of the rightmost parameter
in the variable parameter list of the function definition (the one just before 
the ...). *If the parameter parmN is of a reference type,* or of a type that is 
not compatible with the type that results when passing an argument for which 
there is no parameter, *the behavior is undefined.*
{quote}

Currently, the following files have instances of varargs.

{noformat}
3rdparty/libprocess/3rdparty/stout/include/stout/format.hpp
3rdparty/libprocess/3rdparty/stout/include/stout/windows/format.hpp
3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/shell.hpp
3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/shell.hpp
src/jvm/jvm.hpp
src/jvm/jvm.cpp
{noformat}

For {{format.hpp}}, we can simply use {{asprintf}} rather than {{vasprintf}}. 
An additional task here is to add {{asprintf}} in {{windows/format.hpp}}, but 
this can simply delegate to {{vasprintf}} which is already implemented.

The transformation for {{shell.hpp}} is trivial since all it only depends on 
{{format.hpp}}.

The JVM parts are likely to be the biggest undertaking, this needs further 
investigation.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to