Commit efe2289
committed
Linux netfilter: Avoid a Y2K38_SAFETY Coverity warning
It's about 'Sequence number' in Netlink messages.
The Linux Documentation/userspace-api/netlink/intro.rst states:
:c:member:`nlmsghdr.nlmsg_seq` should be a set to a monotonically
increasing value. The value gets echoed back in responses and doesn't
matter in practice, but setting it to an increasing value for each
message sent is considered good hygiene. The purpose of the field is
matching responses to requests.
Thus seq_id, used to set it, hss no need to be initialized to
time(NULL). It can start at 1.
The Coverity warning was:
CID 1508935: Use of 32-bit time_t (Y2K38_SAFETY)
A time_t value is stored in an integer with too few bits to accommodate
it. The expression time(NULL) is cast to unsigned int.
356 seq_id = time(NULL);
There was also an old clang warning on 64-bit build:
pcap-netfilter-linux.c:356:12: warning: implicit conversion loses
integer precision: 'time_t' (aka 'long') to 'unsigned int'
[-Wshorten-64-to-32]
356 | seq_id = time(NULL);
| ~ ^~~~~~~~~~
It was silenced by 16782c7.
The "To be look at before 2038..." in the previous commit is no longer
relevant.1 parent 0056b3a commit efe2289
1 file changed
+0
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
351 | 351 | | |
352 | 352 | | |
353 | 353 | | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | 354 | | |
359 | 355 | | |
360 | 356 | | |
| |||
0 commit comments