Uploaded image for project: 'Qpid Proton'
  1. Qpid Proton
  2. PROTON-2772

[c] Add parameter safety annotations for printf format strings

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • proton-c-0.39.0
    • proton-c-0.40.0
    • proton-c
    • None

    Description

      There seem to be various mismatched printf format arguments. This is best resolved by annotating the string format parameters so that regular compilation warns on the mismatches as they happen.

      Proton already has some of this, but it is incomplete.

      ```
      /home/jdanek/repos/qpid/qpid-proton/c/src/core/logger.c: In function ‘pni_logger_log_raw’:
      /home/jdanek/repos/qpid/qpid-proton/c/src/core/logger.c:204:41: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 4 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=]
        204 |     pn_fixed_string_addf(&out, "%04x/%04x: ", i, size);
            |                                      ~~~^        ~~~~
            |                                         |        |
            |                                         |        size_t {aka long unsigned int}
            |                                         unsigned int
            |                                      %04lx
      cc1: all warnings being treated as errors
      ```
      

      On windows, we want to enable these optional warning flags

      "/analyzer"
      "/we6328" # Size mismatch: 'unsigned __int64' passed as _Param_(4) when 'int' is required in call to 'ssl_log'.
      "/we6340" # Mismatch on sign: 'unsigned __int64' passed as _Param_(4) when some signed type is required in call to 'ssl_log'.
      

      Attachments

        Activity

          People

            jdanek Jiri Daněk
            jdanek Jiri Daněk
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: