Project

General

Profile

Actions

Optimization #3206

closed

improve int handling

Added by Victor Julien about 5 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Effort:
Difficulty:
Label:

Description

Using clang-8 (and probably others) we can use -Werror,-Wimplicit-int-conversion. https://clang.llvm.org/docs/DiagnosticsReference.html#wimplicit-int-conversion

It would be good to fix all issues this triggers. With unittests disabled, this is the first one:

alert-unified2-alert.c:415:53: error: implicit conversion loses integer precision: 'unsigned long' to 'uint16_t' (aka 'unsigned short') [-Werror,-Wimplicit-int-conversion]
    fakehdr->ip6h.s_ip6_plen = htons(sizeof(TCPHdr) + payload_len);
                               ~~~~~ ~~~~~~~~~~~~~~~^~~~~~~~~~~~~
alert-unified2-alert.c:582:52: error: implicit conversion loses integer precision: 'unsigned long' to 'uint16_t' (aka 'unsigned short') [-Werror,-Wimplicit-int-conversion]
                (uint16_t *)&fakehdr->tcph, buflen + sizeof(TCPHdr), 0);
                                            ~~~~~~~^~~~~~~~~~~~~~~~
alert-unified2-alert.c:587:52: error: implicit conversion loses integer precision: 'unsigned long' to 'uint16_t' (aka 'unsigned short') [-Werror,-Wimplicit-int-conversion]
                (uint16_t *)&fakehdr->tcph, buflen + sizeof(TCPHdr), 0);
                                            ~~~~~~~^~~~~~~~~~~~~~~~
3 errors generated.

Once master is completely fixed a CI check should be put in place.

Actions #1

Updated by Philippe Antoine about 3 years ago

  • Status changed from New to Closed

Duplicate of #4516

Actions

Also available in: Atom PDF