[ 
https://issues.apache.org/jira/browse/PROTON-2772?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17804002#comment-17804002
 ] 

ASF GitHub Bot commented on PROTON-2772:
----------------------------------------

jiridanek commented on code in PR #419:
URL: https://github.com/apache/qpid-proton/pull/419#discussion_r1444068569


##########
c/src/core/engine.c:
##########
@@ -1645,9 +1645,9 @@ void pn_delivery_dump(pn_delivery_t *d)
   printf("{tag=%s, local.type=%" PRIu64 ", remote.type=%" PRIu64 ", 
local.settled=%u, "
          "remote.settled=%u, updated=%u, current=%u, writable=%u, readable=%u, 
"
          "work=%u}",
-         tag, d->local.type, d->remote.type, d->local.settled,
-         d->remote.settled, d->updated, pn_delivery_current(d),
-         pn_delivery_writable(d), pn_delivery_readable(d), d->work);
+         tag, d->local.type, d->remote.type, (unsigned)d->local.settled,
+         (unsigned)d->remote.settled, (unsigned)d->updated, 
(unsigned)pn_delivery_current(d),
+         (unsigned)pn_delivery_writable(d), (unsigned)pn_delivery_readable(d), 
(unsigned)d->work);

Review Comment:
   MSVC would be happy to print `bool`s with `%i`, but `%u` it does not like. 
Maybe just go with `%i` or `%d` instead?





> [c] Add parameter safety annotations for printf format strings
> --------------------------------------------------------------
>
>                 Key: PROTON-2772
>                 URL: https://issues.apache.org/jira/browse/PROTON-2772
>             Project: Qpid Proton
>          Issue Type: Improvement
>          Components: proton-c
>    Affects Versions: proton-c-0.39.0
>            Reporter: Jiri Daněk
>            Assignee: Jiri Daněk
>            Priority: Major
>             Fix For: proton-c-0.40.0
>
>
> 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.
> {noformat}
> ```
> /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
> ```
> {noformat}
> On windows, we want to enable these optional warning flags
> {noformat}
> "/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'.
> {noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org
For additional commands, e-mail: dev-h...@qpid.apache.org

Reply via email to