Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-2767

Check type of passed skip functions

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor - P4 Minor - P4
    • None
    • None
    • tests
    • None

    Description

      The culprit of CDRIVER-2759 was passing a function with the wrong type to a variadic list. Reading variadic arguments in C is not type safe, so there was no compiler warning/error.

      We could do type checking when TestSuite_AddFull is called by wrapping the variadic arguments with no-op function calls using preprocessor defines. E.g. something along the lines of this:

       

      #define TestSuite_AddFull(_suite, _name, _func, _dtor, _ctx, ...) \
       _TestSuite_AddFull (_suite, _name, _func, _dtor, _ctx, FOREACH(TypeCheck, __VA_ARGS__) NULL)
       

      Where this would expand to:

      _TestSuite_AddFull (_suite, _name, _func, _dtor, _ctx, TypeCheck(chk1), TypeCheck(chk2), TypeCheck(chk3), null)
      

      Therefore, the caller does the type check. We don't have any mechanism for doing a foreach with the preprocessor. See this example and P99_FOR.

      Attachments

        Activity

          People

            Unassigned Unassigned
            kevin.albertson@mongodb.com Kevin Albertson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: