Skip to content

<wil/safecast.h> should have a helper that can cast larger with zero-extension of signed types #473

@dmachaj

Description

@dmachaj

I am trying to work through some suppressed compiler warnings in one of our code bases. Many of the suppressed warnings are C4312. This warning is saying that if a signed integer is cast upwards into a pointer type it may become unsafe if the original value was negative. The cast will fill in the upper bits with ones, which would change the pointer to some address in the kernel address space.

This new helper aims to help with that by casting upwards with 0s as the upper bits. That will avoid changing the value to something unsafe if it really is treated as a pointer.

(PR to follow shortly)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions