Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn integers downcast 64to32 6186 v1 #9105

Closed
wants to merge 2 commits into from

Conversation

catenacyber
Copy link
Contributor

Link to redmine ticket:
https://redmine.openinfosecfoundation.org/issues/6186

Describe changes:

  • ci : add the -Wshorten-64-to-32 flag to clang after -Wimplicit-int-conversion
  • fix these warnings for all src/a*.c

Provide values to any of the below to override the defaults.

LIBHTP_BRANCH=pr/396

OISF/libhtp#396

Draft : is this the way to go ?
Make multiple PRs for this redmine ticket
I will remove the CI commit in the next version, but so, we have some red feedback to see what is still to be fixed

Ticket: OISF#6186

clang warns and errors on 64 to 32 bits integer conversion
Ticket: OISF#6186

Warnings about downcast from 64 to 32 bits
@@ -686,7 +686,7 @@ static uint32_t AppLayerProtoDetectProbingParserGetMask(AppProto alproto)
FatalError("Unknown protocol detected - %u", alproto);
}

SCReturnUInt(1UL << (uint32_t)alproto);
SCReturnUInt(1 << (uint32_t)alproto);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should AppLayerProtoDetectProbingParserGetMask return a u64 ?
But then flow structure needs to grow 2 u32 into 2 u64...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why an u64?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we will soon have more than 32 app-layer protocols, right ?

@@ -60,7 +60,7 @@ typedef struct Frame {
typedef struct Frames {
uint16_t cnt;
uint16_t dyn_size; /**< size in elements of `dframes` */
uint32_t left_edge_rel;
uint64_t left_edge_rel;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@victorjulien is this correct for frames ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no it's u32 intentionally, it's relative to something, I think the stream base seq. So when used it's added to that other thing.

@@ -53,8 +53,8 @@ typedef struct {
{ \
.secs = 0, .usecs = 0 \
}
#define SCTIME_USECS(t) ((uint64_t)(t).usecs)
#define SCTIME_SECS(t) ((uint64_t)(t).secs)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jlucovsky do you remember the reason for the cast ?

@catenacyber
Copy link
Contributor Author

Also draft to get CI feedback.
I think it is likely that these changes will break one build...

@suricata-qa
Copy link

WARNING:

field baseline test %
SURI_TLPR1_stats_chk
.app_layer.flow.rfb 221 246 111.31%
.app_layer.tx.rfb 227 246 108.37%
.app_layer.error.rfb.parser 242 1 0.41%

Pipeline 14912

@catenacyber
Copy link
Contributor Author

Replaced by #9117

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants