linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Toke Høiland-Jørgensen" <toke@toke.dk>
To: linux-wireless@vger.kernel.org
Cc: "Toke Høiland-Jørgensen" <toke@toke.dk>
Subject: [PATCH] iw: Fix timestamp output on 32-bit architectures
Date: Thu, 18 Mar 2021 23:46:55 +0100	[thread overview]
Message-ID: <20210318224655.143489-1-toke@toke.dk> (raw)

On 32-bit architectures, time_t is 32-bit which causes overflows in the
arithmetic involving tv_sec, leading to invalid output. Fix this by
explicitly adding ULL suffixes to the constants used in those calculations.

Fixes: 3708f614dfdd ("iw: Print current time in station info dump")
Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
---
 station.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/station.c b/station.c
index bddea51815ee..002cf13526cc 100644
--- a/station.c
+++ b/station.c
@@ -337,7 +337,7 @@ static int print_sta_handler(struct nl_msg *msg, void *arg)
 	unsigned long long now_ms;
 
 	gettimeofday(&now, NULL);
-	now_ms = now.tv_sec * 1000;
+	now_ms = now.tv_sec * 1000ULL;
 	now_ms += (now.tv_usec / 1000);
 
 	nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
@@ -601,7 +601,7 @@ static int print_sta_handler(struct nl_msg *msg, void *arg)
 		unsigned long long assoc_at_ms;
 
 		clock_gettime(CLOCK_BOOTTIME, &now_ts);
-		boot_ns = now_ts.tv_sec * 1000000000;
+		boot_ns = now_ts.tv_sec * 1000000000ULL;
 		boot_ns += now_ts.tv_nsec;
 
 		bt = (unsigned long long)nla_get_u64(sinfo[NL80211_STA_INFO_ASSOC_AT_BOOTTIME]);
-- 
2.30.2


                 reply	other threads:[~2021-03-18 22:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210318224655.143489-1-toke@toke.dk \
    --to=toke@toke.dk \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).