[Pkg-telepathy-commits] [libnice] 32/265: stun: Fix a use of a function with an aggregate return value

Simon McVittie smcv at debian.org
Wed May 14 12:04:50 UTC 2014


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian
in repository libnice.

commit 3e29fec4a959f2999a0f5a91561f5e798cd9bba2
Author: Philip Withnall <philip.withnall at collabora.co.uk>
Date:   Tue Dec 17 10:06:10 2013 +0000

    stun: Fix a use of a function with an aggregate return value
    
    div() has an aggregate return, which GCC doesn’t like, although this
    seems like a pretty pointless warning because div_t is the same size as
    a pointer on 64-bit platforms (probably) and hardly going to cause
    performance problems by passing it by value.
    
    Anyway, it seems easier to simplify the code by using explicit / and %
    operators inline, than it does to add pragmas and shut the warning up.
---
 stun/stunmessage.c  | 5 ++---
 stun/usages/timer.c | 6 +++---
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/stun/stunmessage.c b/stun/stunmessage.c
index 874d3f1..b9c54e3 100644
--- a/stun/stunmessage.c
+++ b/stun/stunmessage.c
@@ -524,15 +524,14 @@ stun_message_append_error (StunMessage *msg, StunError code)
 {
   const char *str = stun_strerror (code);
   size_t len = strlen (str);
-  div_t d = div (code, 100);
 
   uint8_t *ptr = stun_message_append (msg, STUN_ATTRIBUTE_ERROR_CODE, 4 + len);
   if (ptr == NULL)
     return STUN_MESSAGE_RETURN_NOT_ENOUGH_SPACE;
 
   memset (ptr, 0, 2);
-  ptr[2] = d.quot;
-  ptr[3] = d.rem;
+  ptr[2] = code / 100;
+  ptr[3] = code % 100;
   memcpy (ptr + 4, str, len);
   return STUN_MESSAGE_RETURN_SUCCESS;
 }
diff --git a/stun/usages/timer.c b/stun/usages/timer.c
index ce711c2..82f3ea2 100644
--- a/stun/usages/timer.c
+++ b/stun/usages/timer.c
@@ -88,9 +88,9 @@ static void stun_gettime (struct timeval *now)
 
 static void add_delay (struct timeval *ts, unsigned delay)
 {
-  div_t d = div (delay, 1000);
-  ts->tv_sec += d.quot;
-  ts->tv_usec += d.rem * 1000;
+  /* Delay is in ms. */
+  ts->tv_sec += delay / 1000;
+  ts->tv_usec += (delay % 1000) * 1000;
 
   while (ts->tv_usec > 1000000)
   {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-telepathy/libnice.git



More information about the Pkg-telepathy-commits mailing list