Timur Davydov has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/41923?usp=email )


Change subject: core: fix printf format casts for struct timeval fields
......................................................................

core: fix printf format casts for struct timeval fields

Explicitly cast struct timeval fields to long when passing them to
printf-style functions.

This avoids compiler warnings/errors on platforms where tv_sec or
tv_usec are not exactly of type long, while keeping the existing log
and control output unchanged.

Change-Id: Icac9e392c728948a7976970658e37f5e0da41709
---
M src/core/fsm.c
M src/ctrl/fsm_ctrl_commands.c
2 files changed, 3 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/23/41923/1

diff --git a/src/core/fsm.c b/src/core/fsm.c
index 9333cac..a4f1bcb 100644
--- a/src/core/fsm.c
+++ b/src/core/fsm.c
@@ -660,7 +660,7 @@
                        else
                                snprintf(trailer, sizeof(trailer), "(keeping " 
OSMO_T_FMT
                                          ", %ld.%03lds remaining)", 
OSMO_T_FMT_ARGS(fi->T),
-                                         (long) remaining.tv_sec, 
remaining.tv_usec / 1000);
+                                         (long) remaining.tv_sec, (long) 
(remaining.tv_usec / 1000));
                } else if (timeout_ms) {
                        if (timeout_ms % 1000 == 0)
                                /* keep log output legacy compatible to avoid 
autotest failures */
diff --git a/src/ctrl/fsm_ctrl_commands.c b/src/ctrl/fsm_ctrl_commands.c
index c93d3a5..76bc481 100644
--- a/src/ctrl/fsm_ctrl_commands.c
+++ b/src/ctrl/fsm_ctrl_commands.c
@@ -120,7 +120,7 @@
        if (osmo_timer_remaining(&fi->timer, NULL, &remaining) < 0)
                cmd->reply = "0,0,0";
        else
-               cmd->reply = talloc_asprintf(cmd, "%u,%ld,%ld", fi->T, 
remaining.tv_sec, remaining.tv_usec);
+               cmd->reply = talloc_asprintf(cmd, "%u,%ld,%ld", fi->T, (long) 
remaining.tv_sec, (long) remaining.tv_usec);

        return CTRL_CMD_REPLY;
 }
@@ -149,7 +149,7 @@
                rc = osmo_timer_remaining(&fi->timer, NULL, &remaining);
                if (rc == 0) {
                        cmd->reply = talloc_asprintf_append(cmd->reply, 
",timeout_sec=%ld,timeout_usec=%ld",
-                                                           remaining.tv_sec, 
remaining.tv_usec);
+                                                           (long) 
remaining.tv_sec, (long) remaining.tv_usec);
                }
        }


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/41923?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Icac9e392c728948a7976970658e37f5e0da41709
Gerrit-Change-Number: 41923
Gerrit-PatchSet: 1
Gerrit-Owner: Timur Davydov <[email protected]>

Reply via email to