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

_mongoc_uri_set_option_as_int64_with_error uses incorrect format specifier

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 1.18.0-alpha
    • 1.18.0, 1.18.0-alpha2
    • uri
    • None

    Description

      I observed the following -Wformat compiler warning due to _mongoc_uri_set_option_as_int64_with_error using %lld for int64_t:

      /home/jmikola/workspace/mongodb/phpc/src/libmongoc/src/libmongoc/src/mongoc/mongoc-uri.c: In function ‘_mongoc_uri_set_option_as_int64_with_error’:
      /home/jmikola/workspace/mongodb/phpc/src/libmongoc/src/libmongoc/src/mongoc/mongoc-uri.c:2854:10: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 6 has type ‘int64_t’ {aka ‘long int’} [-Wformat=]
       2854 |          "Invalid \"%s\" of %lld: must be a non-negative integer",
            |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       2855 |          option_orig,
       2856 |          value);
            |          ~~~~~
            |          |
            |          int64_t {aka long int}
      /home/jmikola/workspace/mongodb/phpc/src/libmongoc/src/libmongoc/src/mongoc/mongoc-uri.c:61:20: note: in definition of macro ‘MONGOC_URI_ERROR’
         61 |                    format,                           \
            |                    ^~~~~~
      /home/jmikola/workspace/mongodb/phpc/src/libmongoc/src/libmongoc/src/mongoc/mongoc-uri.c:2854:32: note: format string is defined here
       2854 |          "Invalid \"%s\" of %lld: must be a non-negative integer",
            |                             ~~~^
            |                                |
            |                                long long int
            |                             %ld
      

      For portability, it would be preferable to use the PRId64 constant instead.

      Attachments

        Issue Links

          Activity

            People

              jmikola@mongodb.com Jeremy Mikola
              jmikola@mongodb.com Jeremy Mikola
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: