[CDRIVER-3951] _mongoc_uri_set_option_as_int64_with_error uses incorrect format specifier Created: 09/Apr/21  Updated: 28/Oct/23  Resolved: 19/Apr/21

Status: Closed
Project: C Driver
Component/s: uri
Affects Version/s: 1.18.0-alpha
Fix Version/s: 1.18.0, 1.18.0-alpha2

Type: Bug Priority: Major - P3
Reporter: Jeremy Mikola Assignee: Jeremy Mikola
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to CDRIVER-3850 Allow timeoutMS to be set via the URI Closed

 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.



 Comments   
Comment by Githook User [ 03/Jun/21 ]

Author:

{'name': 'Jeremy Mikola', 'email': 'jmikola@gmail.com', 'username': 'jmikola'}

Message: CDRIVER-3951 Use PRId64 format specifier for int64_t
Branch: r1.18
https://github.com/mongodb/mongo-c-driver/commit/c10c34e68715363e1c2876c6c1dd4ea3e960b8b5

Comment by Githook User [ 19/Apr/21 ]

Author:

{'name': 'Jeremy Mikola', 'email': 'jmikola@gmail.com', 'username': 'jmikola'}

Message: CDRIVER-3951 Use PRId64 format specifier for int64_t
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/01e651af2b70a297128f90e0a9135f6aa1fecf10

Comment by Jeremy Mikola [ 09/Apr/21 ]

https://github.com/mongodb/mongo-c-driver/pull/777

Comment by Jeremy Mikola [ 09/Apr/21 ]

This was introduced in 6bacf92 for CDRIVER-3850.

Generated at Wed Feb 07 21:19:29 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.