Skip to content

Initialize ResultLength to fix code analysis warning - #39

Open
forderud wants to merge 1 commit into
xxandy:masterfrom
forderud:ResultLength-warn
Open

Initialize ResultLength to fix code analysis warning#39
forderud wants to merge 1 commit into
xxandy:masterfrom
forderud:ResultLength-warn

Conversation

@forderud

@forderud forderud commented Apr 4, 2024

Copy link
Copy Markdown
Contributor

Fixes the following warning when running Code Analysis from Visual Studio:
USB_UDE_Sample\UDEFX2\Device.c(571): warning C6101: Returning uninitialized memory '*ResultLength'. A successful path through the function does not set the named _Out_ parameter.

@xxandy

xxandy commented Apr 5, 2024

Copy link
Copy Markdown
Owner

the parameter is market as optional (Opt) in the annotations, but it is being set before being checked against NULL.. we probably can't do that.

Fixes the following warning when running Code Analysis from Visual Studio:
USB_UDE_Sample\UDEFX2\Device.c(571): warning C6101: Returning uninitialized memory '*ResultLength'.  A successful path through the function does not set the named _Out_ parameter.
@forderud
forderud force-pushed the ResultLength-warn branch from e8786b1 to 81f7dd9 Compare April 5, 2024 07:15
@forderud

forderud commented Apr 5, 2024

Copy link
Copy Markdown
Contributor Author

the parameter is market as optional (Opt) in the annotations, but it is being set before being checked against NULL.. we probably can't do that.

The ResultLength argument is annotated as _Out_, which makes it mandatory. It should therefore be safe to write to without checking first. It's the OutputBuffer argument that is annotated as _Out_writes_to_opt_.

@forderud

forderud commented Jun 6, 2024

Copy link
Copy Markdown
Contributor Author

@xxandy Would it be possible for you to consider this PR?

1 similar comment
@forderud

forderud commented Aug 2, 2024

Copy link
Copy Markdown
Contributor Author

@xxandy Would it be possible for you to consider this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants