Closed Bug 1573097 Opened 5 years ago Closed 9 months ago

Invalid casts in instance.c

Categories

(NSS :: Libraries, defect, P3)

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: mt, Unassigned)

References

Details

(Keywords: good-first-bug)

Attachments

(2 files, 1 obsolete file)

cl on Windows complains of an invalid cast in instance.c:

...\nss\lib\ckfw\instance.c(550): warning C4312: 'type cast': conversion from 'CK_SESSION_HANDLE' to 'const void *' of greater size

This probably benign, but we should build a function that performs this conversion AND statically asserts that the conversion is lossless, i.e.:

PR_STATIC_ASSERT(sizeof(CK_SESSION_HANDLE) <= sizeof(void*));

That function might need to be structured so that it suppresses the warning, but we can probably use uintptr_t as an intermediate value.

Type: task → defect
Priority: -- → P3

Hello, although I am new to this community I would love to attempt contributing to this bug. Thanks

Flags: needinfo?(mt)

If you can make some changes to instance.c that makes the warnings go away, that would be greatly appreciated. I would start with reproducing the problem on a Windows build. Then take a look at the code to see what might be changed to fix it.

Flags: needinfo?(mt)

Sorry, I realized my build is done in a linux environment. Thanks for your time

I would like to work on this bug.

Please see the contribution documentation at https://firefox-source-docs.mozilla.org/.

Flags: needinfo?(sd2187)

Okay

Flags: needinfo?(sd2187)
Attachment #9250512 - Attachment description: Bug 1573097- Invalid casts in instance.c r?keeler → Bug 1573097- Invalid casts in instance.c r?bbeurdouche
Attachment #9250512 - Attachment description: Bug 1573097- Invalid casts in instance.c r?bbeurdouche → Bug 1573097- Invalid casts in instance.c r?keeler
Attachment #9250512 - Attachment description: Bug 1573097- Invalid casts in instance.c r?keeler → Bug 1573097- Invalid casts in instance.c r?mt
Severity: normal → S3

Add the CKSessionHandleToVoidPtr function, which performs the
conversion from CK_SESSION_HANDLE to const void* using uintptr_t
as an intermediate value. This function is then used in the
nssCKFWHash_Add function call to avoid the warning and ensure
the conversion is lossless.

Attachment #9338192 - Attachment description: WIP: Bug 1573097 - Fix Invalid casts in instance.c → Bug 1573097 - Fix Invalid casts in instance.c r?mt
Attachment #9338192 - Attachment description: Bug 1573097 - Fix Invalid casts in instance.c r?mt → Bug 1573097 - Fix Invalid casts in instance.c r=mt

The patch for this bug should be for the NSS repo right? The code lives there and then Firefox vendors it into mozilla-central when NSS releases a new version.

Status: NEW → RESOLVED
Closed: 9 months ago
Resolution: --- → FIXED
Attachment #9338192 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: