USB_UDE_Sample icon indicating copy to clipboard operation
USB_UDE_Sample copied to clipboard

Initialize ResultLength to fix code analysis warning

Open forderud opened this issue 10 months ago • 4 comments

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 avatar Apr 04 '24 10:04 forderud

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.

xxandy avatar Apr 05 '24 02:04 xxandy

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 avatar Apr 05 '24 07:04 forderud

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

forderud avatar Jun 06 '24 14:06 forderud

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

forderud avatar Aug 02 '24 12:08 forderud