Ticket #100 (closed defect: fixed)
Opened 2 years ago
Last modified 18 months ago
[PATCH] - cast of 32 bit value to 64 bit, pthread_exit
| Reported by: | rogueresearch | Owned by: | hjelmn |
|---|---|---|---|
| Milestone: | Component: | libusb-1.0 | |
| Keywords: | Cc: | ||
| Blocked By: | Blocks: |
Description
Attached patch fixes a warning on darwin:
IOReturn kresult;
...
pthread_exit ((void *)kresult);
That's rather evil. :) IOReturn is a 32bit int. On x86_64, casting it to a (64 bit) pointer is not sound.
In any case, pthread_join never uses the value.
Patch is simple, and attached.
Attachments
Change History
Changed 2 years ago by rogueresearch
comment:1 Changed 2 years ago by rogueresearch
- Summary changed from PATCH - cast of 32 bit value to 64 bit, pthread_exit to [PATCH] - cast of 32 bit value to 64 bit, pthread_exit
comment:2 Changed 2 years ago by segher
comment:3 Changed 2 years ago by rogueresearch
Tim, the language may specify the behaviour, but I maintain that it's a horrible code smell.
segher, the warning is: "warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]"
comment:4 Changed 2 years ago by segher
Ah yes. GCC has this exact same warning, and it's included in -Wall.
Using void* in this way is a common idiom; it works fine on pretty
much all compilers, but it is not portable C (it is implementation-
defined behaviour).
comment:5 Changed 2 years ago by rogueresearch
So we agree the current usage is not portable, and since pthread_join() plainly never uses the value in this case anyway, do we agree the patch is good?
Can it be accepted and merged? Thanks.
comment:6 Changed 21 months ago by rogueresearch
comment:7 Changed 20 months ago by rogueresearch
- Resolution set to fixed
- Status changed from new to closed
Confirmed fixed in http://git.libusb.org/libusb.git "testing" branch.
What is the warning message?